MPNowPlayingInfoCenter & Avplayercontroller displaying wrong information on lock screen

I'm facing a problem concerning the information displayed in the info center of the device lock screens when playing a video files with avplayercontroller.

I have followed the guidelines on how to implement the MPNowPlayingInfoCenter and update it's content but it seems that avplayercontroller override all the information that I want to display.

I always end up with a lock screen infos center displaying the logo of my application, the name of the device, the name of my app, a play/pause button & time slider.

I have tried to disable the update of the info center by the avplayercontroller. While doing that it seems that the info center is disabled completely and just doesn't appear anymore.

This is how I set the infos center information:

func setNowPlayingInfo() { 
var nowPlayingInfo = [String: Any]()  
// prepare title and subtitle 
nowPlayingInfo[MPMediaItemPropertyTitle] = "Movie Title" 
nowPlayingInfo[MPMediaItemPropertyArtist] = "Actor Name"  
// asynchronously download movie art image. 
// here, for simplicity, an image from asset catalog is loaded 
if let movieArt = UIImage(named: "cover-art") { 
     nowPlayingInfo[MPMediaItemPropertyArtwork] = MPMediaItemArtwork(boundsSize: movieArt.size, requestHandler: {
           imageSize in return movieArt }) 
     } 
nowPlayingInfo[MPNowPlayingInfoPropertyIsLiveStream] = true 
nowPlayingInfo[MPMediaItemPropertyPlaybackDuration] = playerItems[0].asset.duration.seconds 
nowPlayingInfo[MPNowPlayingInfoPropertyPlaybackRate] = player.rate 
nowPlayingInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = playerItems[0].currentTime().seconds 
MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo 
}

and this is what I tried to stop the overriding of the information by avplayercontroller:

avplayerViewController.updatesNowPlayingInfoCenter = false

I can't seem to find a way to either change the information that avplayercontroller sets in the lock screen infos center or how to display the info center all together if it's update if set to false on the avplayercontroller.

I'm open to any suggestion. I really don't understand why the info center doesn't appear if I forbid it's update from avplayercontroller.

Thank you in advance for any tips you could give me to fix this.

Replies

Hi,

Am also facing the same issue while playing audio in iOS 12.3. But it is working fine in iOS 12.1.