Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVPLayer + Fullscreen with custom player controls

Design :

ViewController : has a player view & a container vew.

Player View: loads the AVPlayer & has a subview(PlayerControlView) at the bottom of the player view to load the player controls (play/pause/progress bar/fullscreen etc..)

PlayerControlView: A custom UIView that has the player controls laid out.

I'm able to load the AVPlayer and player controls in normal mode(i.e. not fullscreen). Playback is fine and all the controls are working.

Problem:

I want the AVPlayer to go fullscreen when the user taps the fullscreen icon on the player controls. I'm able to make AVPlayer go fullscreen by changing the frame of the Player view and setting the Zposition of the AVPlayerLayer to 100.

Problem is the AVPlayer remains in fullscreen only when I do not make any updates to the playerControlView (i.e. progress bar/tapping play button etc). As soon as playback progress update is done on the slider, AVPlayer exits the fullscreen and comes back to normal mode.

Player controls are not repositioning to the bottom of the player view. They remain in their previous position itself. In normal mode, player control lays out properly on orientation changes.

Can someone please let me know if the approach I took is the right way to go? If not, please suggest the right design to take for implementing a fully functional player controls for AVPlayer.

Thanks in advance, Naveen

like image 624
Madala Avatar asked Mar 04 '15 16:03

Madala


1 Answers

you need to override viewWillLayoutSubviews methode in your player viewcontroller and update the frame of your playerview there

like image 135
MohyG Avatar answered Nov 15 '22 21:11

MohyG