4

In iOS 14, when I set up an AVPlayerViewController, and set the player's delegate, if I press the home button on an iPhone, the delegate function playerViewControllerDidStartPictureInPicture gets called and I can see the PiP on the phone's home screen. However, in the same app, if I press the home button on an iPad, that delegate method does not get called, and PiP doesn't start.

Is there anything I could possibly be missing? Is there a way to programmatically activate PiP? The goal is to show PiP on iPad when the user presses the home button.

This is what the code looks like:

                let videoURL = URL(string: url)!
                let player = AVPlayer(url: videoURL)
                playerView = AVPlayerViewController()
                guard let playerView = playerView else { return }

                playerView.player = player
                playerView.delegate = self
                playerView.allowsPictureInPicturePlayback = true
Jay Strawn
  • 215
  • 3
  • 14
  • 2
    I fixed this by adding `playerView.canStartPictureInPictureAutomaticallyFromInline = true` – Jay Strawn Nov 11 '20 at 15:33
  • 1
    Thank you, it saved my day too. I think Apply should clarify this point. Otherwise, we can consider this as a kind of unintentional behavior of iOS on iPhones. – congnd Mar 24 '21 at 07:02
  • There was originally some bugs as well, see https://stackoverflow.com/questions/63739978/avpictureinpicturecontroller-doesnt-automatically-start-picture-in-picture-when/ – Claus Jørgensen Apr 28 '21 at 11:50

0 Answers0