0

I have one query regarding orientation and play video,

My application support portrait mode but when i start any video it will run only landscape mode then after when video have completed it automatically come portrait mode.

Below of the code I'm using

**MyMovieViewController.h** 

#import <MediaPlayer/MediaPlayer.h>


@interface MyMovieViewController : MPMoviePlayerViewController

@end

**MyMovieViewController.m**

@implementation MyMovieViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{

    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeRight;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}

@end

But above of the code only working in iPhone 4.3 simulator and My application support 4.3 to 6.1.

So please can you help me out.

Guru
  • 21,652
  • 10
  • 63
  • 102
milanjansari
  • 1,529
  • 2
  • 21
  • 33
  • can you please tell what is actually you want?? you want only portrait mode or landscape mode??? – Kalyani Mar 21 '13 at 04:30
  • Apple changed their rotation methods in iOS6. You may wish to check out the documentation to see the new API methods and implement them. – bennythemink Mar 21 '13 at 04:41
  • I want to movie play only landscape mode. and when movie finished view comes up original orientation like portrait mode. – milanjansari Mar 21 '13 at 07:00

1 Answers1

0
-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeRight;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}

These few methods only return YES when your device is in landscape. Then it wont support portrait mode.

Horst
  • 1,733
  • 15
  • 20