Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

swift picture in picture mode

Tags:

ios

swift

enter image description here

I am working on video player application and want to add Picture in Picture feature. I added this feature(using AVPictureInPictureController) and it works perfect, except one issue. After I click PiP button, PiP activated but application do not go to the home screen (picture attached). I need to push Home button. Ho to hide app and show home screen after PiP button tapped?

like image 340
Sergey Di Avatar asked Sep 05 '25 09:09

Sergey Di


2 Answers

Starting iOS 14.2, Apple has provided this API to start PIP without user intervention.

You can do it this way without getting your App rejected:

if #available(iOS 14.2, *) {                
    pictureInPictureController.canStartPictureInPictureAutomaticallyFromInline = true
}
like image 178
atulkhatri Avatar answered Sep 09 '25 03:09

atulkhatri


Not sure if this helps, but if you do this:

   func applicationDidEnterBackground(application: UIApplication) {

        pictureInPictureController.startPictureInPicture() 
    }

Then when a user presses the home button or switches apps, the video will go PIP. It's how NetFlix works.

like image 33
Jay Avatar answered Sep 09 '25 03:09

Jay