APAudioPlayer
APAudioPlayer copied to clipboard
MPNowPlayingInfoCenter can not update duration, current time
When I play a file use AVAudioPlayer
, I can show info to control center with MPNowPlayingInfoCenter
. But when use APAudioPlayer
, it can't update current time, duration to control center.
let currentPlayingInfo = [
AVMetadataCommonKeyTitle: "Song title",
MPMediaItemPropertyPlaybackDuration: 300,
MPNowPlayingInfoPropertyElapsedPlaybackTime: TimeInterval(player.position) * player.duration()
]
MPNowPlayingInfoCenter.default().nowPlayingInfo = currentPlayingInfo