This library is a UIView that is capable of Picture-in-Picture (PiP) in iOS.

Related tags

Guides swift ios uikit pip
Overview

>> 日本語

UIPiPView

This library is a UIView that is capable of Picture-in-Picture (PiP) in iOS.

Using this library, information that is updated in real time (e.g. stock prices) can be displayed on the screen using PiP, even when the app is in the background. We look forward to seeing many ideas come to fruition using this library.

Requirements

You need to be running iOS15 or higher. This library can be installed on iOS12 or higher, but PiP cannot be executed without iOS15 or higher.

Also, as a note for development, PiP will only work on ACTUAL DEVICES. Please note that PiP does not work with simulators. Also, this library depends on AVKit and AVFoundation.

If you want to include this library in your app, you need to enable Audio, AirPlay and Picture in Picture in Backgroound Models. For more information, see Apple's page.

Installation

UIPiPView can be installed using CocoaPods. You can install it using You can install it by writing the following to your Podfile and running $ pod install.

pod 'UIPiPView', :git => 'https://github.com/uakihir0/UIPiPView/', :branch => 'main'

Example

It is always a good idea to check if your environment is ready to use UIPiPView before you start. You can do this with the following code.

uiPipView.isUIPiPViewSupported()

Start

Since UIPiPView inherits from UIView, it can be used in the same way as UIView. To run PiP, execute the following function. Run the following function to run PiP.

uiPipView.startPictureInPicture(withRefreshInterval: (0.1 / 60.0))

The above function will refresh the PiP screen 60 times per second. The screen refresh is a relatively heavy process because the UIView is converted to a CMSampleBuffer via a UIImage. Therefore, if the UIView is complex, the update processing may not be able to keep up, or it may affect other processing. In that case, change the arguments in the above code to reduce the update frequency, or run PiP with the following code.

uiPipView.startPictureInPictureWithManualCallRender()

The above function will not automatically refresh the screen except for the first screen refresh. If you want to update the screen, execute the following additional code.

uiPipView.render()

Running the above function will render the state of the UIPiPView at the time the thread completes. By using this function, we can perform rendering at each screen update timing and keep the rendering cost to a minimum.

Exit

To exit PiP, execute the following code.

uiPipView.stopPictureInPicture()

Author

Akihiro Urushihara
Mail: [email protected]
Twitter: @uakihir0

License

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

Comments
  • Show animation / Hide view

    Show animation / Hide view

    Hi! I need to show an animation when pipView starts (imageView should shrink smoothly) - can this be done with this library? When I try to make an animation, pipView immediately shows its final result, without animation.

    Second question. Is it possible to override the behavior of the top right button (which is used to exit pip mode)? For example, just close pipView, as when clicking on a cross.

    opened by rozmarica 2
  • Problem with working on iOS16

    Problem with working on iOS16

    Hi! On iOS16: first time run startPictureInPicture() an infinite loading appears (screenshot attached). On subsequent runs, startPictureInPicture() works correctly. But if close application and start it again, then at first there will be an infinite loading again Please, help solve this problem image

    opened by rozmarica 1
  • Change PIP window size

    Change PIP window size

    How to modify the size of PIP window? I use OC language. Can I have an OC version that can modify the size of PIP window? I'm currently studying. Thank you

    opened by Andrew5 1
  • #14 update support version to iOS12

    #14 update support version to iOS12

    fix #14

    The latest Xcode has difficulty supporting iOS9, so we have changed the minimum to iOS12. (At least iOS15 is required to use this library as it functions.) (Swift package manager already requires iOS15 or higher.)

    opened by uakihir0 0
  • #11 Fix issue for iOS16 grayout screen

    #11 Fix issue for iOS16 grayout screen

    fix #11

    before after

    https://user-images.githubusercontent.com/1501888/190159252-9937600d-4c2c-4903-bdc8-6a2972f86d97.mp4

    https://user-images.githubusercontent.com/1501888/190160402-c61df739-584b-4e0a-8bbd-e3711aecee6d.mp4

    opened by uakihir0 0
  • #3 Improved drawing methods

    #3 Improved drawing methods

    With the help of the following site I have improved the way PiPView draws.

    https://soranoba.net/programming/uiview-to-cmsamplebuffer

    Issue

    fix #3

    Result

    • Before
    スクリーンショット 2022-04-03 18 15 25
    • After
    スクリーンショット 2022-04-03 18 21 08
    opened by uakihir0 0
  • Improved drawing methods

    Improved drawing methods

    The drawing speed is slow and the process is a long way off, so the following article will help to improve the process.

    https://soranoba.net/programming/uiview-to-cmsamplebuffer

    opened by uakihir0 0
  • Huge CPU usage since iOS 16.1

    Huge CPU usage since iOS 16.1

    Huge CPU usage since iOS 16.1

    Hi. Our users point that since iOS 16.1 our app with PiP drain battery very fast.

    We had tested it. So. If PiP disabled then our app use about 2-5% CPU time. As soon as the PiP is turned on, the usage instantly grows to 110% - 130%.

    We have changed the library code in such a way as to exclude any influence of our code. There was no content rendering for the test. Just a black window. And yet the load is the same 110% - 130%.

    Can you confirm that you are experiencing the same issue? Is it library specific or is it a system bug. If this is a system bug, then let's create a defect in Apple Bug Tracker. Because iOS 16.2 has already been released, but the problem has not been solved.

    opened by Reactor13 5
  • Support canStartPictureInPictureAutomaticallyFromInline

    Support canStartPictureInPictureAutomaticallyFromInline

    Hello,

    In iOS 14.2, Apple added canStartPictureInPictureAutomaticallyFromInline, so developers don't have to explicitly call PiP methods from lifecycle functions.

    This would fit great in my app, where the user may leave the app without enabling PiP, where it would still be beneficial to have it. I tried to fork the repo and add canStartPictureInPictureAutomaticallyFromInline to the pipController, but it didn't work.

    opened by WillBishop 1
