Protocol

AVPlayerViewControllerDelegate

Methods you can implement to respond to media playback events associated with a player view controller.

Declaration

protocol AVPlayerViewControllerDelegate

Overview

On iPad, you can implement methods to manage your app’s participation with Picture in Picture (PiP) playback. On Apple TV, you can implement methods related to playback navigation, interstitial content, and content proposals. Adopt this protocol in a custom object, and assign the object as the delegate of your AVPlayerViewController instance.

Topics

Managing Your App’s UI for Picture in Picture

func playerViewControllerShouldAutomaticallyDismissAtPictureInPictureStart(AVPlayerViewController) -> Bool

Allows you to opt out from the player view controller automatically dismissing when Picture in Picture (PiP) starts.

func playerViewController(AVPlayerViewController, restoreUserInterfaceForPictureInPictureStopWithCompletionHandler: (Bool) -> Void)

Gives your app an opportunity to restore its movie playback user interface; called when Picture in Picture is about to stop.

Responding to Picture in Picture Playback Events

func playerViewControllerWillStartPictureInPicture(AVPlayerViewController)

Tells the delegate Picture in Picture is about to start.

func playerViewControllerDidStartPictureInPicture(AVPlayerViewController)

Tells the delegate Picture in Picture playback has started.

func playerViewControllerWillStopPictureInPicture(AVPlayerViewController)

Tells the delegate Picture in Picture is about to stop.

func playerViewControllerDidStopPictureInPicture(AVPlayerViewController)

Tells the delegate Picture in Picture playback has stopped and the stopping animation has finished.

Responding to Navigation Events

func playerViewController(AVPlayerViewController, timeToSeekAfterUserNavigatedFrom: CMTime, to: CMTime) -> CMTime

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

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.

Responding to Interstitial Content Playback Events

func playerViewController(AVPlayerViewController, willPresent: AVInterstitialTimeRange)

Tells the delegate the player view controller is about to begin playing a range of interstitial content.

func playerViewController(AVPlayerViewController, didPresent: AVInterstitialTimeRange)

Tells the delegate the player view controller has completed playing a range of interstitial content.

Responding to Content Proposals

func playerViewController(AVPlayerViewController, didAccept: AVContentProposal)

Tells the delegate the user accepts the presented content proposal.

func playerViewController(AVPlayerViewController, didReject: AVContentProposal)

Tells the delegate the user rejects the presented content proposal.

func playerViewController(AVPlayerViewController, shouldPresent: AVContentProposal) -> Bool

Tells the delegate whether the content proposal should be presented.

Responding to Media Selection

func playerViewController(AVPlayerViewController, didSelect: AVMediaSelectionOption?, in: AVMediaSelectionGroup)

Tells the delegate a user has selected a media option from a media selection group.

Responding to Transport Bar Changes

Relationships

Inherits From

See Also

Accessing the Delegate Object

var delegate: AVPlayerViewControllerDelegate?

The delegate object for the player view controller.

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