【问题标题】:MPMediaItemPropertyArtwork is not displayed in command centerMPMediaItemPropertyArtwork 未显示在命令中心
【发布时间】:2017-04-26 21:45:48
【问题描述】:

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

问题是艺术品只显示在锁定屏幕上,而不是在命令中心上。

我错过了什么吗?

【问题讨论】:

    标签: ios swift swift3 media-player ios10


    【解决方案1】:

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

    MPMediaItemPropertyTitle

    【讨论】:

    • 设置 MPMediaItemPropertyTitle 没有帮助。我已经设置好了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-27
    • 2021-01-21
    • 1970-01-01
    • 2020-10-27
    • 1970-01-01
    • 2013-01-20
    相关资源
    最近更新 更多