With DVAssetLoaderDelegate you can implement caching data downloaded by AVPlayer for AVURLAsset. DVAssetLoaderDelegate provides you delegate method you can use to save downloaded data:
- (void)dvAssetLoaderDelegate:(DVAssetLoaderDelegate *)resourceLoader didLoadData:(NSData *)data forURL:(NSURL *)url;
For other methods check DVAssetLoaderDelegatesDelegate.h.
DVAssetLoaderDelegateobject using URL for AVURLAsset.
DVAssetLoaderDelegatedelegate for receiving cache data.
AVURLAsset, change URL scheme to
AVURLAssetwith URL with updated scheme.
AVURLAsset's resource loader delegate to created
NSURL *URL = ...; DVAssetLoaderDelegate *resourceLoaderDelegate = [[DVAssetLoaderDelegate alloc] initWithURL:URL]; resourceLoaderDelegate.delegate = self; NSURLComponents *components = [[NSURLComponents alloc] initWithURL:URL resolvingAgainstBaseURL:NO]; components.scheme = [DVAssetLoaderDelegate scheme]; AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:[components URL] options:options]; [asset.resourceLoader setDelegate:resourceLoaderDelegate queue:dispatch_get_main_queue()];
DVAssetLoaderDelegate is available through CocoaPods. To install it, simply add the following line to your Podfile:
DVAssetLoaderDelegate is available under the MIT license. See the LICENSE file for more info.