AVAssetResourceLoaderDelegate Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/AVFoundation.framework
Availability
Available in iOS 6.0 and later.
Declared in
AVAssetResourceLoader.h

Overview

The AVAssetResourceLoaderDelegate protocol defines a method that lets your code handle resource loading requests coming from an AVURLAsset object.

A class should adopt this protocol when associated with the asset’s resource loader—that is, an instance of the AVAssetResourceLoader class. The resource loader works with your delegate to process the request.

Tasks

Processing Resource Requests

Instance Methods

resourceLoader:didCancelLoadingRequest:

Invoked to inform the delegate that a prior loading request has been cancelled

- (void)resourceLoader:(AVAssetResourceLoader *)resourceLoader didCancelLoadingRequest:(AVAssetResourceLoadingRequest *)loadingRequest
Parameters
resourceLoader

The resource loader.

loadingRequest

The loading request that has been cancelled.

Discussion

Previously issued loading requests can be cancelled when data from the resource is no longer required or when a loading request is superseded by new requests for data from the same resource.

For example, if to complete a seek operation it becomes necessary to load a range of bytes that's different from a range previously requested, the prior request may be cancelled while the delegate is still handling it.

Availability
  • Available in iOS 7.0 and later.
Declared In
AVAssetResourceLoader.h

resourceLoader:shouldWaitForLoadingOfRequestedResource:

Asks the delegate if it wants to load the requested resource.

- (BOOL)resourceLoader:(AVAssetResourceLoader *)resourceLoader shouldWaitForLoadingOfRequestedResource:(AVAssetResourceLoadingRequest *)loadingRequest
Parameters
resourceLoader

The resource loader object that is making the request.

loadingRequest

The loading request object that contains information about the requested resource.

Return Value

YES if your delegate can load the resource specified by the loadingRequest parameter or NO if it cannot.

Discussion

The resource loader object calls this method when assistance is required of your code to load the specified resource. For example, the resource loader might call this method to load decryption keys that have been specified using a custom URL scheme.

Returning YES from this method, implies only that the receiver will load, or at least attempt to load, the resource. In some implementations, the actual work of loading the resource might be initiated on another thread, running asynchronously to the resource loading delegate; whether the work begins immediately or merely soon is an implementation detail of the client application.

You can load the resource synchronously or asynchronously. In both cases, you must indicate success or failure of the operation by calling the finishLoadingWithResponse:data:redirect: or finishLoadingWithError: method of the request object when you finish. If you load the resource asynchronously, you must also store a strong reference to the object in the loadingRequest parameter before returning from this method.

If you return NO from this method, the resource loader treats the loading of the resource as having failed.

Availability
  • Available in iOS 6.0 and later.
Declared In
AVAssetResourceLoader.h