Deleted protected content cannot be downloaded again in the same session

231 Views Asked by At

I'm working with HLS FairPlay but can't correctly delete a protected downloaded content and re-download it in the same session (= without first closing the app).

step 1: movpkg is deleted from FileManager its content key is deleted from the .keys folder

step 2: trying to re-download, without killing the app first, doesn't fire any delegate method from the ContentKeyDelegate flow.

Apparently, there's some sorta of caching after you do the first time:

processContentKeyRequest(withIdentifier: identifier, initializationData: nil, options: nil)

AVContentKeySession is initialized at app start.

calling processContentKeyRequest(withIdentifier: identifier, initializationData: nil, options: nil) the second time does nothing.

If I re-download after restarting the app(and after deleting the content) works fine. I also tried using invalidatePersistableContentKey with no luck.

1

There are 1 best solutions below

0
zuziaaax On

Please try creating new instance of the AVContentKeySession. I found this in Apple's HLS Catalog example:

/// Reset content key manager. May have to do this to re-download an already downloaded item. Does not reset any other keys.
func reset() {
    contentKeySession = AVContentKeySession(keySystem: .fairPlayStreaming)
    contentKeySession.setDelegate(contentKeyDelegate, queue: contentKeyDelegateQueue)
}