Class: AVAsset

Inherits:
NSObject show all

Overview

AVAsset is an abstract class to represent timed audiovisual media such as videos and sounds. Each asset contains a collection of tracks that are intended to be presented or processed together, each of a uniform media type, including but not limited to audio, video, text, closed captions, and subtitles.

Direct Known Subclasses

AVComposition, AVURLAsset

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Instance Attribute Details

- (Array) availableChapterLocales (readonly)

The locales available for chapters in the asset. (read-only) The array contains instances of NSLocale.

Returns:

- (Array) availableMediaCharacteristicsWithMediaSelectionOptions (readonly)

An array of media characteristics for which a media selection option is available. (read-only) The value of this property is an array of NSString objects, each string indicating a media characteristic for which a media selection option is available.

Returns:

- (Array) availableMetadataFormats (readonly)

An array of strings, each representing a metadata format that’s available to the asset. (read-only) Metadata formats may include ID3, iTunes metadata, and so on. For more details, see AVMetadataItem.

Returns:

- (Array) commonMetadata (readonly)

An array of metadata items for each common metadata key for which a value is available. (read-only) The value is an array of AVMetadataItem objects, one for each metadata key from the common key space for which the asset has an available value. You can filter the array by locale using metadataItemsFromArray:withLocale: (AVMetadataItem) or by key using metadataItemsFromArray:withKey:keySpace: (AVMetadataItem).

Returns:

- (Boolean) compatibleWithSavedPhotosAlbum (readonly)

Indicates whether the asset can be written to the Saved Photos album. (read-only)

Returns:

  • (Boolean)

- (Boolean) composable (readonly)

Indicates whether the asset can be used within a segment of an AVCompositionTrack object. (read-only)

Returns:

  • (Boolean)

- (AVMetadataItem) creationDate (readonly)

Indicates the creation date of the asset. (read-only) The value of this property may be nil.If a creation date has been stored by the asset in a form that can be converted to an NSDate object, the dateValue property of the metadata item will provide an instance of NSDate. Otherwise the creation date is available only as a string value, using the AVMetadataItem stringValue method.

Returns:

- (CMTime) duration (readonly)

The duration of the asset. (read-only) If providesPreciseDurationAndTiming is NO, a best-available estimate of the duration is returned. You can set the degree of precision required for timing-related properties at initialization time for assets initialized with URLs (see AVURLAssetPreferPreciseDurationAndTimingKey in AVURLAsset).

Returns:

  • (CMTime)

- (Boolean) exportable (readonly)

Indicates whether the asset can be exported using AVAssetExportSession. (read-only)

Returns:

  • (Boolean)

- (Boolean) hasProtectedContent (readonly)

Indicates whether the asset has protected content. (read-only)

Returns:

  • (Boolean)

- (String) lyrics (readonly)

The lyrics of the asset suitable for the current locale. (read-only)

Returns:

- (Boolean) playable (readonly)

Indicates whether the asset, or its URL, can be used to initialize an instance of AVPlayerItem. (read-only)

Returns:

  • (Boolean)

- (Float) preferredRate (readonly)

The natural rate at which the asset is to be played. (read-only) This value is often, but not always, 1.0.

Returns:

- (CGAffineTransform) preferredTransform (readonly)

The preferred transform to apply to the visual content of the asset for presentation or processing. (read-only) The value is often, but not always, the identity transform.

Returns:

- (Float) preferredVolume (readonly)

The preferred volume at which the audible media of asset is to be played. (read-only) This value is often, but not always, 1.0.

Returns:

- (Boolean) providesPreciseDurationAndTiming (readonly)

Indicates whether the asset provides precise timing. (read-only) You can set the degree of precision required for timing-related properties at initialization time for assets initialized with URLs (see AVURLAssetPreferPreciseDurationAndTimingKey in AVURLAsset).

Returns:

  • (Boolean)

- (Boolean) readable (readonly)

Indicates whether the asset’s media data can be extracted using AVAssetReader. (read-only)

Returns:

  • (Boolean)

- (AVAssetReferenceRestrictions) referenceRestrictions (readonly)

The reference restrictions being used by the receiver. (read-only) For AVURLAsset, this property reflects the value passed in for AVURLAssetReferenceRestrictionsKey, if any.The default value for this property is availableMediaCharacteristicsWithMediaSelectionOptions. See AVURLAssetReferenceRestrictionsKey for a full discussion of reference restrictions.

Returns:

  • (AVAssetReferenceRestrictions)

- (Array) tracks (readonly)

The tracks contained by the asset. (read-only) Tracks are instances of AVAssetTrack.

Returns:

Class Method Details

+ (Object) assetWithURL(URL)

Returns an asset for inspection of a media resource.

Parameters:

  • URL (NSURL)

    A URL that references a media resource.

Returns:

  • (Object)

    An instance of a subclass of AVAsset initialized with URL.

Instance Method Details

- (Object) cancelLoading

Cancels the loading of all values for all observers. Deallocation of an instance of the asset will implicitly invoke this method if any loading requests are still outstanding.

Returns:

