I want to play video in landscape mode in fullscreen. And my application is lock in portrait mode. How to implement this. Please help me. Thanks in advance
When on the main screen, under the orientation section, you will see a number of options like 'Auto-rotate OFF', 'Auto-rotate ON', 'Forced Portrait' and 'Forced Landscape'. As the names suggest, you can use these buttons as one-tap shortcuts to toggle the orientation of your device.
On the main screen of Rotation Manager, select an orientation by tapping on either the vertical or horizontal icons next to a specific app to lock it into either landscape or portrait mode. Highlighting both icons will allow that particular app to auto-rotate.
Simplest solution in swift 3 Add this to your app delegate:
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
if window == self.window {
return .portrait
} else {
return .allButUpsideDown
}
}
I've done this in on of my app. To do this you need to check that is your viewcontroller that where you want to play a video.
The first thing you have to do is check Device Orientation to Portrait,Landscape left, Landscape right in your project target
In your AppDelegate do the below code
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
UIStoryboard *mainStoryboard;
if (IS_IPHONE) {
mainStoryboard= [UIStoryboard storyboardWithName:@"Main" bundle: nil];
}
else{
mainStoryboard= [UIStoryboard storyboardWithName:@"Main_iPad" bundle: nil];
}
ViewControllerThatPlaysVideo *currentViewController= ViewControllerThatPlaysVideo*)[mainStoryboard instantiateViewControllerWithIdentifier:@"postDetailView"];
if(navigationController.visibleViewController isKindOfClass: [ViewControllerThatPlaysVideo class]]){
if([currentViewController playerState])
return UIInterfaceOrientationMaskLandscape|UIInterfaceOrientationMaskPortrait;
return UIInterfaceOrientationMaskPortrait;
}
return UIInterfaceOrientationMaskPortrait;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With