AVPlayer making extraneous http request prior to playback of HLS / AES-encrypted video

拈花ヽ惹草 提交于 2019-12-05 16:12:48

The simple answer to this issue is that the AVAssetResourceLoaderDelegate will only handle requests for URLs which cannot be processed in the normal way.

In your case, the URL for your key is a normal https:// URL, so the AVPlayer will try to process this request itself. Without the token though, this request is rejected by your server. Therefore, the AVAssetResourceLoaderDelegate will then pass the request to your delegate to handle it.

To avoid the 'extraneous' request, modify your playlist so that the encryption key URL has an invalid scheme. Use something like crypt://... instead of https://....

That way, you will receive the resource loader call on the first try, and you can replace the crypt:// scheme with https:// and add your token before making the request yourself in the normal way.

It's just how AVAssetResourceLoaderDelegate works, I'm afraid. Check out Apple's sample app here for more details: https://developer.apple.com/library/ios/samplecode/sc1791/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!