Question

I am working on a iPad/iPhone app that displays a video on a button press. I have the video working however, my app is locked to portrait mode and I would like my video to display in Landscape only. Here is some code to go with my questions, I would like the easiest and simpliest way if its possible.

-(void) view_intro:(UIButton *)introButton {
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
               pathForResource:@"Introduction" ofType:@".m4v"]];
moviePlayer =  [[MPMoviePlayerController alloc]
                initWithContentURL:url];

[[NSNotificationCenter defaultCenter] addObserver:self
                selector:@selector(moviePlayBackDidFinish:)
                name:MPMoviePlayerPlaybackDidFinishNotification
                object:moviePlayer];

moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];}
Was it helpful?

Solution 2

Basically what I ended up doing was creating a seperate view/classes for my Movie Player, this seemed to have worked perfectly.

OTHER TIPS

I know it is painful in this situation. What I did is rotate the whole view. Give it a try.

    // First rotate the screen:
    [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;
    // Then rotate the view and re-align it:
    CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadians(-90));
    landscapeTransform = CGAffineTransformTranslate( landscapeTransform, -90.0, -90.0 );
    [self.view setTransform:landscapeTransform];

if your using fullscreen to show video in side viewcontroler then u got do some like this which i did n it worked well.

Make the viewcontroller support only landscape mode only.(checkout for landscape right or left). override the supportedInterfaceOrientions Check out below code

-(NSInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape ; }

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top