Class: AVAssetReader
Overview
You use an AVAssetReader object to obtain media data of an asset, whether the asset is file-based or represents an assemblage of media data from multiple sources (as with an AVComposition object).
Instance Attribute Summary (collapse)
-
- asset
readonly
The asset with which the receiver was initialized.
-
- error
readonly
Describes the error that occurred if the status is AVAssetReaderStatusFailed.
-
- outputs
readonly
The outputs from which clients of reader can read media data.
-
- status
readonly
The status of the reading of sample buffers from the asset.
-
- timeRange
The time range of the asset that should be read.
Class Method Summary (collapse)
-
+ assetReaderWithAsset:error:
Returns an asset reader for reading media data from a specified asset.
Instance Method Summary (collapse)
-
- addOutput:
Adds a given output to the receiver.
-
- canAddOutput:
Returns a Boolean value that indicates whether a given output can be added to the receiver.
-
- cancelReading
Cancels any background work and prevents the receiver’s outputs from reading more samples.
-
- initWithAsset:error:
Initializes an asset reader for reading media data from a specified asset.
-
- startReading
Prepares the receiver for obtaining sample buffers from the asset.
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
- (AVAsset) asset (readonly)
The asset with which the receiver was initialized. (read-only) Concrete instances of AVAssetReader with specific AVAssetTrack instances must obtain those tracks from the asset returned by this property.
- (NSError) error (readonly)
Describes the error that occurred if the status is AVAssetReaderStatusFailed. (read-only) This property is thread safe.The value of this property describes what caused the reader to no longer be able to read its asset. If the reader’s status is not AVAssetReaderStatusFailed, the value of this property is nil.
- (Array) outputs (readonly)
The outputs from which clients of reader can read media data. (read-only) The array contains concrete instances of AVAssetReaderOutput associated with the reader.
- (AVAssetReaderStatus) status (readonly)
The status of the reading of sample buffers from the asset. (read-only) This property is thread safe. For possible values, see “Reader Status Constants.”The value of this property indicates whether reading is in progress, has completed successfully, has been canceled, or has failed. You should check the value of this property copyNextSampleBuffer (AVAssetReaderOutput) returns NULL to determine why no more samples could be read.
- (CMTimeRange) timeRange
The time range of the asset that should be read. The intersection of the value of this property and CMTimeRangeMake(kCMTimeZero, asset.duration) determines the time range of the asset from which media data will be read.The default value is CMTimeRangeMake(kCMTimeZero, kCMTimePositiveInfinity). You cannot change the value of this property after reading has started.
Class Method Details
+ (AVAssetReader) assetReaderWithAsset(asset, error:outError)
Returns an asset reader for reading media data from a specified asset.
Instance Method Details
- (Object) addOutput(output)
Adds a given output to the receiver. Outputs are created with a reference to one or more AVAssetTrack objects. Adding an output to an asset reader indicates to the reader that it should source from those tracks. The tracks must be owned by the asset returned by the reader’s asset property.You cannot add an output after reading has started.
- (Boolean) canAddOutput(output)
Returns a Boolean value that indicates whether a given output can be added to the receiver. You cannot add an output that reads from a track of an asset other than the asset used to initialize the receiver.
- (Object) cancelReading
Cancels any background work and prevents the receiver’s outputs from reading more samples. If you want to stop reading samples from the receiver before reaching the end of its time range, you should call this method to stop any background read ahead operations that the may have been in progress.
- (Object) initWithAsset(asset, error:outError)
Initializes an asset reader for reading media data from a specified asset.
- (Boolean) startReading
Prepares the receiver for obtaining sample buffers from the asset. This method validates the entire collection of settings for outputs for tracks, for audio mixdown, and for video composition and initiates reading of all outputs.status signals the terminal state of the asset reader, and if a failure occurs, error describes the failure.