iOS Developer Library

Developer

AVFoundation Framework Reference AVAssetResourceLoadingDataRequest Class Reference

Options
Deployment Target:

On This Page
Language:

AVAssetResourceLoadingDataRequest

Inheritance


  • NSObject
  • AVAssetResourceLoadingDataRequest
  • NSObject
  • AVAssetResourceLoadingDataRequest

Conforms To


Import Statement


Swift

import AVFoundation

Objective-C

@import AVFoundation;

Availability


Available in iOS 7.0 and later.

Use the AVAssetResourceLoadingDataRequest class to request data from a resource referenced by an AVAssetResourceLoadingRequest instance.

The AVAssetResourceLoaderDelegate uses the AVAssetResourceLoadingDataRequest class to do the actual data reading, and its methods will be invoked, as necessary, to acquire data for the AVAssetResourceLoadingRequest instance.

When the resource loading delegate, which implements the AVAssetResourceLoaderDelegate protocol, receives an instance of AVAssetResourceLoadingRequest as the second parameter of the delegate’s resourceLoader:shouldWaitForLoadingOfRequestedResource: method, it has the option of accepting responsibility for loading the referenced resource. If it accepts that responsibility, by returning YEStrue, it must check whether the dataRequest property of the AVAssetResourceLoadingRequest instance is not nil. If it is not nil, the resource loading delegate is informed of the range of bytes within the resource that are required by the underlying media system. In response, the data is provided by one or more invocations of respondWithData: as required to provide the requested data. The data can be provided in increments determined by the resource loading delegate according to convenience or efficiency.

When the AVAssetResourceLoadingRequest method finishLoading is invoked, the data request is considered fully satisfied. If the entire range of bytes requested has not yet been provided, the underlying media system assumes that the resource's length is limited to the provided content.

  • Provides data to the loading request.

    Declaration

    Swift

    func respondWithData(_ data: NSData!)

    Objective-C

    - (void)respondWithData:(NSData *)data

    Parameters

    data

    An instance of NSData containing some or all of the requested bytes.

    Discussion

    This method may be invoked multiple times on the same instance of AVAssetResourceLoadingDataRequest to provide the full range of requested data incrementally. Upon each invocation, the value of the currentOffset property is updated to match the amount of data provided.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

    See Also

    currentOffset

  • The length, in bytes, of the data requested. (read-only)

    Declaration

    Swift

    var requestedLength: Int { get }

    Objective-C

    @property(nonatomic, readonly) NSInteger requestedLength

    Discussion

    If the content length of the resource is unknown, the sum of the requestedLength and requestedOffset properties may be greater than the actual content length. When this situation occurs, an application must attempt to provide as much of the requested data beginning at the requestedOffset property as the resource contains. The application must then invoke either the AVAssetResourceLoadingRequest instance’s finishLoading method upon success, or the finishLoadingWithError: method if an error is encountered during the loading.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

    See Also

    requestedLength

  • The position within the resource of the first byte requested. (read-only)

    Declaration

    Swift

    var requestedOffset: Int64 { get }

    Objective-C

    @property(nonatomic, readonly) long long requestedOffset

    Discussion

    When all of the requested bytes that can be provided have been loaded—including the possible contentInformationRequest data in the AVAssetResourceLoadingRequest instance that contains the receiver—the delegate should respond by invoking finishLoading.

    If the requestedOffset value is beyond the content length of the resource, the AVAssetResourceLoadingRequest instance is sent a finishLoading message without any prior invocations of respondWithData:.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

    See Also

    requestedOffset

  • The position within the resource of the next byte. (read-only)

    Declaration

    Swift

    var currentOffset: Int64 { get }

    Objective-C

    @property(nonatomic, readonly) long long currentOffset

    Discussion

    When incrementally loading data you should begin loading at this offset, returning the data by invoking the respondWithData: method. Bytes previous to this value have already been provided.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.