Owner
Akihiro Urushihara
Swift/Kotlin/Java/Go Programmer
Akihiro Urushihara
DCL Private Library

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

null 0 Nov 28, 2021
SwiftUI module library for adding seasons theme animations to your app

HolidayThemes SwiftUI module library for adding seasons theme animations to your app. Requirements iOS 13.0+ Xcode 12.0+ Installation Swift Package Ma

null 2 Mar 7, 2022
SmartString - A powerful and small library that will allow the creation of complex String Styles

SmartString A powerful and small library that will allow the creation of complex

Valerio 7 Oct 26, 2022
Swift library of lightweight interfaces for prototyping, bridged to JS

Prototope Prototope is a lightweight, high-performance prototyping framework. Its goals are: making simple things very easy making complex things poss

Khan Academy 230 Jun 29, 2022
⚛️ A Reactive Data-Binding and Dependency Injection Library for SwiftUI x Concurrency.

SwiftUI Atom Properties A Reactive Data-Binding and Dependency Injection Library for SwiftUI x Concurrency ?? API Reference Introduction Examples Gett

Ryo Aoyama 199 Dec 17, 2022
Swift Client library to interact with Supabase Functions.

functions-swift Swift Client library to interact with Supabase Functions. Usage let client = FunctionsClient( url: URL(string: "https://project-id.s

Supabase Community 3 Dec 1, 2022
This is an iOS Safari Extension Sample that adds a "Develop menu" to Safari on iOS to allow you to analyze websites.

Develop Menu for Mobile Safari This is an iOS Safari Extension that adds a "Develop menu" to Safari on iOS to allow you to analyze websites. This is a

Watanabe Toshinori 1 Dec 7, 2022
List of awesome iOS & Swift stuff!!

Awesome iOS Developer Feel free to fork this repository and pull requests!! ?? Content Coding Convention Swift Lint Design Pattern Adaptor Delegation

Jungpyo Hong 666 Jan 8, 2023
An assignment for ios Dev intern position

iOS Assignment An assignment for ios Dev intern position Design Process A UI design for the project is made in FIGMA. Link here Figma Sneek Peek Descr

Divyam Solanki 11 Apr 28, 2022
SwiftUI iOS component for Step Indications.

StepperView SwiftUI iOS component for Step Indications Table of Contents Features Documentation Installation CocoaPods Carthage Swift Package Manager

Badarinath Venkatnarayansetty 851 Dec 29, 2022
This is a course project for CodePath Professional iOS Development class.

Parstagram - Part I This is an Instagram clone with a custom Parse backend that allows a user to post photos and view a global photos feed. Time spent

Mingkai Chen 0 Oct 13, 2021
Mini-application iOS native avec Xcode et Swift exploitant l'architecture MVVM et le framework Combine d'Apple pour la mise en place de la programmation réactive fonctionnelle, le tout avec UIKit.

iOS (Swift 5): Test MVVM avec Combine et UIKit L'architecture MVVM et la programmation réactive fonctionnelle sont très utlisées dans le développement

Koussaïla BEN MAMAR 2 Nov 5, 2022
iOS native app demo with Xcode and Swift using MVVM architecture and Apple's Combine framework for functional reactive programming, all with UIKit

iOS (Swift 5): MVVM test with Combine and UIKit MVVM and functional reactive programming (FRP) are very used in iOS development inside companies. Here

Koussaïla BEN MAMAR 2 Dec 31, 2021
USC's ITP342 iOS Development Swift Final Project

READMEBlogs USC's ITP342 iOS Development Swift Final Project NOTE: You'll need to attach your own Firebase to the app LINK TO APP ZIP FILE: https://dr

Connie Xu 0 Dec 8, 2021
USC's ITP342 iOS Development Swift Final Project

READMEBlogs USC's ITP342 iOS Development Swift Final Project NOTE: You'll need to attach your own Firebase to the app LINK TO APP ZIP FILE: https://dr

Connie Xu 0 Dec 8, 2021
Create a simple MVVM-C iOS architecture with Swift for starters

iOS-Architecture-MVVM MVVM+Coordinators IOS Architecture Tutorial By Bobby Pehtr

Mehrdad Ahmadian 0 Dec 30, 2021
NewsAppMVVM - A Swift iOS App created to practice MVVM Design Pattern

NewsAppMVVM A Swift iOS App created to practice MVVM Design Pattern. This app re

Jorge Roberto 1 Jan 3, 2022
Jared Watson 0 Jan 8, 2022