- (Array) chapterMetadataGroupsBestMatchingPreferredLanguages(preferredLanguages)

Returns an array of chapters whose locale best matches the the list of preferred languages. Each object in the returned array contains an AVMetadataItem object representing the chapter title. The time range property of the AVTimedMetadataGroup object is equal to the time range of the chapter title item.All of the available chapter metadata is included in the metadata groups, including items with the common key AVMetadataCommonKeyArtwork, if such items are present. Items not carrying chapter titles are added to an existing AVTimedMetadataGroup object if the time range (timestamp and duration) of the metadata item and that of the metadata group overlaps. The locale of such items need not match the locale of the chapter titles.You can use the metadataItemsFromArray:filteredAndSortedAccordingToPreferredLanguages: method to further filter the metadata items in each group. You can also filter the returned items based on locale using the metadataItemsFromArray:withLocale: method.

Parameters:

  • preferredLanguages (Array)

    An array of NSString objects, each of which contains a canonicalized IETF BCP 47 language identifier. The order of the identifiers in the array reflects the preferred language order, with the most preferred language being first in the array. Typically, you pass the user’s preferred languages by retrieving this array from the preferredLanguages class method of NSLocale.

Returns:

- (Array) chapterMetadataGroupsWithTitleLocale(locale, containingItemsWithCommonKeys:commonKeys)

Returns an array of chapters with a given title locale and containing specified keys. Each object in the returned array contains an AVMetadataItem object representing the chapter title, and the time range property of the AVTimedMetadataGroup object is equal to the time range of the chapter title item.An AVMetadataItem with the specified common key is added to an existing AVTimedMetadataGroup object if the time range (timestamp and duration) of the metadata item and the metadata group overlap.The locale of items not carrying chapter titles need not match the specified locale parameter. You can filter the returned items based on locale using metadataItemsFromArray:withLocale:.

Parameters:

  • locale (NSLocale)

    The locale of the metadata items carrying chapter titles to be returned (the method supports the IETF BCP 47 specification of locales).

  • commonKeys (Array)

    An array of common keys of AVMetadataItem to include in the returned array. AVMetadataCommonKeyArtwork is the only supported key.

Returns:

- (AVMediaSelectionGroup) mediaSelectionGroupForMediaCharacteristic(mediaCharacteristic)

Returns an AVMediaSelectionGroup object that contains one or more options with the specified media characteristic. You can invoke this method without blocking when the key availableMediaCharacteristicsWithMediaSelectionOptions has been loaded.You can filter the options in the returned media selection group according to playability, locale, and additional media characteristics can be accomplished using the filtering methods defined in the AVMediaSelectionGroup class.

Parameters:

  • mediaCharacteristic (String)

    A media characteristic for which you wish to obtain the available media selection options.Only AVMediaCharacteristicAudible and AVMediaCharacteristicLegible are currently supported.Pass AVMediaCharacteristicAudible to obtain the group of available options for audio media in various languages and for various purposes, such as descriptive audio.Pass AVMediaCharacteristicLegible to obtain the group of available options for subtitles in various languages and for various purposes.

Returns:

- (Array) metadataForFormat(format)

Returns an array of AVMetadataItem objects, one for each metadata item in the container of the specified format You can filter the array by locale using metadataItemsFromArray:withLocale: (AVMetadataItem) or by key using metadataItemsFromArray:withKey:keySpace: (AVMetadataItem).

Parameters:

  • format (String)

    The metadata format for which you want items.

Returns:

  • (Array)

    An array of AVMetadataItem objects, one for each metadata item in the container of the specified format, or nil if there is no metadata of the specified format.

- (Array) tracksWithMediaCharacteristic(mediaCharacteristic)

Returns an array of AVAssetTrack objects of the asset that present media with a specified characteristic. You can call this method without blocking when the data in the tracks property is already loaded.

Parameters:

  • mediaCharacteristic (String)

    The media characteristic according to which receiver filters its asset tracks.For valid values, see AVAssetTrack.

Returns:

  • (Array)

    An array of AVAssetTrack objects that present media with mediaCharacteristic, or nil if no tracks with the specified characteristic are available.

- (Array) tracksWithMediaType(mediaType)

Returns an array of the asset tracks of the asset that present media of a specified type. You can call this method without blocking when the data in the tracks property is already loaded.

Parameters:

  • mediaType (String)

    The media type according to which the asset filters its tracks.Media types are defined in AVAssetTrack.

Returns:

  • (Array)

    An array of AVAssetTrack objects of the asset that present media of mediaType.

- (AVAssetTrack) trackWithTrackID(trackID)

Returns the track with a specified track ID. You can call this method without blocking when the data in the tracks property is already loaded.

Parameters:

  • trackID (CMPersistentTrackID)

    The trackID of the requested asset track.

Returns:

  • (AVAssetTrack)

    The track with track ID trackID, or nil if no track with the specified ID is available.

- (CMPersistentTrackID) unusedTrackID

Returns an ID that is currently unused by any of the tracks in the asset.

Returns:

  • (CMPersistentTrackID)