Instance Method

playerViewController(_:timeToSeekAfterUserNavigatedFrom:to:)

Tells the delegate a user has skipped, scrubbed, or otherwise navigated to a new time and wants to resume playback at the targetTime.

Declaration

optional func playerViewController(_ playerViewController: AVPlayerViewController, timeToSeekAfterUserNavigatedFrom oldTime: CMTime, to targetTime: CMTime) -> CMTime

Parameters

playerViewController

The player view controller to which this delegate is assigned.

oldTime

The current playback time before the user began navigating.

targetTime

The time to which the user navigated.

Return Value

The time at which playback should begin.

Discussion

This method is called prior to beginning playback after a user-initiated scrubbing request. You can return a time value other than the user’s targetTime if needed to enforce certain business rules. For instance, you may want to return a different time to prevent users from skipping past ad breaks in your program.

You should not use this method to disable scrubbing. Instead, use the player view controller’s requiresLinearPlayback property to disable scrubbing.

See Also

Responding to Navigation Events

func playerViewController(AVPlayerViewController, willResumePlaybackAfterUserNavigatedFrom: CMTime, to: CMTime)

Tells the delegate the user has skipped, scrubbed, or otherwise navigated to a new time, and playback is about to start at the new time.

func skipToPreviousItem(for: AVPlayerViewController)

Tells the delegate the user skips backward in the timeline and the player view controller is configured to use non-default skipping behavior.

func skipToNextItem(for: AVPlayerViewController)

Tells the delegate the user skips forward in the timeline and the player view controller is configured to use non-default skipping behavior.