Instance Method

seek(to:completionHandler:)

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

Declaration

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

Parameters

date

The time to which to seek.

completionHandler

The block to invoke when the seek operation has either been completed or been interrupted. The block takes one argument:

finished

Indicates whether the seek operation completed.

Return Value

true if the playhead moved to the specified date or false if it did not.

Discussion

Use this method to seek to a specified time in the player item and be notified when the operation completes. If the seek request completes without being interrupted (either by another seek request or by any other operation), the completion handler you provide is executed with the finished parameter set to true.

If another seek request is already in progress when you call this method, the completion handler for the in-progress seek request is executed immediately with the finished parameter set to false.

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: 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
func seek(to: CMTime, toleranceBefore: CMTime, toleranceAfter: CMTime)

Sets the current playback time within a specified time bound.

Deprecated