使用AVPlayer播放加密视频 [英] Play encrypted video with AVPlayer

查看:363
本文介绍了使用AVPlayer播放加密视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实施包含视频播放器的应用程序。由于某些原因,视频文件使用AES加密,并且这些文件的大小可能相当大,以避免将其加载到RAM作为一个部分。我正在寻找某种方式与AVPlayer一起玩。

I'm implementing an application that contains video player. For some reasons video files are encrypted with AES, and size of these files can be rather big to avoid loading it to RAM as one piece. I'm looking for some way to play it with AVPlayer.

尝试:

1)自定义NSURLProtocol as这里建议 http://aptogo.co.uk/2010/07/protecting-resources/
没有工作,我建议AVPlayer使用它自己的,我的不会被调用。

1) Custom NSURLProtocol as suggested here http://aptogo.co.uk/2010/07/protecting-resources/ Didn't work, I suggest that AVPlayer uses it's own and mine does not get called.

2)使用AVAsset将视频插入然后将它们提供给AVPlayer,因为AVPlayer中没有API。

2) Use AVAsset to chop video in small chunks and then feed them to AVPlayer - failed because there's no API in AVPlayer for that.

任何解决方法将不胜感激:)

Any workaround would be greatly appreciated :)

推荐答案

您有两个选择:


  1. 7和更新的检查AVAssetResourceLoaderDelegate。它允许您使用自定义的NSURLProtocol,但专门为AVPlayer。

  1. If targeting iOS 7 and newer the check out AVAssetResourceLoaderDelegate. It allows you to do what you would with a custom NSURLProtocol but specifically for AVPlayer.

模拟HTTP服务器,支持Range标题,并将AVURLAsset指向

Emulate an HTTP server with support for the Range header and point the AVURLAsset to localhost.

我之前实施了#2,如果需要,可以提供更多信息。

I implemented #2 before and can provide more info if needed.

这篇关于使用AVPlayer播放加密视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