In my ViewController i'm placing MPMoviePlayerController
to play video. It was working fine. It was able to play in full screen mode too. Now, i'm in need to play this movie in Landscape right and Landscape left also. How do i achieve this? And, the important note is my app will support only on Portrait mode. I just want to display this movie player in both directions. How do i do that? Any idea appreciable!
Here is my code -
-(void)playMovie
{
NSString *movieURL = ___;
NSURL *url = [NSURL URLWithString:movieURL];
player = [[MPMoviePlayerController alloc]initWithContentURL:url];
self._moviePlayer = player;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:_moviePlayer];
_moviePlayer.controlStyle = MPMovieControlStyleDefault;
_moviePlayer.shouldAutoplay = YES;
_moviePlayer.view.frame = CGRectMake(10, shortDesc.frame.origin.y+shortDesc.frame.size.height+10, 280,150);
[_moviePlayer play];
}
- (void) moviePlayBackDidFinish:(NSNotification*)notification
{
player = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:player];
if ([player respondsToSelector:@selector(setFullscreen:animated:)]) {
}
}
I have answered this here, with code: Change Orientation back to Portrait
You have an app that supports all orientations, a main view controller that only supports portrait, and a subclassed MPMoviePlayerController
that supports all orientations (or all, but upside down, or landscape only, or whatever you want...).