I'm currently trying to implement download of an encrypted HLS stream to an iOS device. iOS 10 seems to support that out of the box (see https://developer.apple.com/videos/play/wwdc2016/504), but I can't get it to work.
I am basically using the AssetPersistenceManager
from the Apple sample code (https://developer.apple.com/library/content/samplecode/HLSCatalog/Introduction/Intro.html), which calls makeAssetDownloadTask
of AVAssetDownloadURLSession
. It works fine in online mode, but the playback fails when playing the asset from the stored file.
Now the WWDC video indicates that you should use AVAssetResourceLoaderDelegate
to provide an offline encryption key. As http and https don't seem to be supported by the AVAssetResourceLoader
(see e.g. AVAssetResourceLoaderDelegate methods not working on device), I tried using a custom scheme for the key URI and provide a local aes key in shouldWaitForLoadingOfRequestedResource
of AVAssetResourceLoaderDelegate
. Here it also works when streaming online, but no matter whether I'm using the remote key URL or override it with a local key, AVPlayer always fails playing the AVAsset offline.
Does anyone have experience with downloading encrypted HLS or has a working example on how to provide an encryption key for playing a local encrypted AVURLAsset offline?
The sample HSL file I'm using is here:http://demo.unified-streaming.com/video/tears-of-steel/tears-of-steel-aes.ism/.m3u8