小编set*_*twi的帖子

在分配到nowPlayingInfo后,MPNowPlayingInfoCenter不会更新任何信息

我正在使用Swift 3创建一个iOS应用程序,其中显示有关锁定屏幕和控制中心当前正在播放的项目的信息将是不错的.

目前,我正在使用以下代码尝试将此信息插入到nowPlayingInfo字典中.我还包括对使用的VideoInfo类的引用videoBeganPlaying(_:).

class VideoInfo {
    var channelName: String
    var title: String
}

// ...

var videoInfoNowPlaying: VideoInfo?

// ...

@objc private func videoBeganPlaying(_ notification: NSNotification?) {
    // apparently these have to be here in order for this to work... but it doesn't
    UIApplication.shared.beginReceivingRemoteControlEvents()
    self.becomeFirstResponder()
    guard let info = self.videoInfoNowPlaying else { return }
    let artwork = MPMediaItemArtwork(boundsSize: .zero, requestHandler:
        { (_) -> UIImage in #imageLiteral(resourceName: "DefaultThumbnail") }) // this is filler
    MPNowPlayingInfoCenter.default().nowPlayingInfo = …
Run Code Online (Sandbox Code Playgroud)

ios mpnowplayinginfocenter swift swift3

6
推荐指数
2
解决办法
4911
查看次数

标签 统计

ios ×1

mpnowplayinginfocenter ×1

swift ×1

swift3 ×1