Latest 1.0
License MIT
Platforms ios 9.0, requires ARC
Frameworks UIKit, AVKit


PiPhone is a drop in solution to support picture-in-picture (user-initiated playback of video in a floating, resizable window) on iPhone devices. It’s designed to mimic default AVPictureInPictureController behavior as much as possible.



  • [x] Picture in picture support for devices that doesn’t support it by default
  • [x] No additional work required if AVPictureInPictureController has been already configured
  • [x] Same appearance as default one
  • [x] Handling video size changing
  • [x] Handling video errors
  • [x] Supports tap, double tap, pinch and pan gestures
  • [x] Mimic AVPictureInPictureControllerDelegate behavior


  • Xcode 8.0+
  • iOS 9.0+


PiPhone is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'PiPhone'


To display video in picture-in-picture mode you can use both AVPlayerViewController and any custom video player configured to be diplayed in picture-in-picture.

Basically you don’t need to perform any additional actions, your video players support picture-in-picture now! But PiPhone provides some customizations that you can find useful.

Make sure to import the framework header: #import <PiPhone/PiPhone.h> for Objective-C or import PiPhone for Swift.

Content inset adjustment behavior

Default AVPictureInPictureController behavior is to find the topmost UINavigationController‘s bar, UITabBarController‘s bar, safeAreaInsets, etc and determine where to place overlay video based on this metrics. Since imitation of this behavior turned out to be complicated and tricky process, it’ve been decided to control overlay video position based on predefined configurations.


Includes safe area insets and additional 44dp (32dp on landscape) inset from top safe area.


Includes safe area insets and additional 49dp (32dp on landscape in iOS 11 and above) inset from bottom safe area.


Includes both PiPManagerContentInsetAdjustmentNavigationBar and PiPManagerContentInsetAdjustmentTabBar.


Includes safe area insets.


Overlay video is pinned to screen edges.

This behavior can be changed via PiPManager‘s contentInsetAdjustmentBehavior property.


PiPManager.contentInsetAdjustmentBehavior = PiPManagerContentInsetAdjustmentNavigationAndTabBars;

// animated
[UIView animateWithDuration:0.25 animations:^{
    PiPManager.contentInsetAdjustmentBehavior = PiPManagerContentInsetAdjustmentNavigationAndTabBars;


PiPManager.contentInsetAdjustmentBehavior = .navigationAndTabBars

// animated
UIView.animate(withDuration: 0.25) {
    PiPManager.contentInsetAdjustmentBehavior = .navigationAndTabBars

Additional content insets

Also you can set extra spacing from screen edges to overlay video which will be added to automatically calculated one.


PiPManager.additionalContentInsets = UIEdgeInsetsMake(20, 10, 20, 10);

// animated
[UIView animateWithDuration:0.25 animations:^{
    PiPManager.additionalContentInsets = UIEdgeInsetsMake(20, 10, 20, 10);

Swift = 20

// animated
UIView.animate(withDuration: 0.25) { = 20

Disable picture-in-picture

You can temporarily disable picture-in-picture mode causing AVPictureInPictureController‘s isPictureInPicturePossible property to be false.
Note: this will only have affect on iPhone.


// enable
PiPManager.pictureInPicturePossible = YES;

// disable
PiPManager.pictureInPicturePossible = NO;


// enable
PiPManager.isPictureInPicturePossible = true

// disable
PiPManager.isPictureInPicturePossible = false

To Do

  • Reduce private API usage
  • Investigate whether PiPPictureInPictureController should become a AVPictureInPictureController subclass
  • Implement rotation gesture, add ‘soft’ deceleration for pinch gesture
  • Improve automatic insets calculation


To run the example project, clone the repo, and run pod install from the Example directory first.

Thanks & Credits


PiPhone is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "PiPhone",
    "version": "1.0",
    "summary": "Picture in picture video playback for iPhone",
    "description": "PiPhone is a drop in solution to support picture-in-picture (user-initiated playback of video in a floating, resizable window) on iPhone devices.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "ky1vstar": "[email protected]"
    "source": {
        "git": "",
        "tag": "1.0"
    "platforms": {
        "ios": "9.0"
    "requires_arc": true,
    "resources": "Source/*.xcassets",
    "public_header_files": [
    "source_files": "Source/**/*.{h,m}",
    "frameworks": [

Pin It on Pinterest

Share This