Search code examples
iosavfoundationfullscreenavplayeravplayerlayer

AVPlayer - toggle between fullscreen


I have a tableview where one of the cells houses a view on which AVPlayer renders a video. Works fine. What I'd like to do is allow the user to rotate the device and have the AVPlayer then render to another fullscreen view. Any pointers on how to do this?

I've successfully added the AVPlayer's CALayer as a sublayer to the fullscreen view, but as soon as I do that the AVPlayer stops playing and I cannot start it up again. I get no notifications regarding its state, and no errors.

I would appreciate any direction.


Solution

  • I managed to solve this by simply parenting the view (that contains the view with the AVPlayerLayer) to another full screen view and then rotating/scaling it to full screen. No need to worry about multiple AVPlayers etc as Matt mentions in his comments above.