警告:正在播放键kMRMediaRemoteNowPlayingInfoDuration的意外类型

时间:2020-10-11 18:03:48

标签: ios swift

我在控制台中看到以下错误。

WARNING: Unexpected type for now playing key kMRMediaRemoteNowPlayingInfoDuration (is CFType, should be CFNumber). Removing from now playing info dictionary.

有人知道我在做什么错吗?

if let duration = player.currentItem?.asset.duration {
   nowPlayingInfo[MPMediaItemPropertyPlaybackDuration] = duration
}

1 个答案:

答案 0 :(得分:1)

我也遇到了相同的问题,并已解决它。找到以下解决方案:您忘记提及“ .seconds”

if let currentItem = player.currentItem {
     let duration = currentItem.asset.duration
      nowPlayingInfo[MPMediaItemPropertyPlaybackDuration] = duration.seconds


}

参考:https://developer.apple.com/documentation/avfoundation/media_playback_and_selection/creating_a_basic_video_player_ios_and_tvos/controlling_background_audio

相关问题