I'm using AVPlayerViewController
and have set canStartPictureInPictureAutomaticallyFromInline = true
which works as expected.
What i'd like to achieve, is if the app is opened whilst a video is in PiP mode, I want to automatically dismiss the PiP to put the video back into the AVPlayerViewController
, as currently the video stays in PiP and the in-app video player shows the PiP placeholder.
I can listen to the delegate callbacks in AVPlayerViewControllerDelegate
to know when PiP is active, but I can't figure out how to dismiss it.
AVPictureInPictureController
has a stopPictureInPicture()
function, but I don't know how to add an AVPictureInPictureController
to my player.
I use an AVPlayer
instance passed into the AVPlayerViewController
but from what i'm seeing, I need an AVPlayerLayer
to pass into AVPictureInPictureController
.
No, AVPlayerViewController
cannot fulfill your requirement because it does not expose its internally managed pictureInPictureController(AVPictureInPictureController)
to developers.
To achieve your goal, you would need to implement a custom solution by creating your own CustomPlayerViewController
and manually managing the pictureInPictureController(AVPictureInPictureController)
instance.