All Projects → Sweefties → iOS9-NewAPI-iPad-Multitasking-PIP-Example

Sweefties / iOS9-NewAPI-iPad-Multitasking-PIP-Example

Licence: other
iOS 9 Experiments - New API Components - Multitasking on iPad with Picture-in-Picture (PiP).

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to iOS9-NewAPI-iPad-Multitasking-PIP-Example

Ios
OwnTracks' iPhone App
Stars: ✭ 222 (+1485.71%)
Mutual labels:  ipad
Shigureader
用Chrome或者iPad轻松阅读整理漫画,播放音乐,以及观看视频. All-in-one solution for local doujin/anime/music file.
Stars: ✭ 254 (+1714.29%)
Mutual labels:  ipad
YMTGetDeviceName
Get device name from model number
Stars: ✭ 27 (+92.86%)
Mutual labels:  ipad
Uicollectionviewsplitlayout
UICollectionViewSplitLayout makes collection view more responsive.
Stars: ✭ 226 (+1514.29%)
Mutual labels:  ipad
Ios
IRCCloud iOS App
Stars: ✭ 243 (+1635.71%)
Mutual labels:  ipad
SwiftyJot
Use your finger to annotate images.
Stars: ✭ 14 (+0%)
Mutual labels:  ipad
Stpopuppreview
An alternative peek preview for non 3D Touch devices. Inspired by Instagram.
Stars: ✭ 202 (+1342.86%)
Mutual labels:  ipad
amazon-safari-pip-mode
Start Amazon instant video in Safari and use Picture in Picture Mode.
Stars: ✭ 41 (+192.86%)
Mutual labels:  picture-in-picture
Chipagecontrol
A set of cool animated page controls written in Swift to replace boring UIPageControl. Mady by @ChiliLabs - https://chililabs.io
Stars: ✭ 2,909 (+20678.57%)
Mutual labels:  ipad
iOSShortcuts
A collection of shortcuts for the Shortcuts app.
Stars: ✭ 60 (+328.57%)
Mutual labels:  ipad
Nike Collection
A Nike collection items style app
Stars: ✭ 228 (+1528.57%)
Mutual labels:  ipad
Xkcd Open Source
A free and open source xkcd comic reader for iOS.
Stars: ✭ 243 (+1635.71%)
Mutual labels:  ipad
Shukofukurou-iOS
The Ultimate Open Source AniList, Kitsu, and MyAnimeList Tracker for iOS/iPadOS written in Objective-C
Stars: ✭ 29 (+107.14%)
Mutual labels:  ipad
Stpopup
STPopup provides STPopupController, which works just like UINavigationController in popup style, for both iPhone and iPad. It's written in Objective-C and compatible with Swift.
Stars: ✭ 2,517 (+17878.57%)
Mutual labels:  ipad
spiro
Swift Playgrounds 4 app created on the iPad
Stars: ✭ 48 (+242.86%)
Mutual labels:  ipad
Hls Vod
HTTP Live Streaming with on-the-fly encoding of any video file for Web/Apple TV/iPhone/iPad/iPod
Stars: ✭ 221 (+1478.57%)
Mutual labels:  ipad
SignTools-CI
Sign iOS apps on demand using CI. Part of: https://github.com/SignTools/SignTools
Stars: ✭ 145 (+935.71%)
Mutual labels:  ipad
KeyCommandAlertController
UIAlertController wrapper to add keyboard shortcuts easily
Stars: ✭ 16 (+14.29%)
Mutual labels:  ipad
iPatch
Patch iPA Files With Dynamic Libraries
Stars: ✭ 29 (+107.14%)
Mutual labels:  ipad
iPad Swift Playgrounds
Converted iPad Swift Playgroundbooks into Playgrounds so that the people who don't have an iPad can run a Swift Playgroundbook in macOS.
Stars: ✭ 24 (+71.43%)
Mutual labels:  ipad

iOS 9 - New API - iPad Multitasking - PiP Example

iOS 9~ Experiments - New API Components - Multitasking on iPad with Picture-in-Picture (PiP).

Example

Requirements

  • = XCode 8.0.

  • = Swift 3.

  • = iOS 9.0.

  • = iPad Mini 3 / 4, iPad Air / Air 2, iPad Pro

Tested on iOS 9.1 Simulators. 50%

Important

this is the Xcode 8 / Swift updated project.

Sources

WWDC 2015 Sessions from : WWDC 2015 Videos Jamie XX - Loud Places (feat. Romy) from : youtube.com

App Transport Security Settings

To support HTTP hosted : add the Boolean type Value to YES for NSAllowsArbitraryLoads in app's info.plist file.

Usage

  • To run the example project, download or clone the repo.
  • MULTITASKING RECOMMANDATIONS : Perform and prepare your app to avoid memory leaks and others with Instruments!
  • IN USE OF AVPictureInPictureController , use : AVPictureInPictureController.isPictureInPictureSupported() to get devices capability

Example Code!

  • Set your AVPlayer, AVPlayerViewController or AVPlayerLayer in one controller to play video!
  • Add AVKit + AVFoundation Frameworks
import AVKit
import AVFoundation
  • Set AVAudioSession in didFinishLaunchingWithOptions UIApplication Delegate
/// REQUIRED FOR PIP!!!
/// After active Audio/Airplay Background Mode in General Settings.
/// Setup Audio Session for Picture in Picture
let audioSession = AVAudioSession.sharedInstance()

do {
    try audioSession.setCategory(AVAudioSessionCategoryPlayback)
}
catch {
    print("handle errors setting Audio session Category")
}
  • Delegate your controller with AVPlayerViewControllerDelegate Extension
extension ViewController : AVPlayerViewControllerDelegate {

    /// playerViewController will start PIP
    func playerViewControllerWillStartPictureInPicture(playerViewController: AVPlayerViewController) {
        print("PIP will start")
    }

    /// playerViewController did start PIP
    func playerViewControllerDidStartPictureInPicture(playerViewController: AVPlayerViewController) {
        print("PIP did start")
    }

    /// playerViewController will stop PIP
    func playerViewControllerWillStopPictureInPicture(playerViewController: AVPlayerViewController) {
        print("PIP will stop")
    }

    /// playerViewController did stop PIP
    func playerViewControllerDidStopPictureInPicture(playerViewController: AVPlayerViewController) {
        print("PIP did stop")
    }

    /// playerViewController failed to start PIP
    func playerViewController(playerViewController: AVPlayerViewController, failedToStartPictureInPictureWithError error: NSError) {
        print("PIP Error : \(error.localizedDescription)")
    }

    /// playerViewController automatically dismiss at PIP Start.
    func playerViewControllerShouldAutomaticallyDismissAtPictureInPictureStart(playerViewController: AVPlayerViewController) -> Bool {
        return false
    }

    /// playerViewController restore Interface For PIP
    func playerViewController(playerViewController: AVPlayerViewController, restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: (Bool) -> Void) {

    // if topView and navigation controller :
        if let topViewController = navigationController?.topViewController {
            topViewController.presentViewController(playerViewController, animated: true) {
                print("ready detailvc restore presentViewController")
                completionHandler(true)
            }
        }
        else {
            completionHandler(false)
        }
    }
}

Build and Run! Switch to Home or another App in your simulator or devices and test!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].