From 044101b29091eab34f5bb11ad8929db266826705 Mon Sep 17 00:00:00 2001 From: krolxon Date: Wed, 24 Apr 2024 13:56:53 +0530 Subject: handle seek forwards/backwords --- src/connection.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/connection.rs') diff --git a/src/connection.rs b/src/connection.rs index fa8cc78..16055a5 100755 --- a/src/connection.rs +++ b/src/connection.rs @@ -10,7 +10,7 @@ pub type Error = Box; pub struct Connection { pub conn: Client, pub songs_filenames: Vec, - // pub state: String, + pub state: String, } impl Connection { @@ -27,7 +27,7 @@ impl Connection { Ok(Self { conn, songs_filenames, - // state: "Stopped".to_string(), + state: "Stopped".to_string(), }) } @@ -55,13 +55,14 @@ impl Connection { Ok(()) } - // pub fn update_state(&mut self) { - // match self.conn.status().unwrap().state { - // State::Stop => self.state = "Stopped".to_string(), - // State::Play => self.state = "Playing".to_string(), - // State::Pause => self.state = "Paused".to_string(), - // } - // } + pub fn update_state(&mut self) -> String { + match self.conn.status().unwrap().state { + State::Stop => self.state = "Stopped".to_string(), + State::Play => self.state = "Playing".to_string(), + State::Pause => self.state = "Paused".to_string(), + } + self.state.clone() + } /// push the given song to queue pub fn push(&mut self, song: &Song) -> Result<()> { @@ -136,7 +137,7 @@ impl Connection { let song = self.conn.currentsong()?.unwrap_or_default(); if let Some(s) = song.title { if let Some(a) = song.artist { - return Ok(Some(format!("{} - {}", s, a))); + return Ok(Some(format!("\"{}\" By {}", a, s))); } else { return Ok(Some(s)); } -- cgit v1.2.3