<!--
{
  "documentType" : "article",
  "framework" : "AVKit",
  "identifier" : "/documentation/AVKit/adopting-picture-in-picture-for-video-calls",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Adopting Picture in Picture for video calls"
}
-->

# Adopting Picture in Picture for video calls

Add multitasking capability to your video-call apps by using Picture in Picture (PiP).

## Discussion

Use PiP in your video-call apps so users can multitask with other apps while on video calls. When a user enables PiP, your app scales down to a corner of the screen, so they can see the Home Screen and interact with other apps. In iOS 15 and later, [`AVKit`](/documentation/AVKit) provides PiP support for video-calling apps, which enables you to deliver a familiar video-calling experience that behaves like FaceTime.

> Important:
> In iOS 16 and later, you can use the camera in Picture in Picture mode by enabling a capture session’s <doc://com.apple.documentation/documentation/AVFoundation/AVCaptureSession/isMultitaskingCameraAccessEnabled> property. Apps that have a deployment target earlier than iOS 16 require the <doc://com.apple.documentation/documentation/BundleResources/Entitlements/com.apple.developer.avfoundation.multitasking-camera-access> entitlement to use the camera in PiP mode.

### Create a source view

Providing PiP support begins by choosing a source view to display inside the video-call view controller. You need to add a `UIView` to `AVPictureInPictureVideoCallViewController`, so use <doc://com.apple.documentation/documentation/AVFoundation/AVCaptureVideoPreviewLayer> or <doc://com.apple.documentation/documentation/AVFoundation/AVSampleBufferDisplayLayer> depending on your need. In iOS 18 and later, you may also use <doc://com.apple.documentation/documentation/MetalKit/MTKView> as your source view. Video-calling apps need to display the remote view, so use <doc://com.apple.documentation/documentation/AVFoundation/AVSampleBufferDisplayLayer> to do so.

```swift
class SampleBufferVideoCallView: UIView {
    override class var layerClass: AnyClass {
        AVSampleBufferDisplayLayer.self
    }
    
    var sampleBufferDisplayLayer: AVSampleBufferDisplayLayer {
        layer as! AVSampleBufferDisplayLayer
    }
}
```

### Create a video-call controller

To display your source view, create a [`AVPictureInPictureVideoCallViewController`](/documentation/AVKit/AVPictureInPictureVideoCallViewController) and add your source as a subview.

```swift
let pipVideoCallViewController = AVPictureInPictureVideoCallViewController()
pipVideoCallViewController.preferredContentSize = CGSize(width: 1080, height: 1920)
pipVideoCallViewController.view.addSubview(sampleBufferVideoCallView)
```

Use [`isPictureInPictureSupported()`](/documentation/AVKit/AVPictureInPictureController/isPictureInPictureSupported()) to determine whether the current device supports PiP playback. If PiP isn’t supported on the current device, attempting to initialize a PiP controller returns `nil`.

### Create a PiP controller using a content source

Before you create an [`AVPictureInPictureController`](/documentation/AVKit/AVPictureInPictureController), you need to create an [`AVPictureInPictureController.ContentSource`](/documentation/AVKit/AVPictureInPictureController/ContentSource-swift.class) that represents the source of the content the system displays. A content source requires a video-call view controller, and a source view that contains the content you associate with the video call.

```swift
let pipContentSource = AVPictureInPictureController.ContentSource(
                            activeVideoCallSourceView: videoCallViewSourceView, 
                            contentViewController: pipVideoCallViewController)
```

> Important:
> Avoid unintentionally starting PiP by setting the content source on your PiP controller to `nil` or by releasing your PiP controller, when the active call ends.

After creating a content source, use it to initialize [`AVPictureInPictureController`](/documentation/AVKit/AVPictureInPictureController). By default, PiP starts when a user moves to the background if your source view is full-screen, or you set [`canStartPictureInPictureAutomaticallyFromInline`](/documentation/AVKit/AVPictureInPictureController/canStartPictureInPictureAutomaticallyFromInline) to `true`. If your app is in the foreground, you can start PiP by calling [`startPictureInPicture()`](/documentation/AVKit/AVPictureInPictureController/startPictureInPicture()).

```swift
let pipController = AVPictureInPictureController(contentSource: pipContentSource)
pipController.canStartPictureInPictureAutomaticallyFromInline = true
pipController.delegate = self
```

The system uses the source view to determine the source frame for the PiP animation, and the restore target for either when the user returns to the app or PiP stops.

> Note:
> The PiP window doesn’t receive touch events when you use ``doc://com.apple.avkit/documentation/AVKit/AVPictureInPictureVideoCallViewController``, so you can’t customize the window’s user interface by adding buttons.

### Observe PiP life cycle events

When you use PiP, you respond to life-cycle events by observing [`AVPictureInPictureControllerDelegate`](/documentation/AVKit/AVPictureInPictureControllerDelegate). This allows you to handle your app’s user interface based on the PiP state, along with observing for potential errors.

The system interrupts your capture session when the system or user stashes PiP, so observe <doc://com.apple.documentation/documentation/AVFoundation/AVCaptureSession/wasInterruptedNotification> for <doc://com.apple.documentation/documentation/AVFoundation/AVCaptureSession/InterruptionReason/videoDeviceNotAvailableInBackground> to handle the interruption.

When your app is in PiP mode, it can’t assume control of the camera. For example, Camera.app assumes control of the camera when it’s opened, and the system returns camera control when Camera.app finishes with it. You observe <doc://com.apple.documentation/documentation/AVFoundation/AVCaptureSession/wasInterruptedNotification> for <doc://com.apple.documentation/documentation/AVFoundation/AVCaptureSession/InterruptionReason/videoDeviceInUseByAnotherClient> to handle the interruption.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)