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>
This commit is contained in:
0xQan 2026-04-10 01:10:02 +05:00 committed by GitHub
parent cfe0d746c2
commit c605a9fa8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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<Item = mpris_server::Property> + 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(())
}