yangchao0033 / HLS-Demo

IOS HLS视频直播样例
http://www.jianshu.com/p/8f99202ccb89
MIT License
288 stars 82 forks source link

请教个问题 #2

Closed redsun closed 8 years ago

redsun commented 8 years ago

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

yangchao0033 commented 8 years ago

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

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

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

redsun commented 8 years ago

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