MPMoviePlayerController fullscreen in landscape mode in a portrait project - iphone

in my app i have selected only the portrait mode in the project setting:
and i use it in this way:
player = [[MPMoviePlayerController alloc] init];
[player setContentURL:videoURL];
[player play];
but when i display a video using MPMoviePlayerController in full screen and i try to rotate it, doens't rotate, and stay in portrait, there is a simple way without enable the landscape mode in the project setting, to active the landscape in fullscreen?

You have 2 options:
Enable landscape mode in the project settings and override supportedInterfaceOrientations for your view controllers.
In your app delegate, add the application:supportedInterfaceOrientationsForWindow: method and, when playing a movie, make sure that this returns UIInterfaceOrientationMaskAllButUpsideDown.

Related

UIWebView - YouTube Video Landscape mode - iOS6

I want to play a YouTube Video in a UIWebView in fullscreen (Landscape mode)
But all my other views to be only in Portrait mode. How is it possible that only the YouTube video is in landscape mode?
Do I have to enable the landscape mode in the app targets summary?
Thanks for help! :-)
If your app is using multiple orientations then you need to define them in the Project Target summary. e.g Portrait, Landscape left & Landscape right.
If you are having your device working for iOS5, use the following method(deprecated in iOS6) for rotating to particular orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
If you are having your device working on iOS6. you should use the following methods.
– shouldAutorotate – supportedInterfaceOrientations & – preferredInterfaceOrientationForPresentation
If your app supporting both versions then you could keep the both methods and check if your view controller is responding to the particular method by
if ([self respondsToSelector:#selector(methodToCheck)])
myTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
CGAffineTransform rotate = CGAffineTransformMakeRotation(1.57079633);
[myTableView setTransform:rotate];
self.view = myTableView;
This will also work*
make sure here i have done in tableview

Appliction orientation changes to landscape if I stop a video in landscape

I am working on an application in which I have embedded an iframe on a screen to show the thumbnail of a video from vimeo.com. Every thing is working perfect but when I tap to play the video it invokes iPhone's DEFAULT MOVIE PLAYER and then I rotate my iPhone to landscape and video plays in landscape mode. But if video finishes in landscape mode then the screen (on which I have added the vimeo iframe) also gets rotated in landscape mode. I need to fix it in portrait only but video should play in portrait and landscape both modes.
Thanks!
Put this method in your all view controller to force them to remain always in portrait mode
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
When we play a video in this way then iPhone's in built video player get invoked that is of class "mpinlinevideoviewcontroller". We can't control it's functionality. So I set
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}
in the view controller containing the web view and now only this screen of the application supports all orientation and thus my issue got removed (but not resolved).
one possible way is : When your player stopped playing just call this function.
-(void)setupOrientaion
{
[[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait];
}
or else post your code here. it 'll be more helpful to analyze.

MediaPlayerViewController rotates into view before play

My MediaPlayerViewController developed this funny thing of rotating into view! My whole app is landscape based, but the MediaPlayerViewController seems to rotate from portrait to landscape and when finished the previous view would then also rotate from portrait into its original landscape orientation. This will not happen in a small test app. Only when the app becomes complicated. I have tried preloading the movie, doesn't help, i have tried didRotatefromInterfaceOrientation, nothing. I have my supported orientations set and to return UIInterfaceOrientationIsLandscape. My code for the movie if that might help:
NSString *moviePath = [[NSBundle mainBundle] pathForResource:#"BearA-least" ofType:#"mov"];
NSURL *movieURL = [NSURL fileURLWithPath:moviePath];
MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
[self presentModalViewController:moviePlayer animated:NO];
moviePlayer.moviePlayer.controlStyle = MPMovieControlStyleNone;
[moviePlayer.moviePlayer play];
I'm new to developing and have been struggling with this problem for a while. Any input would be greatly appreciated. I've seen people having similar problems with views rotating.
As I see, you're using MediaPlayerViewController and presenting it using presentModalViewController
MoviePlayerViewControllers are usually displayed using [self presentMoviePlayerViewControllerAnimated:(PlayerViewController)]
As I can see, you're preventing your user from controlling the playback -> MPMovieControlStyleNone
Hint: You might also want to set the movieSourceType property on your MoviePlayerController.
For controlling the orientation in a way as you're trying to achieve, I would suggest you to subclass MPMoviePlayerViewController and listen for notifications sent by the MPMoviePlayer on the various movie playback events.

how do I play fullscreen landscape movie on iOS4 in a portrait application?

The problem is the following:
I have an application in which all viewcontrollers are portrait only 9typical tabbar/navigation app), but I would like to play a move in fullscreen landscape mode. This seems impossible in iOS4 ...
The best I could come up with was to add the mpmoviecontroller view to my parent view and rotate it by hand, but then there are 2 issues, the first being that i dont have the "Done" button, and that the user still has the possibility to press the "fullscreen" button making the view go portrait and completely wrong.
When using the [moviePlayer setFullscreen:YES animated:YES]; method it automatically sets the view in portrait and there is no way of rotating it.
any suggestions?
I don't remember where I found this, but you can subclass MPMoviePlayerViewController so its only support landscape orientations:
#interface CustomMPMovie : MPMoviePlayerViewController
#end
#implementation CustomMPMovie
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
#end
Hope it helps..
For full screen playback use MPMoviePlayerViewController and then to make it launch and play in landscape format use the "shouldAutorotateToInterfaceOrientation" method on the MPMoviePlayerViewController class.
It looks like this:
[yourInstanceOfMPMoviePlayerViewController shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationLandscapeRight];

iPhone Prevent application to automatically change orientation to portrait when a video stop

My application is in landscape mode and I use MPMoviePlayerController to play an sample video. It works fine but when I stop the video with the OK button (or if I wait until the movie ends), the orientation automatically changes to portrait.
Is it possible to keep application in landscape mode when the OK button is pushed ?
I use the followwing code in my main view controller to force landscape mode :
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
I think on the MPMoviePlayerPlaybackDidFinishNotification notification you have to set the statusbarorientation back to landscape.