Of course, the basics used only to support certain URL schemes, as an e-book developer, I saw how this happens for any type of media file downloaded via a URL, such as epub:// or zip:// . In these cases, in iOS 5.x and earlier versions, tracking through the corresponding code will end in the QuickTime method, which compares the URL scheme with a small number of supported ones: file , http , https , ftp and whatever iTunes uses. .. I forgot what he called.
IOS 6+ has a new API in AVFoundation, however, which is intended to help here. Although I have not used it personally, this is how it should work:
NSURL* url = [NSURL URLWithString:@"memory://video"]; AVURLAsset* asset = [[AVURLAsset alloc] initWithURL:url options:nil]; //////////////////////////////////////////////////////////////// // NEW CODE START AVAssetResourceLoader* loader = [asset resourceLoader]; id<AVAssetResourceLoaderDelegate> delegate = [SomeClass newInstanceWithNSURLProtocolClass: [VPMemoryURLProtocol class]]; [loader setDelegate: delegate queue: some_dispatch_queue]; // NEW CODE END //////////////////////////////////////////////////////////////// AVAssetImageGenerator* imageGen = [AVAssetImageGenerator assetImageGeneratorWithAsset:asset]; CMTime time = CMTimeMakeWithSeconds(0, 600);
In this case, you only need to implement the AVAssetResourceLoader protocol somewhere, which is very simple, since it contains only one method . Since you already have an implementation of NSURLProtocol , all of your real work is done, and you can simply transfer the real work to the Cocoa boot system or your protocol class directly.
Again, I will point out that I have not yet taken advantage of this, therefore the above is completely theoretical.
source share