views:

364

answers:

3

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

A: 

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];
priyanka
How would you do this for < iOS3.2?
Daniel Wood
A: 

just set frame MPMoviePlayerController view to landscape frame like what priya told above mpMCtr.view.frame = CGRectMake(0, 0, 1024, 768);
and your view-controller which is displaying movie must support Landscape orientation just like below

// Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{
// Return YES for supported orientations
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) ||
(interfaceOrientation == UIInterfaceOrientationLandscapeRight));

}

jeeva
A: 

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

3DPromax