It was vaguely suggested in https://developer.apple.com/videos/play/wwdc2012-512/ that NSURLProtocol had been used to cache .ts files. However, I haven't found a way yet. On the simulator, things work OK. However, on my iPhone 5S on 9.0, requests for any files will only go through my NSURLProtocol class if they start with an unrecognized URL, like "asdf". So I get my AVPlayerItem to load "asdf://..." for the master and rendition playlist files, and this gets intercepted fine. However, when I try to load a .ts file like this, where it starts off as "asdf://...", after successfully loading the file, I get an AVFoundation error saying "custo m url not redirect". Any ideas how I can use NSURLProtocol to cache files?
For those who don't like the general idea of doing this: I am certainly aware of how HLS is designed to function, and I understand why Apple chose not to include control over .ts file loading in the AVAssetResourceLoaderDelegate class. However, what I'm trying to do is pre-load .ts file chunks in the background while the user before the user gets to the part where they watch videos. One solution would be to kick off the loading, and then wait until it said that it was ready to play. However, this generally requires it to load 3 .ts files, which is more data than I want to load. I also want to prioritize .ts file loading with respect to other loading tasks, so that this pre-loading won't degrade other parts of the app when they need to use the network. Any ideas that would solve this problem without use of NSURLProtocol, such as injecting a .ts file into the file cache that AVFoundation uses, would also be greatly appreciated!