A controller that responds to user-initiated playback of video in a floating, resizable window on iPad.
Mac Catalyst 13.0+
When you use this class, your app is responsible for providing a button for the user to tap to invoke the Picture in Picture feature with your content. Before displaying the button, call the isPictureInPictureSupported() method to determine if the user’s iPad supports the feature, and check the isPictureInPicturePossible property to determine whether PiP is possible in the current context.
To participate with Picture in Picture, take the following steps in your Xcode project:
Link on or after iOS 9.0.
In the Xcode Capabilities view for your project, select Audio and AirPlay in the Background Modes section.
Configure your audio session with an appropriate category, such as playback.
Creating and Configuring a Picture in Picture Controller
Stops Picture in Picture for the associated AVPlayerLayer instance, if it is currently active.
Retrieving Picture in Picture Template Images
You can use the following methods to retrieve system default images to start and stop Picture in Picture playback in your custom player interface. The images returned match the images found in the user interface provided by AVPlayerViewController.
This sample code project demonstrates techniques for tracking AVPlayerViewController presentation state across multiple application scenarios, including being displayed fullscreen, embedded inline, or as Picture in Picture.