Reputation: 48500
I have an AVPlayer that gets loads in a trivial fashion in my iOS 10 app:
let player = AVPlayer(url: url)
let controller = AVPlayerViewController()
controller.player = player
present(controller, animated: true) {
player.play()
}
This opens a player which occupies the entire frame of the window. I'd like to ideally be able to have the player take up only half my screen so on the bottom half I can add other content. I want to give the user the capability to enlarge the player to full screen, perhaps via an overlay/button that I frequently see:
What's the best way to not have my AVPlayer
take up the full screen? What documentation should I be reviewing?
Upvotes: 1
Views: 469
Reputation: 536047
Instead of calling present
, be a custom parent view controller and make the AVPlayerViewController your child view controller. Now, provided you do the correct parent–child dance, you can just set the frame
of the AVPlayerViewController's view and add it as a subview to your view. The view retains the ability for the user to send it into fullscreen mode (it will have the double-arrow button that you show in your screenshot).
Upvotes: 2