swift – Is iOS PIP (Picture In Picture) for Video Call a private API?

swift – Is iOS PIP (Picture In Picture) for Video Call a private API?

(See update below)

OLD

Yes, it is achieved through private APIs. It is not possible for third-party apps to do this.

Basically people have played around with live-streaming video with low latency and displaying that in PiP mode. It is not easy to do right, but it is doable. However, you cannot keep the camera active during PiP, so a video call is unfortunately still not possible (at least it would be one-sided).

UPDATE:

With iOS 15 it is now possible using the Multitasking Camera Access Entitlement to keep the camera recording while in PiP mode using the AVPictureInPictureController.

iOS 15 Update;

Adopting Picture in Picture for Video Calls

Create a Source View

class SampleBufferVideoCallView: UIView {
    override class var layerClass: AnyClass {
        get { return AVSampleBufferDisplayLayer.self }
    }

    var sampleBufferDisplayLayer: AVSampleBufferDisplayLayer {
        return layer as! AVSampleBufferDisplayLayer
    }
}

Create a Video-Call Controller

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

Create a PiP Controller using a Content Source

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


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

Observe Picture in Picture Lifecycle Events

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

swift – Is iOS PIP (Picture In Picture) for Video Call a private API?

Leave a Reply

Your email address will not be published.