Contents

loadSegment(forTrackTime:completionHandler:)

Loads a segment with a target time range that contains, or is closest to, the specified track time.

Declaration

func loadSegment(forTrackTime trackTime: CMTime, completionHandler: @escaping  @Sendable (AVAssetTrackSegment?, (any Error)?) -> Void)
func loadSegment(forTrackTime trackTime: CMTime) async throws -> AVAssetTrackSegment?

Parameters

  • trackTime:

    The track time of the segment to load.

  • completionHandler:

    A callback that the system invokes after it finishes the loading request. It passes the completion handler the following parameters:

    segment

    The loaded track segment, or nil if an error occurs.

    error

    An error object if the request fails; otherwise, nil.

Discussion

If the specified track time doesn’t map to a sample presentation time, the system returns the segment with the closest matching time.

See Also

Loading track segments