MPMoviePlayerViewController orientation - iphone

I'm using cocos2d and i want to play a movie. For these purposes i've created MPMoviePlayerViewController and put it as a subview to [[CCDirector sharedDirector] openGLView]. The problem is that it appears in a vertical orientation.
In the application orientation is set to landscape:
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
How can i change the orientation of my player ?

Have a look at the cocos2d manual page about autorotation:
http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:autorotation
Basically you have to decide between two solutions:
Cocos2D handles orientation changes and you need to rotate the MPMoviePlayerViewController's view manually (e.g. using CGAffineTransformMakeRotation).
Cocos2D's opengl-view doesn't handle orientation changes and is inside a UIViewController that overrides shouldAutorotateToInterfaceOrientation and thus automatically rotates the view for you.

Related

How to handle UIImagePickerController overlay rotation in landscape?

You cannot subclass UIImagePickerController, but surely there is clean(not saying obvious or easy) way to keep camera feed as background of UIViewController and just make UIImagePickerController overlay to rotate like it would respond to shouldAutorotateToInterfaceOrientation: ?
I just want to UIImagePicker stay in its beloved portrait orientation, but I want rotate my UI buttons that I put into camera overlay. What I have now, is changing each element's orientation with CGAffineTransformMakeRotation() so it always stays at the same place, but rotates around each center.
I downloaded Layar app and the somehow achieved it... camera feed stays and UI buttons rotates (like UIViewController's style).
edit: I have to use iOS 5.1 and Xcode 4.2
edit2: for now I have this int DIRECTION and depending on what is the current orientation of the device I assign from 0 to 3, so I can decide with what angle to rotate all UI buttons. I do this inside shouldAutorotateToInterfaceOrientation: which is returning only YES for portrait and upside portrait.
You have to put constraints on the buttons and picker view.
Use this link to study AutoLayout concept by Ray Wenderlich
Hope this will help but you have to go through it thoroughly.

How to handle the rotation of mpmovie player object in iPhone?

I'm using a custom movie player in my application, its working fine.
But I'm stuck up with managing the rotation of the player, I want to rotate the player as the phone rotates, similar to the default nature of mpmovie player.
How can I control that?
Do the view controllers in the hierarchy above it support auto-rotation? By default, only portrait orientation is supported, but you can override shouldAutorotateToInterfaceOrientation: to specify others.

MPMoviePlayerController only rotate on fullscreen

I have a table view that contains an instance of MPMoviePlayerController as the table header and when the user presses my custom overlay button, the video expands to full screen. The aspect ratio of the video is such that in portrait mode it is very small, and I imagine most users will rotate to landscape.
The problem is that I want to allow rotation when the video is full screen but not when it exits. My underlying table does not support landscape. Is there a way to support rotation only when full screen? I thought this would be a standard component of MPMoviePlayerController.
I'm using SDK 5.0, but it was originally built with 4.3.
Have you tried subclassing the MPMoviePlayerController MPMoviePlayerViewController class, and overriding the method:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (!self.fullscreen) {
return UIDeviceOrientationIsPortrait(interfaceOrientation);
}
return YES;
}

Flip the iPhone screen with a button

how do I implement a button that will flip the screen 180deg for my game (if the user wishes to play it with the iPhone upside-down), and have it affect all of my 5 different views?
You should apply a transform to the parent view (your UIWindow). The rotation can be made using CGAffineTransformMakeRotation().
It might be better to actually allow the device orientation to cause the rotation though. In App settings set that the app supports autorotation and then in the UIViewController return tru to -(BOOL)shouldAutorotateToInterfaceOrientation when the rotation passed in is UIInterfaceOrientationPortraitUpsideDown
Look at shouldAutorotateToInterfaceOrientation. And maybe [myView setNeedsDisplay]; could help.
It sounds like you just want to use the build in automatic orientation rotation. You may need to tell your app in the build settings that it supports the upsidedown orientation and as dasdom mentioned you need to implement shouldAutorotateToInterfaceOrientation in all of your view controllers.
There is no way to force the phone into an orientation on-demand.
If you are looking to just rotate a view you can apply a CGAffineTransform.

iPhone UIImagePicker Camera in Landscape Orientation

Is there any good way to set UIImagePicker to landscape orientation? I tried to call setStatusBarOrientation after presentModalViewController like following,
[self presentModalViewController:picker animated:YES];
[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeRight animated: NO ];
However, the video duration view (00:00) on the right corner didn't rotate as orientation changed.
Unfortunately, according to the documentation, the image picker only supports portrait mode.
Apple doesn't support landscape for camera view. If you want anything shown as customised then add overlay view on it & transform that view to look as landscape view.
#Note:-overlay is also add as portrait thats why transformation needed.
I was able to create landscape camera view using the following code:
[self.view insertSubview:self.imagePicker.view atIndex:0];
self.imagePicker.view.transform =
CGAffineTransformScale (
CGAffineTransformTranslate(
CGAffineTransformMakeRotation(M_PI/2), -90, -15),
1.2,1.2)
;
Note that I am directly adding the imagePicker's view to the current view, not calling it as a modal.
self.imagePicker.view.transform seems to respond as expected to all CGAffineTransform function calls, though I can't speak to whether or not Apple approves of this method.