Instance Method


Restarts reading with a new set of time ranges.


func reset(forReadingTimeRanges timeRanges: [NSValue])



An array of NSValue objects, each representing a single CMTimeRange structure.


This method may only be used if supportsRandomAccess has been set to true and may not be called after markConfigurationAsFinal() has been invoked.

This method is often used in conjunction with AVAssetWriter multi-pass. When used as such, the caller invokes copyNextSampleBuffer() until that method returns NULL and then asks the AVAssetWriterInput for a set of time ranges from which it is believed that media data should be re-encoded. These time ranges are then passed to this method to set up the asset reader output for the next pass.

The time ranges set here override the time range set on AVAssetReader instance’s timeRange property. Just as with that property, for each time range in the array the intersection of that time range and CMTimeRangeMake(kCMTimeZero, asset.duration) will take effect. If the start times of each time range in the array are not strictly increasing or if two or more time ranges in the array overlap, an invalidArgumentException will be raised. It is an error to include a time range with a non-numeric start time or duration (CMTIME_IS_NUMERIC), unless the duration is positiveInfinity.

If this method is invoked after the status of the attached AVAssetReader instance has become AVAssetReader.Status.failed or AVAssetReader.Status.cancelled, no change in status will occur and the result of the next call to copyNextSampleBuffer() will be NULL.

If this method is invoked before all media data has been read, for example, copyNextSampleBuffer() has not yet returned NULL, an exception is thrown. This method may not be called before startReading() has been invoked on the attached asset reader.

See Also

Configuring Reading Settings

func markConfigurationAsFinal()

Informs the receiver not to continue reconfiguring the time ranges, and allows the attached asset reader to change its status to completed.

var supportsRandomAccess: Bool

A Boolean value that indicates whether the asset reader output supports reconfiguration of the time ranges.