Fix progress updating issues

This commit is contained in:
ronaldheft 2022-08-25 18:28:17 -04:00
parent 268cf67576
commit 7cf36d829a
2 changed files with 29 additions and 23 deletions

View file

@ -59,12 +59,17 @@ class NowPlayingInfo {
}
}
public func update(duration: Double, currentTime: Double, rate: Float) {
nowPlayingInfo[MPMediaItemPropertyPlaybackDuration] = duration
nowPlayingInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = currentTime
nowPlayingInfo[MPNowPlayingInfoPropertyPlaybackRate] = rate
nowPlayingInfo[MPNowPlayingInfoPropertyDefaultPlaybackRate] = 1.0
MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo
// Update on the main to prevent access collisions
DispatchQueue.main.async { [weak self] in
if let self = self {
self.nowPlayingInfo[MPMediaItemPropertyPlaybackDuration] = duration
self.nowPlayingInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = currentTime
self.nowPlayingInfo[MPNowPlayingInfoPropertyPlaybackRate] = rate
self.nowPlayingInfo[MPNowPlayingInfoPropertyDefaultPlaybackRate] = 1.0
MPNowPlayingInfoCenter.default().nowPlayingInfo = self.nowPlayingInfo
}
}
}
public func reset() {