Instance Method

seek(to:toleranceBefore:toleranceAfter:)

Sets the current playback time within a specified time bound.

Declaration

func seek(to time: CMTime, toleranceBefore: CMTime, toleranceAfter: CMTime)

Parameters

time

The time to which you would like to move the playback cursor.

toleranceBefore

The tolerance allowed before time.

toleranceAfter

The tolerance allowed after time.

Discussion

The time seeked to will be within the range [time-beforeTolerance, time+afterTolerance], and may differ from the specified time for efficiency. If you pass kCMTimeZero for both toleranceBefore and toleranceAfter (to request sample accurate seeking), you may incur additional decoding delay that impacts seeking performance.

Passing kCMTimePositiveInfinity for both toleranceBefore and toleranceAfter is the same as messaging seek(to:) directly.

See Also

Moving the Playhead

func step(byCount: Int)

Moves the player item’s current time forward or backward by a specified number of steps.

var seekableTimeRanges: [NSValue]

An array of time ranges within which it is possible to seek.

func seek(to: CMTime, completionHandler: ((Bool) -> Void)?)

Sets the current playback time to the specified time and executes the specified block when the seek operation completes or is interrupted.

func seek(to: Date, completionHandler: ((Bool) -> Void)?) -> Bool

Sets the current playback time to the time specified by the date object.

func seek(to: CMTime, toleranceBefore: CMTime, toleranceAfter: CMTime, completionHandler: ((Bool) -> Void)?)

Sets the current playback time within a specified time bound and invokes the specified block when the seek operation completes or is interrupted.

func cancelPendingSeeks()

Cancels any pending seek requests and invokes the corresponding completion handlers if present.

func seek(to: Date) -> Bool

Sets the current playback time to the time specified by the date object.

Deprecated
func seek(to: CMTime)

Sets the current playback time to the specified time.

Deprecated

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software