Giter Site home page Giter Site logo

insidegui / pipcontainer Goto Github PK

View Code? Open in Web Editor NEW
113.0 7.0 5.0 1.94 MB

An easy to use interface for picture-in-picture on macOS 10.12 and later

License: BSD 2-Clause "Simplified" License

Objective-C 88.27% Ruby 11.73%
pip picture-in-picture macos macos-sierra swift

pipcontainer's Introduction

PIPContainer

Carthage compatible CocoaPods

An NSViewController subclass that can present its child view controller in picture-in-picture mode.

Please note that this project links against PIP.framework, which is private. Don't try to submit apps using this to the App Store.

demo

Integration

Carthage

Add the following line to your Cartfile and follow the integration instructions for Carthage:

github "insidegui/PIPContainer" ~> 1.0

CocoaPods

Add the following line to your Podfile and then run pod install:

pod 'PIPContainer'

Manually

Drag PIPContainer.xcodeproj to your project and add PIPContainer.framework to the Embedded Binaries section.

manual integration

Usage

Containment

The way it works is you add the view controller you want to display in the PiP as a child view controller of PIPContainerViewController. This can all be done using storyboards (see demos).

storyboard containment

Entering and Exiting PiP mode

After you have the correct containment setup, simply call togglePIP on PIPContainerViewController to enter/exit PiP mode.

private var pip: PIPContainerViewController? {
    return parent as? PIPContainerViewController
}
    
func togglePictureInPictureMode() {
    pip?.togglePIP(nil)
}

You can also link UI controls like buttons and menus directly to the togglePIP action in Interface Builder by control-dragging to the First Responder and selecting the action togglePIP:.

Getting notified about PiP commands

PIPContainerViewController has many block properties that you can use to get notifications about state changes.

  • pipDidPause: Called when the pause button is pressed in the PiP panel
  • pipDidPlay: Called when the play button is pressed in the PiP panel
  • pipWillOpen: Called when the PiP panel is about to be opened. This is the best moment to set the isPlaying property of PIPContainerViewController to reflect the state of your player
  • pipWillClose: Called when the PiP panel is about to be closed
  • pipDidClose: Called after the PiP panel is closed and the view controller is back to its original position

Demos

I encourage you to have a look at the demos to get a better understanding of how PIPContainer works:

pipcontainer's People

Contributors

insidegui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.