Instance Method

validateSegments(_:)

Returns a Boolean value that indicates whether a given array of track segments conform to the timing rules for a composition track.

Declaration

func validateSegments(_ trackSegments: [AVCompositionTrackSegment]) throws

Parameters

trackSegments

An array of AVCompositionTrackSegment objects.

error

If validation fails, on return contains an NSError object that describes the problem.

Return Value

true if the track segments in trackSegments conform to the timing rules for a composition track, otherwise false.

Discussion

You can use this method to ensure that an array of track segments is suitable for setting as the value of the segments property. The timeMapping.target.start of the first track segment must be kCMTimeZero, and the timeMapping.target.start of each subsequent track segment must equal CMTimeRangeGetEnd(<#previousTrackSegment#>.timeMapping.target).

If you want to modify the existing segments array, you can create a mutable copy of it, modify the mutable array, and then validate the mutable array using this method.