Class

AVPictureInPictureController

A controller that responds to user-initiated Picture in Picture playback of video in a floating, resizable window.

Declaration

class AVPictureInPictureController : NSObject

Overview

Your app is responsible for providing a button for the user to tap to invoke Picture in Picture playback. Before displaying the button, call the isPictureInPictureSupported() method to determine if the user’s device supports the feature, and check the isPictureInPicturePossible property to determine whether PiP is possible in the current context.

To participate with Picture in Picture in iOS, take the following steps in your Xcode project:

  1. In the Xcode Capabilities view for your project, select Audio and AirPlay in the Background Modes section.

  2. Configure your audio session with an appropriate category, such as playback.

Topics

Creating and Configuring a Picture in Picture Controller

init?(playerLayer: AVPlayerLayer)

Creates a new Picture in Picture controller.

var delegate: AVPictureInPictureControllerDelegate?

The Picture in Picture controller’s delegate object.

protocol AVPictureInPictureControllerDelegate

The protocol that defines the methods to respond to Picture in Picture events.

var playerLayer: AVPlayerLayer

The player layer that displays the media to play.

Accessing Picture in Picture State

class func isPictureInPictureSupported() -> Bool

Returns a Boolean value that determines whether the current device supports Picture in Picture playback.

var isPictureInPicturePossible: Bool

A Boolean value that indicates whether Picture in Picture playback is currently possible.

var isPictureInPictureActive: Bool

A Boolean value that indicates whether the controller’s Picture in Picture window is onscreen.

var isPictureInPictureSuspended: Bool

A Boolean value that indicates whether the system suspended the controller’s Picture in Picture window.

Controlling Picture in Picture Playback

func startPictureInPicture()

Starts Picture in Picture playback, if possible.

func stopPictureInPicture()

Stops Picture in Picture playback, if it’s 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.

class var pictureInPictureButtonStartImage: UIImage

The system default Picture in Picture start template image for use in an app’s Picture in Picture button.

class var pictureInPictureButtonStopImage: UIImage

The system default Picture in Picture stop template image for use in an app’s Picture in Picture button.

class func pictureInPictureButtonStartImage(compatibleWith: UITraitCollection?) -> UIImage

Returns the system default Picture in Picture start template image for use in your player’s Picture in Picture button.

class func pictureInPictureButtonStopImage(compatibleWith: UITraitCollection?) -> UIImage

Returns the system default Picture in Picture stop template image for use in your player’s Picture in Picture button.

Relationships

Inherits From

Conforms To

See Also

Media Playback

Adopting Picture in Picture in a Standard Player

Add Picture in Picture (PiP) playback to your app using a player view controller.

Adopting Picture in Picture in a Custom Player

Add controls to your custom player user interface to invoke Picture in Picture (PiP) playback.

Working with Interstitial Content in tvOS

Present additional content such as legal text, content warnings, or advertisements alongside your main media presentation.

Using AVKit in iOS

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.

Adopting Custom Interactive Overlays, Channel Flipping, and Parental Controls in tvOS Video Playback

This sample demonstrates support for custom interactive overlays, and parental controls, using AVPlayerViewController.

Adding Information to the Info Panel (tvOS)

Add metadata information and navigation markers to the Info panel in Apple TV.

class AVPlayerViewController

A view controller that displays the video content from a player object along with system-supplied playback controls.

class AVPlayerView

A macOS-only object that displays the video content from a player object along with system-supplied playback controls.

class AVInterstitialTimeRange

A time range in an audiovisual presentation designated as interstitial content, such as advertisements or legal notices.

class AVNavigationMarkersGroup

A set of markers for navigating playback of an audiovisual presentation.