Root Problem
Our video buffers a lot when seeking in iOS. It buffers quite a bit more than our web player which saves copies of the already watched segments in temp storage.
Desired Solution
Caching the video segments locally on the device's disk. We're fine with caching a single quality and always replaying it.
Blocker
We can't find a way to perform caching within AVFoundation/AVPlayer.
What We've Tried
2 ways to intercept networking requests with AVPlayer.
- Conforming to AVAssetResourceLoaderDelegate and handling the loading of the media manually
Doesn't work with HLS. You can load the m3u8 files by implementing AVAssetResourceLoaderDelegate, which allows you to pass authentication or to decrypt the response, however the .ts files can't be loaded. Here's the code we tried: https://gist.github.com/nathanhillyer/84e46152d7c4c88183b6
- Implementing a NSURLProtocol to capture requests for
.ts
files.
AVURLAsset actually avoids being intercepted. Somehow the network requests just don't get captured. (No clue why)
Aucun commentaire:
Enregistrer un commentaire