Hello,
I am using FairPlay streaming to stream encrypted HLS content to my app. Here is the code I use to playback content:
func load(url: URL) {
if let currentAsset = self.avPlayer.currentItem?.asset as? AVURLAsset {
self.contentKeySessionManager?.removeContentKeyRecipient(recipient: currentAsset)
}
self.urlAssetObserver?.invalidate()
let urlAsset = AVURLAsset(url: url)
self.contentKeySessionManager?.addContentKeyRecipient(recipient: urlAsset)
let playerItem = AVPlayerItem(asset: urlAsset)
self.urlAssetObserver = urlAsset.observe(\AVURLAsset.isPlayable, options: [.new, .initial]) { [weak self] (urlAsset, _) in
guard let strongSelf = self, urlAsset.isPlayable == true else { return }
strongSelf.avPlayer.replaceCurrentItem(with: playerItem)
if(playerItem.status == .readyToPlay) {
strongSelf.internalState = .Paused
}
}
}
I am using AVContentKeySession to handle getting the ckc. However, my crash reporting sends me the following crash report:
Fatal Exception: NSInternalInconsistencyException
AVAsset failed to associate with AVContentKeySession
This happens out in the wild. It crashes on line 8 above.
self.contentKeySessionManager?.addContentKeyRecipient(recipient: urlAsset)
I can't find any documentation on this crash. Does anyone know what would cause it?
Thanks