iOS Developer Library

Developer

AVFoundation Framework Reference AVAssetResourceLoaderDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

AVAssetResourceLoaderDelegate

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

Inheritance


Not Applicable

Import Statement


import AVFoundation @import AVFoundation;

Availability


Available in iOS 6.0 and later.
  • Asks the delegate if it wants to load the requested resource.

    Declaration

    Swift

    optional func resourceLoader(_ resourceLoader: AVAssetResourceLoader!, shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest!) -> Bool

    Objective-C

    - (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

    YEStrue if your delegate can load the resource specified by the loadingRequest parameter or NOfalse 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 YEStrue 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 NOfalse from this method, the resource loader treats the loading of the resource as having failed.

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 6.0 and later.

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

    Declaration

    Swift

    optional func resourceLoader(_ resourceLoader: AVAssetResourceLoader!, didCancelLoadingRequest loadingRequest: AVAssetResourceLoadingRequest!)

    Objective-C

    - (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.

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

  • Invoked when assistance is required of the application to renew a resource. (required)

    Declaration

    Swift

    optional func resourceLoader(_ resourceLoader: AVAssetResourceLoader!, shouldWaitForRenewalOfRequestedResource renewalRequest: AVAssetResourceRenewalRequest!) -> Bool

    Objective-C

    - (BOOL)resourceLoader:(AVAssetResourceLoader *)resourceLoader shouldWaitForRenewalOfRequestedResource:(AVAssetResourceRenewalRequest *)renewalRequest

    Parameters

    resourceLoader

    The resource loader.

    renewalRequest

    An instance of AVAssetResourceRenewalRequest that provides information about the requested resource.

    Return Value

    YEStrue if the delegate can renew the resource; otherwise NOfalse.

    Discussion

    Delegates receive this message when assistance is required to renew a resource previously loaded by resourceLoader:shouldWaitForLoadingOfRequestedResource:. For example, this method is invoked to for decryption keys that require renewal, as indicated in a response to a prior invocation of resourceLoader:shouldWaitForLoadingOfRequestedResource:.

    If the result is YEStrue, the resource loader expects invocation, either subsequently or immediately, of either the AVAssetResourceRenewalRequest method finishLoading or finishLoadingWithError:. If you intend to finish loading the resource after your handling of this message returns, you must retain the renewalRequest until after loading is finished.

    If the result is NOfalse, the resource loader treats the loading of the resource as having failed.

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 8.0 and later.

  • Informs the delegate that a prior authentication challenge has been cancelled. (required)

    Declaration

    Swift

    optional func resourceLoader(_ resourceLoader: AVAssetResourceLoader!, didCancelAuthenticationChallenge authenticationChallenge: NSURLAuthenticationChallenge!)

    Objective-C

    - (void)resourceLoader:(AVAssetResourceLoader *)resourceLoader didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)authenticationChallenge

    Parameters

    resourceLoader

    The resource loader.

    authenticationChallenge

    The authentication challenge that has been cancelled.

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 8.0 and later.

  • Invoked when assistance is required of the application to respond to an authentication challenge. (required)

    Declaration

    Swift

    optional func resourceLoader(_ resourceLoader: AVAssetResourceLoader!, shouldWaitForResponseToAuthenticationChallenge authenticationChallenge: NSURLAuthenticationChallenge!) -> Bool

    Objective-C

    - (BOOL)resourceLoader:(AVAssetResourceLoader *)resourceLoader shouldWaitForResponseToAuthenticationChallenge:(NSURLAuthenticationChallenge *)authenticationChallenge

    Parameters

    resourceLoader

    The resource loader.

    authenticationChallenge

    The authentication challenge.

    Return Value

    YEStrue if the resource loader should wait for a response to the authentication challenge; otherwise NOfalse.

    Discussion

    Delegates receive this message when assistance is required of the application to respond to an authentication challenge.

    Return YEStrue if you expect a response either subsequently or immediately to the authenticationChallenger object’s sender.

    If you intend to respond to the authentication challenge after your handling of resourceLoader:shouldWaitForResponseToAuthenticationChallenge: returns, you must retain the authenticationChallenge until after your response has been made.

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 8.0 and later.