From 72795327455481645d65d271005bea6ac9d73bc8 Mon Sep 17 00:00:00 2001 From: Erica Z Date: Fri, 1 Nov 2024 18:01:14 +0100 Subject: [PATCH] signals signals --- src/mpris/player.rs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) 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"))]