I\'m trying to make a AVPlayerViewController go to full screen mode programmatically, coming from \"embedded\" mode, however this does not appear to be possible with the pub
For an 'embedded' AVPlayerViewController
instance, it is quite easy to programmatically have it start playback in full screen mode, and without hacking anything (calling private methods). You just need to set its entersFullScreenWhenPlaybackBegins
property to true.
You need to add the controller as a child VC to the main VC, and that's basically it. In viewDidAppear(_:)
you need to call play()
method on the controller's player
property - playback will be automatically started in fullscreen.
It's often best to check Apple sample code for these kind of tricky APIs; I think this one might be useful for a lot of AVPlayer use cases: Using AVKit in iOS.