Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.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 设置标题和图像,以便在后台播放音频_Ios_Iphone_Swift_Avplayer_Mpnowplayinginfocenter - Fatal编程技术网

Ios 设置标题和图像,以便在后台播放音频

Ios 设置标题和图像,以便在后台播放音频,ios,iphone,swift,avplayer,mpnowplayinginfocenter,Ios,Iphone,Swift,Avplayer,Mpnowplayinginfocenter,如何使用AVPlayer设置正在后台播放音频的标题和图像 到目前为止,我的代码是: let path: String = String(format: "pathtoaudio") let aPlayerItem: AVPlayerItem = AVPlayerItem(URL: NSURL(string: path)!) let anAudioStreamer: AVPlayer = AVPlayer(playerItem: aPlayerItem) player

如何使用
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()

我正在尝试使用
mpnowplayingfocenter
,但看不到锁屏上的信息。

您的标题和艺术家键看起来正确,但要设置相册插图,您需要使用对象:

您可能还需要明确订阅远程控制事件:

UIApplication.sharedApplication().beginReceivingRemoteControlEvents()

标题和艺术家键看起来正确,但要设置相册艺术品,需要使用对象:

您可能还需要明确订阅远程控制事件:

UIApplication.sharedApplication().beginReceivingRemoteControlEvents()

我这样做了,我也没有看到锁屏上的信息,请检查我的代码编辑上面好,尝试了这个,它根本不适合我。iOS(或我正在播放的AppleTV)用户界面上没有任何跟踪。但是,当我开始播放时,AppleTV屏幕上会出现一条临时消息,其中包含我正在播放的项目的URL。苹果关于这个主题的文档非常糟糕,根本不存在,这个答案只会增加新的痛苦…我做到了,而且我没有看到锁屏上的信息,请检查我的代码编辑,尝试了这个,它根本不适合我。iOS(或我正在播放的AppleTV)用户界面上没有任何跟踪。但是,当我开始播放时,AppleTV屏幕上会出现一条临时消息,其中包含我正在播放的项目的URL。苹果关于这个问题的文档是可怕的,根本不存在,而这个答案只是增加了新的痛苦。。。