MPMediaItemPropertyArtwork 未显示在命令中心

MPMediaItemPropertyArtwork is not displayed in command center

我正在使用 AVPlayer 从服务器播放音乐流。我有一个艺术品图像,我想在命令中心和锁定屏幕上显示。我正在使用以下代码:

    let image = UIImage(named: "RadioBackground")!
    let artwork = MPMediaItemArtwork.init(boundsSize: image.size, requestHandler: { (size) -> UIImage in
        return image
    })

    var playingInfo:[String: Any] = [:]

    playingInfo[MPMediaItemPropertyArtwork] = artwork
    playingInfo[MPNowPlayingInfoPropertyPlaybackRate] = NSNumber(value: 1.0)

    MPNowPlayingInfoCenter.default().nowPlayingInfo = playingInfo

    UIApplication.shared.beginReceivingRemoteControlEvents()
    let CommandCenter = MPRemoteCommandCenter.shared()
    CommandCenter.playCommand.isEnabled = true
    CommandCenter.playCommand.addTarget(self, action:#selector(PlayPauseRadio))

    CommandCenter.pauseCommand.isEnabled = true
    CommandCenter.pauseCommand.addTarget(self, action:#selector(PlayPauseRadio))

问题是作品只显示在锁屏界面,不显示在命令中心

我是不是漏掉了什么?

好的,我知道了!最后 !您只需要为您的 NowPlayingInfo 设置一些 属性。这是属性:

MPMediaItemPropertyTitle