Lock Screen Artwork AVPlayerViewController flickers

I am using AVMetadataItem to show artwork on the lockscreen (.commonIdentifierArtwork) of an app playing video using AVPlayerViewController with some custom UI.

When I switch to AirPlay everything works as expected, except that the artwork sometimes "flickers" when I play/pause the playback. It flickers back and forth for a split second showing the app's icon and the Artwork specified in AVMetadataItem.

Code Block
...
// metadata.artwork is UIImage?
if let artwork = metadata.artwork, let jpgData = artwork.jpegData(compressionQuality: 1.0) {
let artWorkMetadataItem = makeMetadataItem(.commonIdentifierArtwork, value: jpgData as NSData)
metadataItems.append(artWorkMetadataItem)
}
...
avPlayer.currentItem?.externalMetadata = metadataItems
...
private func makeMetadataItem(_ identifier: AVMetadataIdentifier, value: Any) -> AVMetadataItem {
let item = AVMutableMetadataItem()
item.identifier = identifier
item.value = value as? NSCopying & NSObjectProtocol
item.extendedLanguageTag = "und"
return item.copy() as! AVMetadataItem
}




Any idea what can be causing this issue?
If it is the lock screen showing your artwork, and not code you control, I would file a bug report via feedback assistant.

Same issue. My recent testing confirmed your issue and found a work around as below. I also wonder if Apple has recently dropped the default "Artist" display from the Lock Screen when using "AVPlayer.currentItem?.externalMetadata" method or it's an outstanding bug fix at Apple ? Anyone know ?

  1. using the traditional "MPNowPlayingInfoCenter.default().nowPlayingInfo" + "MPRemoteCommandCenter" + "AVPlayerViewController .updatesNowPlayingInfoCenter = false".

Result "Artist" is displayed correctly in the iOS Lock Screen. Agreed - more code required.

  1. using "AVPlayer.currentItem?.externalMetadata" + "AVPlayerViewController .updatesNowPlayingInfoCenter = true (ie: default)".

Result: "Artist" is not displayed in the iOS Lock Screen.

Thanks, Jeff

Lock Screen Artwork AVPlayerViewController flickers
 
 
Q