Niall Mccormack
Niall Mccormack

Reputation: 1372

iPad MPMoviePlayerController - landscape video at launch

I'm having difficulty getting video to play in landscape at launch.

My app supports all interface orientations in the plist file. If I start a view controller at launch then the app loads in the correct orientation.

However if I start a video the orientation is fixed in portrait at startup.

How can I get around this? [UIApplication statusBarOrientation] always reports that the app is in portrait on launch so I don't really know what else I can do.

Cheers Niall

Upvotes: 0

Views: 2886

Answers (2)

priyanka
priyanka

Reputation: 2076

in .h file

MPMoviePlayerController *mpMCtr;

in .m file

    mpMCtr=[[MPMoviePlayerController alloc] initWithContentURL:ur];

    mpMCtr.fullscreen=YES;

    [mpMCtr setScalingMode:MPMovieScalingModeFill];

    [mpMCtr setShouldAutoplay:YES];

    [mpMCtr setControlStyle:MPMovieControlStyleNone];

    [mpMCtr setMovieSourceType:MPMovieSourceTypeFile];

    mpMCtr.view.frame = CGRectMake(0, 0, 1024, 768);

    [mpMCtr setRepeatMode:MPMovieRepeatModeNone];

    self.view = mpMCtr.view;

    [mpMCtr play];

    [ur release];

Upvotes: 2

3DPromax
3DPromax

Reputation: 11

in the .m file use this:

// Override to allow orientations other than the default portrait orientation.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
{
    if ((orientation == UIInterfaceOrientationPortrait) ||
        (orientation == UIInterfaceOrientationLandscapeLeft))
        return NO;

    return YES;
}

Upvotes: 1

Related Questions