Fix crash when video thumbnail cannot be loaded (fixes #28)

This commit is contained in:
Arkadiusz Fal 2021-12-05 18:15:40 +01:00
parent 1f495562fc
commit 82ea8733ec

View File

@ -481,10 +481,9 @@ final class PlayerModel: ObservableObject {
fileprivate func updateNowPlayingInfo() {
let duration: Int? = currentItem.video.live ? nil : Int(currentItem.videoDuration ?? 0)
let nowPlayingInfo: [String: AnyObject] = [
var nowPlayingInfo: [String: AnyObject] = [
MPMediaItemPropertyTitle: currentItem.video.title as AnyObject,
MPMediaItemPropertyArtist: currentItem.video.author as AnyObject,
MPMediaItemPropertyArtwork: currentArtwork as AnyObject,
MPMediaItemPropertyPlaybackDuration: duration as AnyObject,
MPNowPlayingInfoPropertyIsLiveStream: currentItem.video.live as AnyObject,
MPNowPlayingInfoPropertyElapsedPlaybackTime: player.currentTime().seconds as AnyObject,
@ -492,6 +491,10 @@ final class PlayerModel: ObservableObject {
MPMediaItemPropertyMediaType: MPMediaType.anyVideo.rawValue as AnyObject
]
if !currentArtwork.isNil {
nowPlayingInfo[MPMediaItemPropertyArtwork] = currentArtwork as AnyObject
}
MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo
}