From c605a9fa8a799cae038fdee6bc5f8c370f8a972c Mon Sep 17 00:00:00 2001 From: 0xQan <125211961+FurqanHun@users.noreply.github.com> Date: Fri, 10 Apr 2026 01:10:02 +0500 Subject: [PATCH] fix: sync mpris state before emission and send PlaybackStatus property alongside Metadata (#122) * fix: sync mpris state before emission and send PlaybackStatus property alongside Metadata * style: add whitespace --------- Co-authored-by: talwat <83217276+talwat@users.noreply.github.com> --- src/ui/mpris.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/ui/mpris.rs b/src/ui/mpris.rs index a063667..409a742 100644 --- a/src/ui/mpris.rs +++ b/src/ui/mpris.rs @@ -268,6 +268,12 @@ pub struct Server { impl Server { /// Handles a player message to update the state of the MPRIS player. pub async fn handle(&mut self, message: &crate::Message) -> ui::Result<()> { + while let Ok(update) = self.receiver.try_recv() { + if let Update::Track(current) = update { + self.player().current.swap(Arc::new(current)); + } + } + match message { Message::ChangeVolume(_) | Message::SetVolume(_) => self.update_volume().await, Message::Play | Message::Pause | Message::PlayPause => self.update_playback().await, @@ -281,12 +287,6 @@ impl Server { &mut self, properties: impl IntoIterator + Send + Sync, ) -> ui::Result<()> { - while let Ok(update) = self.receiver.try_recv() { - if let Update::Track(current) = update { - self.player().current.swap(Arc::new(current)); - } - } - self.inner.properties_changed(properties).await?; Ok(()) } @@ -310,7 +310,12 @@ impl Server { /// Updates the current track data with the current information. async fn update_metadata(&mut self) -> ui::Result<()> { let metadata = self.player().metadata().await?; - self.changed(vec![Property::Metadata(metadata)]).await?; + let status = self.player().playback_status().await?; + self.changed(vec![ + Property::Metadata(metadata), + Property::PlaybackStatus(status), + ]) + .await?; Ok(()) }