MPMediaPickerController orientation on iPad
Asked Answered
A

3

8

How can I set correct orientation of MPMediaPickerController ?

I've return YES in shouldAutorotateToInterfaceOrientation, but i have bad frame for Landscape (if show MPMediaPickerController in Portrait first, and conversely).

I've rotating my device chaotically and sometime frame set to correct himself! I've find the method to set frame by rotating - need rotate to 180 degreess. For example, if you have good frame in Portrait, when you rotate to Landscape - you have bad frame (from Portatait), but if you rotate to other landscape (to 180 degreess), then frame set to Landscape... Why ?

How can i set the frame after rotation correct always ?

regards,

Arms answered 10/9, 2010 at 18:42 Comment(0)
D
3

Not sure whether you are interested in the solution or not, since you asked this in 2010. Anyway, after a few searches here is what I found:

  1. MPMediaPickerController DOES NOT SUPPORT LANDSCAPE ORIENTATION.

  2. In order to make the MPMediaPicker appear nicely in landscape orientation, we can make use of PopOverController. Basically, we create a pop over, and insert the picker into it. PopOverController, when displayed properly from the rootViewController, will indeed follow the orientation of the device.

Here is the rough code. It works, but needs some cleaning up. Probably best you check whether the popover is nil or not, otherwise it will just stack up on itself each time the user tap on the button.

- (IBAction)showMediaPicker:(id)sender
{

    MPMediaPickerController *mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeAny];

    mediaPicker.delegate = self;
    mediaPicker.allowsPickingMultipleItems = YES;
    mediaPicker.prompt = @"Select musics...";


    UIPopoverController *colorPickerPopover = [[[UIPopoverController alloc] 
                                    initWithContentViewController:mediaPicker] retain];               
    [colorPickerPopover presentPopoverFromBarButtonItem:sender 
                                    permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];    

}

A little more note: this IBAction is tied to a Toolbar Bar button.

Drove answered 28/6, 2012 at 6:24 Comment(0)
L
0

I'm simply pushing it onto my navigation controller:

MPMediaPickerController *mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeAny];

mediaPicker.delegate = self;
mediaPicker.allowsPickingMultipleItems = NO;
mediaPicker.prompt = @"Select songs...";

[[self navigationController]  pushViewController:mediaPicker animated:YES];

Granted this only works in the context of a navigation controller, but it works and is simple!

Lurid answered 26/12, 2012 at 1:6 Comment(0)
F
-1

here is some sample code you can try it one , after rotation you have to set media palyer view in center of self.view, here some sample code... you have to add MediaPlayer Framework at first....

NSString* moviePath = [[NSBundle mainBundle] pathForResource:@"PATRON_LOGO_3" ofType:@"mp4"];
NSURL* movieURL = [NSURL fileURLWithPath:moviePath];
 MPMoviePlayerController *playerCtrl =  [[MPMoviePlayerController alloc]initWithContentURL:movieURL];
playerCtrl.scalingMode = MPMovieScalingModeFill;
playerCtrl.controlStyle = MPMovieControlStyleNone;
[playerCtrl.view setCenter:CGPointMake(240, 160)];
[playerCtrl.view setTransform:CGAffineTransformMakeRotation(M_PI/2)];
playerCtrl.view.frame = CGRectMake(0, 0, 320, 480);
[self.view addSubview:playerCtrl.view];
[playerCtrl play];

i think it works fine , this is for landscape mode for portrait we have to set frame according to portrait frame like..

playerCtrl.view.frame = CGRectMake(0, 0, 480, 320);

after that we have to set to center of view.

Forestry answered 13/3, 2012 at 13:29 Comment(2)
This is irrelevant to the question. The question asks for MPMediaPickerController, not MPMoviePlayerController. They are 2 different things. And MPMediaPickerController does not have a transform property.Drove
@Rocotilos The picker may not, but the pickers view does, ex: MPMediaPickerController.view.transformCobber

© 2022 - 2024 — McMap. All rights reserved.