Reputation: 727
I am using autolayout and in a screen I create AVPlayerViewController with half the size of main view. I am using UITabBarViewController and UINavigationController. This screen is navigated from first child ViewController of UITabBarViewController. Code is like this..
avPlayerVideoController = [[AVPlayerViewController alloc] init];
avPlayer = [AVPlayer playerWithURL:[NSURL URLWithString:videoURL]];
avPlayerVideoController.view.frame = CGRectMake( imgViewVideo.frame.origin.x, imgViewVideo.frame.origin.y, imgViewVideo.frame.size.width, imgViewVideo.frame.size.height);
avPlayerVideoController.delegate = self;
avPlayerVideoController.showsPlaybackControls = YES;
avPlayerVideoController.player = avPlayer;
[avPlayerVideoController.player play];
now I want the video to be rotated in landscape view when I click on that full screen button comes with AVPlayerViewController. It just remains in portrait orientation even I rotate my phone. And there is also no delegate method called when full screen button is tapped. Please I need this badly. Explain in detail how I should achieve this. Thank you
Upvotes: 4
Views: 4795
Reputation: 11
-(UIInterfaceOrientationMask)supportedInterfaceOrientations{
[avPlayerLayer removeFromSuperlayer];
[avPlayerLayer setFrame:self.view.bounds];
[self.view.layer addSublayer:avPlayerLayer];
return UIInterfaceOrientationMaskAllButUpsideDown;
}
Upvotes: 1
Reputation: 4043
add below code to your viewController
with contains AVPlayerViewController
-(BOOL)shouldAutorotate{
return YES;
}
-(UIInterfaceOrientationMask)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
Hope it Helps you.
Upvotes: 2