Montaser El-sawy
Montaser El-sawy

Reputation: 830

MPMoviePlayerViewController rotate issue

I have a "VideoLecturesDetails" inside a tabbarcontroller, this class has this method

-(IBAction) playVideo{
    NSString *fileURL = [NSString stringWithFormat:@"%@" ,FileName];

    NSURL* videoURL = [NSURL URLWithString:fileURL];                
    MPMoviePlayerViewController* theMoviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:videoURL];
    [theMoviePlayer shouldAutorotate];
    [self presentMoviePlayerViewControllerAnimated:theMoviePlayer];
}

-(BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers {
    return NO;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
    return YES;//This allows all orientations, set it to whatever you want
}

so while playing the video the autorotate doesn't work , how can i enable autorotate by using this method.

Upvotes: 0

Views: 473

Answers (1)

NDM
NDM

Reputation: 944

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return YES;//This allows all orientations, set it to whatever you want

}

The above code is no longer available in IOS 6! you should keep it for user who use your app with IOS 5 or less.

In the IOS 6 you should implement the rotation as follow:

In the appDelegate: Use:

window.rootViewController = viewController

instead of:

[window addSubview:viewController.view];

and add:

- (NSUInteger) application:(UIApplication *)application 

supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return  UIInterfaceOrientationMaskAll;
}

This will happen every time you rotate.

and in your view controller yous should add the following:

-(BOOL)shouldAutorotate {

    return YES;
}
-(NSUInteger)supportedInterfaceOrientations {

        return UIInterfaceOrientationMaskAllButUpsideDown;
}

Upvotes: 1

Related Questions