diff --git a/Cargo.lock b/Cargo.lock index 1a0fc45..22bcb8c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,9 +79,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.12" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fec134f64e2bc57411226dfc4e52dec859ddfc7e711fc5e07b612584f000e4aa" +checksum = "0cb8f1d480b0ea3783ab015936d2a55c87e219676f0c0b7dec61494043f21857" dependencies = [ "flate2", "futures-core", diff --git a/src/mpris/player.rs b/src/mpris/player.rs index 05790ab..a19a46e 100644 --- a/src/mpris/player.rs +++ b/src/mpris/player.rs @@ -241,42 +241,50 @@ impl Player { #[zbus::interface(name = "org.mpris.MediaPlayer2.Player")] impl Player { + #[tracing::instrument(skip(self), parent = None, target = "audrey::mpris", level = Level::DEBUG, ret)] fn next(&self) -> zbus::fdo::Result<()> { self.window().playlist_next(); Ok(()) } + #[tracing::instrument(skip(self), parent = None, target = "audrey::mpris", level = Level::DEBUG, ret)] fn previous(&self) -> zbus::fdo::Result<()> { self.window().playlist_prev(); Ok(()) } + #[tracing::instrument(skip(self), parent = None, target = "audrey::mpris", level = Level::DEBUG, ret)] fn pause(&self) -> zbus::fdo::Result<()> { self.window().set_pause(true); Ok(()) } + #[tracing::instrument(skip(self), parent = None, target = "audrey::mpris", level = Level::DEBUG, ret)] fn play_pause(&self) -> zbus::fdo::Result<()> { self.window().set_pause(!self.window().pause()); Ok(()) } + #[tracing::instrument(skip(self), parent = None, target = "audrey::mpris", level = Level::DEBUG, ret)] fn stop(&self) -> zbus::fdo::Result<()> { self.window().set_pause(true); self.window().set_time_pos(0.0); Ok(()) } + #[tracing::instrument(skip(self), parent = None, target = "audrey::mpris", level = Level::DEBUG, ret)] fn play(&self) -> zbus::fdo::Result<()> { self.window().set_pause(false); Ok(()) } + #[tracing::instrument(skip(self), parent = None, target = "audrey::mpris", level = Level::DEBUG, ret)] fn seek(&self, offset: i64) -> zbus::fdo::Result<()> { self.window().seek(offset as f64 / MICROSECONDS); Ok(()) } + #[tracing::instrument(skip(self), parent = None, target = "audrey::mpris", level = Level::DEBUG, ret)] 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); @@ -284,6 +292,7 @@ impl Player { Ok(()) } + #[tracing::instrument(skip(self), parent = None, target = "audrey::mpris", level = Level::DEBUG, ret)] fn open_uri(&self, _s: String) -> zbus::fdo::Result<()> { Err(zbus::fdo::Error::NotSupported("OpenUri".into())) } @@ -318,13 +327,13 @@ impl Player { #[zbus(property)] fn set_rate(&self, _rate: f64) -> zbus::Result<()> { // A value of 0.0 should not be set by the client. If it is, the media player should act as though Pause was called. - todo!() + Err(zbus::fdo::Error::NotSupported("setting Rate".into()).into()) // TODO } - #[zbus(property)] // FIXME: https://github.com/dbus2/zbus/issues/992 + #[zbus(property)] fn shuffle(&self) -> zbus::fdo::Result { - Ok(false) + Err(zbus::fdo::Error::NotSupported("Shuffle".into()).into()) } #[zbus(property)] @@ -344,8 +353,10 @@ impl Player { } #[zbus(property)] - fn set_volume(&self, _volume: f64) -> zbus::Result<()> { - todo!() + #[tracing::instrument(skip(self), parent = None, target = "audrey::mpris", level = Level::DEBUG, ret)] + fn set_volume(&self, volume: f64) -> zbus::Result<()> { + let corrected_volume = (volume.clamp(0.0, 1.0) * 100.0) as i64; + Ok(self.window().set_volume(corrected_volume)) } #[zbus(property(emits_changed_signal = "false"))]