diff --git a/src/mpris/player.rs b/src/mpris/player.rs index 81009d3..1a18b87 100644 --- a/src/mpris/player.rs +++ b/src/mpris/player.rs @@ -83,6 +83,23 @@ impl Player { ), ); + playbin.connect_notify_local( + Some("state"), + glib::clone!( + #[strong] + player_ref, + move |_playbin: &crate::Playbin, _| { + let player_ref = player_ref.clone(); + glib::spawn_future_local(async move { + player_ref.get_mut().await + .playback_status_changed(player_ref.signal_emitter()) + .await + .unwrap(); + }); + } + ), + ); + playbin.connect_notify_local( Some("volume"), glib::clone!( @@ -305,27 +322,27 @@ impl Player { #[zbus(property)] fn can_go_next(&self) -> bool { - self.playbin.upgrade().unwrap().state() != crate::playbin::State::Stopped + true } #[zbus(property)] fn can_go_previous(&self) -> bool { - self.playbin.upgrade().unwrap().state() != crate::playbin::State::Stopped + true } #[zbus(property)] fn can_play(&self) -> bool { - self.playbin.upgrade().unwrap().state() != crate::playbin::State::Stopped + true } #[zbus(property)] fn can_pause(&self) -> bool { - self.playbin.upgrade().unwrap().state() != crate::playbin::State::Stopped + true } #[zbus(property)] fn can_seek(&self) -> bool { - self.playbin.upgrade().unwrap().state() != crate::playbin::State::Stopped + true } #[zbus(property(emits_changed_signal = "const"))]