PDA

View Full Version : Movie Controls Won't Show in iPad




newtoiphonesdk
Sep 15, 2012, 02:55 PM
In my app, the view I am writing about shows a movie that the user selected from the archive of saved videos.

The xib for this view simply has a view in it, and a MPMoviePlayerController is added as a subview.

In the iPhone version (which uses exact same code), you can tap the movie, and it will bring up the controls for pausing, AirPlay, and FullScreen, etc. Going fullscreen will allow it to be rotated.

In the iPad version, the controls never show, and it won't go full screen or rotate. If I point the code to simply pull up the iPhone class, it will show at top left at iPhone size in iPad, and then go fullscreen. Any suggestions? Here is my code (again, same on iPhone class and iPad class)

- (void)viewDidLoad {
AVAudioSession *audioSession = [AVAudioSession sharedInstance];

NSError *setCategoryError = nil;
[audioSession setCategory:AVAudioSessionCategoryPlayback error:&setCategoryError];
if (setCategoryError) { /* handle the error condition */ }

NSError *activationError = nil;
[audioSession setActive:YES error:&activationError];
if (activationError) { /* handle the error condition */ }
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *pdfPath = [documentsDirectory stringByAppendingPathComponent:selectedCountry];

NSURL *newURL = [[NSURL alloc] initFileURLWithPath: pdfPath];

self.player =

[[MPMoviePlayerController alloc] initWithContentURL: newURL];

[player prepareToPlay];

player.allowsAirPlay = YES;
player.scalingMode = MPMovieScalingModeAspectFit;
self.player.view.frame = self.view.frame;


[self.view addSubview: player.view];
[self.player setFullscreen:NO animated:YES];

[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];


[player play];


}