Instance Method

insertTimeRange(_:of:at:)

Inserts all the tracks within a given time range of a specified asset into the receiver.

Declaration

func insertTimeRange(_ timeRange: CMTimeRange, of asset: AVAsset, at startTime: CMTime) throws

Parameters

timeRange

The time range of the asset to be inserted.

asset

An asset that contains the tracks to be inserted.

startTime

The time at which the inserted tracks should be presented by the receiver.

outError

If the insertion was not successful, on return contains an NSError object that describes the problem.

Return Value

true if the insertion was successful, otherwise false.

Discussion

This method may add new tracks to ensure that all tracks of the asset are represented in the inserted time range.

Existing content at the specified start time is pushed out by the duration of the time range.

Media data for the inserted time range is presented at its natural duration; you can scale it to a different duration using scaleTimeRange(_:toDuration:).

See Also

Managing Time Ranges

func insertEmptyTimeRange(CMTimeRange)

Adds or extends an empty time range within all tracks of the composition.

func removeTimeRange(CMTimeRange)

Removes a specified time range from all tracks of the composition.

func scaleTimeRange(CMTimeRange, toDuration: CMTime)

Changes the duration of all tracks in a given time range.