ios - 警告 : Unexpected type for now playing key kMRMediaRemoteNowPlayingInfoDuration

标签 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
}

最佳答案

我遇到了同样的问题并解决了它找到以下解决方案:你忘记提及“.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

关于ios - 警告 : Unexpected type for now playing key kMRMediaRemoteNowPlayingInfoDuration,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64307378/

相关文章:

swift - 我如何使用 onDisappear 修饰符来了解 SwiftUI 中被杀死的 View ?

ios - 打开ios拨号面板

swift - 使用 UISlider 更新 UILabel 为 Sender 调用抛出 "unresolved identifier"错误

ios iAd 在显示前加载

ios - Swift 类添加 "@objc"为什么

objective-c - UIKeyboardTypeNumberPad 关闭键盘

xcode - AVFoundation 框架中不存在 AVAudioSession

ios - Alamofire/AlamofireObjectMapper - 如何从 responseObject 打印错误 json?

ios - 需要有关管理 ios 资源的帮助

c# - 如何将分隔符添加到 UITabbar ios