yangchao0033/HLS-Demo

请教个问题

Closed this issue · 2 comments

你好,请教个问题,关于m3u8加密这个,获取到加密key怎么传给播放器?楼主有没有研究过。

具体加密的官方说明是放在AVAssetResourceLoaderDelegate中的代理方法中分别是:

- (void)resourceLoader:(AVAssetResourceLoader *)resourceLoader didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)authenticationChallenge;
- (BOOL)resourceLoader:(AVAssetResourceLoader *)resourceLoader shouldWaitForResponseToAuthenticationChallenge:(NSURLAuthenticationChallenge *)authenticationChallenge

这两个方法实现的,具体官方实现的demo中有介绍,根据自己的情况做适当的修改。
并且在AVAssetResourceLoaderDelegate协议中定义了很多AVPlayer的网络状态相关的参数和方法,对于播放器的网络请求及响应以及用户的加密都很有用,这里可以做关于HTTPS的网络请求加密,以及流媒体片段的分段加密,具体要看后端的实现方式,比较灵活多变。

已经解决了,参照了官方AVAssetResourceLoaderDelegate的demo。