Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksongoode committed Jul 26, 2024
1 parent 9affe6e commit 5c94904
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions psst-gui/src/controller/playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,31 +187,25 @@ impl PlaybackController {

fn update_media_control_metadata(&mut self, playback: &Playback) {
if let Some(media_controls) = self.media_controls.as_mut() {
let title = playback.now_playing.as_ref().map(|p| p.item.name().clone());
let album = playback
.now_playing
.as_ref()
.and_then(|p| p.item.track())
.map(|t| t.album_name());
let artist = playback
.now_playing
.as_ref()
.and_then(|p| p.item.track())
.map(|t| t.artist_name());
let duration = playback.now_playing.as_ref().map(|p| p.item.duration());
let cover_url = playback
.now_playing
.as_ref()
.and_then(|p| p.cover_image_url(512.0, 512.0));
media_controls
.set_metadata(MediaMetadata {
title: title.as_deref(),
album: album.as_deref(),
if let Some(now_playing) = &playback.now_playing {
let title = now_playing.item.name();
let album = now_playing
.item
.track()
.and_then(|t| t.album.as_ref().map(|a| &a.name));
let artist = now_playing.item.track().map(|t| t.artist_name());
let duration = now_playing.item.duration();
let cover_url = now_playing.cover_image_url(512.0, 512.0);

let metadata = MediaMetadata {
title: Some(title.as_ref()),
album: album.map(|a| a.as_ref()),
artist: artist.as_deref(),
duration,
duration: Some(duration),
cover_url,
})
.unwrap();
};
media_controls.set_metadata(metadata).unwrap();
}
}
}

Expand Down

0 comments on commit 5c94904

Please sign in to comment.