Find the current song's URL and pass it on when possible

This commit is contained in:
Danielle McLean 2024-07-23 13:29:50 +10:00
parent b8bcdc5a83
commit d9c8e0fe28
Signed by: 00dani
GPG key ID: 6854781A0488421C
9 changed files with 79 additions and 21 deletions

View file

@ -25,6 +25,7 @@ from MediaPlayer import (
MPNowPlayingInfoCenter,
MPNowPlayingInfoMediaTypeAudio,
MPNowPlayingInfoMediaTypeNone,
MPNowPlayingInfoPropertyAssetURL,
MPNowPlayingInfoPropertyElapsedPlaybackTime,
MPNowPlayingInfoPropertyExternalContentIdentifier,
MPNowPlayingInfoPropertyMediaType,
@ -106,6 +107,9 @@ def song_to_media_item(song: Song) -> NSMutableDictionary:
nowplaying_info[MPMediaItemPropertyComposer] = join_plural_field(song.composer)
nowplaying_info[MPMediaItemPropertyPlaybackDuration] = song.duration
if song.url is not None:
nowplaying_info[MPNowPlayingInfoPropertyAssetURL] = song.url.human_repr()
# MPD can't play back music at different rates, so we just want to set it
# to 1.0 if the song is playing. (Leave it at 0.0 if the song is paused.)
if song.state == PlaybackState.play: