AVURLAsset Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AVFoundation.framework
Availability
Available in iOS 4.0 and later.
Declared in
AVAsset.h
Related sample code

Overview

AVURLAsset is a concrete subclass of AVAsset that you use to initialize an asset from an URL.

Tasks

Creating an URL Asset

Accessing the URL

Accessing the Resource Loader

Finding Compatible Tracks

Getting Supported Media Types

Properties

resourceLoader

The resource loader associated with the asset. (read-only)

@property(nonatomic, readonly) AVAssetResourceLoader *resourceLoader
Discussion

During loading, the resource loader object may be asked to assist in the loading of a resource. For example, a resource that requires decryption might result in the resource loader being asked to provide the appropriate decryption keys. You can assign a delegate object to the resource loader object and use your delegate to intercept these requests and provide an appropriate response.

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

URL

The URL with which the asset was initialized. (read-only)

@property(nonatomic, readonly, copy) NSURL *URL
Availability
  • Available in iOS 4.0 and later.
Declared In
AVAsset.h

Class Methods

audiovisualMIMETypes

Returns an array of the MIME types the AVURLAsset class understands.

+ (NSArray *)audiovisualMIMETypes
Return Value

An array of strings containing MIME types the AVURLAsset class understands.

Availability
  • Available in iOS 5.0 and later.
Declared In
AVAsset.h

audiovisualTypes

Returns an array of the file types the AVURLAsset class understands.

+ (NSArray *)audiovisualTypes
Return Value

An array of strings containing UTIs identifying the file types the AVURLAsset class understands.

Availability
  • Available in iOS 5.0 and later.
Declared In
AVAsset.h

isPlayableExtendedMIMEType:

Returns a Boolean value that indicates whether the asset is playable with the given codec(s) and container type.

+ (Boolean)isPlayableExtendedMIMEType:(NSString *)extendedMIMEType
Parameters
extendedMIMEType

An extended MIME type.

Return Value

YES if the asset is playable with the codec(s) and container type specified in extendedMIMEType, otherwise NO.

Availability
  • Available in iOS 5.0 and later.
Declared In
AVAsset.h

URLAssetWithURL:options:

Returns an asset for inspection of a resource referenced by a given URL.

+ (AVURLAsset *)URLAssetWithURL:(NSURL *)URL options:(NSDictionary *)options
Parameters
URL

An URL that references the container file to be represented by the asset.

options

A dictionary that contains options for the initialization of the asset.

For possible keys and values, see “Initialization Options.”

Return Value

An asset initialized for inspection of a resource referenced by URL.

Availability
  • Available in iOS 4.0 and later.
Declared In
AVAsset.h

Instance Methods

compatibleTrackForCompositionTrack:

Returns an asset track from which any time range can be inserted into a given composition track.

- (AVAssetTrack *)compatibleTrackForCompositionTrack:(AVCompositionTrack *)compositionTrack
Parameters
compositionTrack

The composition track for which a compatible AVAssetTrack object is requested.

Return Value

An asset track managed by the receiver from which any time range can be inserted into a given composition track.

Discussion

You insert the track into using insertTimeRange:ofTrack:atTime:error: (AVMutableCompositionTrack). This method is the logical complement of mutableTrackCompatibleWithTrack:.

Availability
  • Available in iOS 4.0 and later.
Declared In
AVAsset.h

initWithURL:options:

Initializes an asset for inspection of a resource referenced by a given URL.

- (id)initWithURL:(NSURL *)URL options:(NSDictionary *)options
Parameters
URL

An URL that references the container file to be represented by the asset.

options

A dictionary that contains options for the initialization of the asset.

For possible keys and values, see “Initialization Options.”

Return Value

An asset initialized for inspection of a resource referenced by URL.

Availability
  • Available in iOS 4.0 and later.
Declared In
AVAsset.h

Constants

Initialization Options

Keys for options dictionary for use with initWithURL:options: and URLAssetWithURL:options:.

NSString *const AVURLAssetPreferPreciseDurationAndTimingKey;
NSString *const AVURLAssetReferenceRestrictionsKey;
Constants
AVURLAssetPreferPreciseDurationAndTimingKey

The corresponding value is a boolean, contained in an NSValue object, that indicates whether the asset should be prepared to indicate a precise duration and provide precise random access by time.

YES indicates that longer loading times are acceptable in cases in which precise timing is required. Such precision, however, may require additional parsing of the resource in advance of operations that make use of any portion of it, depending on the specifics of its container format.

Many container formats provide sufficient summary information for precise timing and do not require additional parsing to prepare for it; QuickTime movie files and MPEG-4 files are examples of such formats. Other formats do not provide sufficient summary information, and precise random access for them is possible only after a preliminary examination of a file's contents.

If you only intend that the asset be played, the default value of NO will suffice (because AVPlayer supports approximate random access by time when full precision isn't available). If you intend to insert the asset into an AVMutableComposition object, precise random access is typically desirable, and the value of YES is recommended.

Available in iOS 4.0 and later.

Declared in AVAsset.h.

AVURLAssetReferenceRestrictionsKey

The corresponding value is a an NSNumber wrapping an “AVAssetReferenceRestrictions” enum value or the logical combination of multiple such values indicating the restrictions used by the asset when resolving references to external media data.

Some assets can contain references to media data stored outside the asset’s container file, for example in another file. You can use this key to specify a policy to use when these references are encountered. If an asset contains one or more references of a type that is forbidden by the reference restrictions, loading of asset properties will fail. In addition, such an asset cannot be used with other AVFoundation objects, such as AVPlayerItem or AVAssetExportSession.

Available in iOS 5.0 and later.

Declared in AVAsset.h.

AVAssetReferenceRestrictions

These constants can be passed in to AVURLAssetReferenceRestrictionsKey to control the resolution of references to external media data.

enum {
   AVAssetReferenceRestrictionForbidNone = 0UL,
   AVAssetReferenceRestrictionForbidRemoteReferenceToLocal = (1UL << 0),
   AVAssetReferenceRestrictionForbidLocalReferenceToRemote = (1UL << 1),
   AVAssetReferenceRestrictionForbidCrossSiteReference = (1UL << 2),
   AVAssetReferenceRestrictionForbidLocalReferenceToLocal = (1UL << 3),
   AVAssetReferenceRestrictionForbidAll = 0xFFFFUL,
};
typedef NSUInteger AVAssetReferenceRestrictions;
Constants
AVAssetReferenceRestrictionForbidNone

Indicates that all types of references should be followed.

Available in iOS 5.0 and later.

Declared in AVAsset.h.

AVAssetReferenceRestrictionForbidRemoteReferenceToLocal

Indicates that references from a remote asset (for example, referenced via http URL) to local media data (for example, stored in a local file) should not be followed.

Available in iOS 5.0 and later.

Declared in AVAsset.h.

AVAssetReferenceRestrictionForbidLocalReferenceToRemote

Indicates that references from a local asset to remote media data should not be followed.

Available in iOS 5.0 and later.

Declared in AVAsset.h.

AVAssetReferenceRestrictionForbidCrossSiteReference

Indicates that references from a remote asset to remote media data stored at a different site should not be followed.

Available in iOS 5.0 and later.

Declared in AVAsset.h.

AVAssetReferenceRestrictionForbidLocalReferenceToLocal

Indicates that references from a local asset to local media data stored outside the asset’s container file should not be followed.

Available in iOS 5.0 and later.

Declared in AVAsset.h.

AVAssetReferenceRestrictionForbidAll

Indicates that only references to media data stored within the asset’s container file should be allowed.

Available in iOS 5.0 and later.

Declared in AVAsset.h.