如何使用 设置正在后台播放音频的标题和图像AVPlayer
?
到目前为止我的代码:
let path: String = String(format: "pathtoaudio")
let aPlayerItem: AVPlayerItem = AVPlayerItem(URL: NSURL(string: path)!)
let anAudioStreamer: AVPlayer = AVPlayer(playerItem: aPlayerItem)
player = anAudioStreamer
let playerController = AVPlayerViewController()
playerController.player = player
self.addChildViewController(playerController)
self.view.addSubview(playerController.view)
playerController.view.frame = self.view.frame
player.addObserver(self, forKeyPath: "status", options: NSKeyValueObservingOptions.New, context: nil)
let nowPlayingInfo = [MPMediaItemPropertyArtist : "Artist!", MPMediaItemPropertyTitle : "Title!", MPMediaItemPropertyArtwork : MPMediaItemArtwork(image: UIImage(named: "nour.jpg")!)]
MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo = nowPlayingInfo
UIApplication.sharedApplication().beginReceivingRemoteControlEvents()
我正在尝试使用MPNowPlayingInfoCenter
,但在锁定屏幕上看不到信息。