ContentKeyDelegate functions not being called in iOS 17

Hello,

I'm having an issue where my app is in TestFlight, and some of my testers are reporting that FairPlay protected videos are not playing back in iOS 17.

It's been working fine in iOS 16 (my app's initial target).

I can see from the debug logs that for an online stream request -

contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVContentKeyRequest)

is never called.

Whereas, a download for offline playback request, the function is called.

I've used much of the sample code in "HLS Catalog With FPS" as part of the FPS developer package.

All of my m3u8 files are version 5 and contain encryption instructions like below:

#EXT-X-KEY:METHOD=SAMPLE-AES,URI="skd://some-uuid",KEYFORMAT="com.apple.streamingkeydelivery",KEYFORMATVERSIONS="1"

Here's a short excerpt of the code being run:

    let values = HTTPCookie.requestHeaderFields(with: cookies)
    let cookieOptions = ["AVURLAssetHTTPHeaderFieldsKey": values]
    assetUrl = "del\(assetUrl)"
    clip!.assetUrl = AVURLAsset(url: URL(string: assetUrl)!, options: cookieOptions)
    clip!.assetUrl!.resourceLoader.setDelegate(self, queue: DispatchQueue.global(qos: .default))
                    ContentKeyManager.shared.contentKeySession.addContentKeyRecipient(clip!.assetUrl!)

    urlAssetObserver = self.observe(\.isPlayable, options: [.new, .initial]) { [weak self] (assetUrl, _) in
      guard let strongSelf = self else { return }
      strongSelf.playerItem = AVPlayerItem(asset: (self!.clip!.assetUrl)!)
      strongSelf.player.replaceCurrentItem(with: strongSelf.playerItem)
    }

The error thrown is:

Task <A1F3C6EE-2BEF-4223-A09B-1C49327DAB26>.<8> finished with error [18,446,744,073,709,550,614] Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo={NSLocalizedDescription=unsupported URL, NSErrorFailingURLStringKey=skd://some-uuid, NSErrorFailingURLKey=skd://some-uuid, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <A1F3C6EE-2BEF-4223-A09B-1C49327DAB26>.<8>" ), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <A1F3C6EE-2BEF-4223-A09B-1C49327DAB26>.<8>, NSUnderlyingError=0x2839a7450 {Error Domain=kCFErrorDomainCFNetwork Code=-1002 "(null)"}}

Which I believe is being thrown from AVPlayerItem.

Without the delegate, it appears to playback fine. However, I need the delegate (I think), since I'm appending some query params to each request for the segments.

I have an observer on the playerItem, per the example project which is changing the status to .failed once he -1002 error is thrown.

Please let me know if anything rings to mind to try, or if I can provide any additional info.

Thanks in advance!

Accepted Reply

Turns out I have to explicitely run processContentKeyRequest in the delegate; didn't need to in iOS 16.

Replies

Turns out I have to explicitely run processContentKeyRequest in the delegate; didn't need to in iOS 16.