diff --git a/src/mpris/player.rs b/src/mpris/player.rs index a56d741..05790ab 100644 --- a/src/mpris/player.rs +++ b/src/mpris/player.rs @@ -242,35 +242,46 @@ impl Player { #[zbus::interface(name = "org.mpris.MediaPlayer2.Player")] impl Player { fn next(&self) -> zbus::fdo::Result<()> { - Err(zbus::fdo::Error::NotSupported("not implemented".into())) + self.window().playlist_next(); + Ok(()) } fn previous(&self) -> zbus::fdo::Result<()> { - Err(zbus::fdo::Error::NotSupported("not implemented".into())) + self.window().playlist_prev(); + Ok(()) } fn pause(&self) -> zbus::fdo::Result<()> { - Err(zbus::fdo::Error::NotSupported("not implemented".into())) + self.window().set_pause(true); + Ok(()) } fn play_pause(&self) -> zbus::fdo::Result<()> { - Err(zbus::fdo::Error::NotSupported("not implemented".into())) + self.window().set_pause(!self.window().pause()); + Ok(()) } fn stop(&self) -> zbus::fdo::Result<()> { - Err(zbus::fdo::Error::NotSupported("not implemented".into())) + self.window().set_pause(true); + self.window().set_time_pos(0.0); + Ok(()) } fn play(&self) -> zbus::fdo::Result<()> { - Err(zbus::fdo::Error::NotSupported("not implemented".into())) + self.window().set_pause(false); + Ok(()) } - fn seek(&self, _offset: i64) -> zbus::fdo::Result<()> { - Err(zbus::fdo::Error::NotSupported("not implemented".into())) + fn seek(&self, offset: i64) -> zbus::fdo::Result<()> { + self.window().seek(offset as f64 / MICROSECONDS); + Ok(()) } - fn set_position(&self, _track_id: ObjectPath<'_>, _position: i64) -> zbus::fdo::Result<()> { - Err(zbus::fdo::Error::NotSupported("not implemented".into())) + fn set_position(&self, track_id: ObjectPath<'_>, position: i64) -> zbus::fdo::Result<()> { + if Some(track_id) == self.metadata.track_id.as_ref().map(|x| x.as_ref()) { + self.window().set_time_pos(position as f64 / MICROSECONDS); + } + Ok(()) } fn open_uri(&self, _s: String) -> zbus::fdo::Result<()> {