How to Use Picture in Picture (PiP) in Swift

Halil Özel
3 min readJun 13, 2019

Hello Guys,

Today we will learn the structure of picture in picture with you.

If you’re ready, let’s get started 😁

What is the Picture in Picture (PiP) ? 🤔

  • Picture in Picture (PiP) playback was introduced in iOS 9.
  • It lets iPad users play video in a moveable, resizable window that floats over the apps onscreen.
  • It brings a new level of multitasking capabilities to the iPad, enabling users to continue playback while performing other activities on their devices.
  • This feature is found in Apple’s built-in video playback apps, and is available to your apps through the AVKit framework.

Note : PiP used only in iPAD applications.

Applications that support PiP playback present a small button in the lower-right corner of the video playback window. Tapping this button minimizes the video display to a small floating window, letting the user perform other activities in the primary application or even in another application.

After learning the pip structure, let’s make an example.

Picture in Picture App

Design

First we design our screens.

We have two screens.

There is a button on the first screen. Press the button and the video starts.

On the second screen has navigation controller.

Coding

After designing, let’s make to coding

We add the necessary code for Audio Session operations to the AppDelegate class.

--

--