Mac Developer Library

Developer

AVFoundation Framework Reference AVURLAsset Class Reference

Options
Deployment Target:

On This Page
Language:

AVURLAsset

Inheritance


Conforms To


Import Statement


Swift

import AVFoundation

Objective-C

@import AVFoundation;

Availability


Available in OS X v10.7 and later.

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

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

    Declaration

    Swift

    init!(URL URL: NSURL!, options options: [NSObject : AnyObject]!)

    Objective-C

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

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Objective-C

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

    Import Statement

    Objective-C

    @import AVFoundation;

    Availability

    Available in OS X v10.7 and later.

  • URL URL Property

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

    Declaration

    Swift

    @NSCopying var URL: NSURL! { get }

    Objective-C

    @property(nonatomic, readonly, copy) NSURL *URL

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    var resourceLoader: AVAssetResourceLoader! { get }

    Objective-C

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

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in OS X v10.9 and later.

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

    Declaration

    Swift

    func compatibleTrackForCompositionTrack(_ compositionTrack: AVCompositionTrack!) -> AVAssetTrack!

    Objective-C

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

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    class func audiovisualMIMETypes() -> [AnyObject]!

    Objective-C

    + (NSArray *)audiovisualMIMETypes

    Return Value

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

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    class func audiovisualTypes() -> [AnyObject]!

    Objective-C

    + (NSArray *)audiovisualTypes

    Return Value

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

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    class func isPlayableExtendedMIMEType(_ extendedMIMEType: String!) -> Bool

    Objective-C

    + (BOOL)isPlayableExtendedMIMEType:(NSString *)extendedMIMEType

    Parameters

    extendedMIMEType

    An extended MIME type.

    Return Value

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

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    let AVURLAssetPreferPreciseDurationAndTimingKey: String let AVURLAssetReferenceRestrictionsKey: String

    Objective-C

    NSString *const AVURLAssetPreferPreciseDurationAndTimingKey; NSString *const AVURLAssetReferenceRestrictionsKey;

    Constants

    • AVURLAssetPreferPreciseDurationAndTimingKey

      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.

      YEStrue 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 NOfalse 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 YEStrue is recommended.

      Available in OS X v10.7 and later.

    • AVURLAssetReferenceRestrictionsKey

      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 OS X v10.7 and later.

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

    Declaration

    Swift

    struct AVAssetReferenceRestrictions : RawOptionSetType { init(_ rawValue: UInt) init(rawValue rawValue: UInt) static var RestrictionForbidNone: AVAssetReferenceRestrictions { get } static var RestrictionForbidRemoteReferenceToLocal: AVAssetReferenceRestrictions { get } static var RestrictionForbidLocalReferenceToRemote: AVAssetReferenceRestrictions { get } static var RestrictionForbidCrossSiteReference: AVAssetReferenceRestrictions { get } static var RestrictionForbidLocalReferenceToLocal: AVAssetReferenceRestrictions { get } static var RestrictionForbidAll: AVAssetReferenceRestrictions { get } }

    Objective-C

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

    Constants

    • RestrictionForbidNone

      AVAssetReferenceRestrictionForbidNone

      Indicates that all types of references should be followed.

      Available in OS X v10.7 and later.

    • RestrictionForbidRemoteReferenceToLocal

      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 OS X v10.7 and later.

    • RestrictionForbidLocalReferenceToRemote

      AVAssetReferenceRestrictionForbidLocalReferenceToRemote

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

      Available in OS X v10.7 and later.

    • RestrictionForbidCrossSiteReference

      AVAssetReferenceRestrictionForbidCrossSiteReference

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

      Available in OS X v10.7 and later.

    • RestrictionForbidLocalReferenceToLocal

      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 OS X v10.7 and later.

    • RestrictionForbidAll

      AVAssetReferenceRestrictionForbidAll

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

      Available in OS X v10.7 and later.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.