diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f5a6bda..0a4d4b4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Multiple instances interfering with each other's MPRIS implementation - An unlikely crash when the UNIX IPC socket is removed before `ncspot` is closed - Guaranteed crash while quiting `ncspot` when using MPRIS +- MPRIS volume not being updated when given numbers smaller than 0 or larger than 1 ## [0.13.4] - 2023-07-24 diff --git a/src/mpris.rs b/src/mpris.rs index a7fda8a9..2a192d24 100644 --- a/src/mpris.rs +++ b/src/mpris.rs @@ -269,13 +269,12 @@ impl MprisPlayer { } #[dbus_interface(property)] - fn set_volume(&self, volume: f64) { + fn set_volume(&self, mut volume: f64) { log::info!("set volume: {volume}"); - if (0.0..=1.0).contains(&volume) { - let vol = (VOLUME_PERCENT as f64) * volume * 100.0; - self.spotify.set_volume(vol as u16); - self.event.trigger(); - } + volume = volume.clamp(0.0, 1.0); + let vol = (VOLUME_PERCENT as f64) * volume * 100.0; + self.spotify.set_volume(vol as u16); + self.event.trigger(); } #[dbus_interface(property)]