Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios MPMediaItemPropertyNetwork未显示在命令中心中_Ios_Swift_Swift3_Media Player_Ios10 - Fatal编程技术网

Ios MPMediaItemPropertyNetwork未显示在命令中心中

Ios MPMediaItemPropertyNetwork未显示在命令中心中,ios,swift,swift3,media-player,ios10,Ios,Swift,Swift3,Media Player,Ios10,我正在使用AVPlayer播放来自服务器的音乐流。我有一个艺术品图像,我想在指挥中心和锁屏上显示。我正在使用以下代码: let image = UIImage(named: "RadioBackground")! let artwork = MPMediaItemArtwork.init(boundsSize: image.size, requestHandler: { (size) -> UIImage in return image })

我正在使用
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