mirror of
https://github.com/talwat/lowfi
synced 2026-04-27 04:16:31 +00:00
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:
parent
cfe0d746c2
commit
c605a9fa8a
@ -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(())
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user