Play video fullscreen in landscape mode, when my entire application is in lock in portrait mode

前端 未结 4 2079
不思量自难忘°
不思量自难忘° 2021-01-03 03:07

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

4条回答
  •  春和景丽
    2021-01-03 03:30

    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;
      }
      

提交回复
热议问题