Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First off, MPMoviePlayerController is a little different than MPMoviePlayer*View*Controller, so some of these answers lead to problems when converting applications that were built in an iOS 4.3+ environment.</p> <p>I've built some apps using MPMoviePlayerController that worked fine when built in iOS 3.2. When I rebuilt it with XCode 3.2.6, (iOS 4.3), the videos don't even play on the iPhone. I since fixed that by adding the MPMoviePlayerController instance to a subView, then presenting a modal (Player is a UIViewController) with the movplayer in fullScreenMode:</p> <pre><code>//from didSelectRowAtIndexPath Vid *selected = [items objectAtIndex:position]; player = [[Player alloc] init]; movplayer = [[MPMoviePlayerController alloc] initWithContentURL:selected.vidURL]; movplayer.view.frame = player.view.bounds; movplayer.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; [player.view addSubview:movplayer.view]; [self presentModalViewController:player animated:YES]; [movplayer setFullscreen:YES animated:NO]; [movplayer play]; [player release]; //movplayer is released inside - (void)exitedFullscreen:(NSNotification*)notification </code></pre> <p><strong>This was done on account of the UINavigationBar being half cut off when rotating</strong>.</p> <p>When I got to the iPad version of the app the modal option wouldn't work aesthetically. It was also having the UISplitViewController navBar and toolbars half cut off when rotating in full screen mode. So I tried implementing MPMoviePlayerViewController instead of MPMoviePlayerController. With this conversion, XCode gave me errors when trying to set: </p> <pre><code>movplayer.controlStyle = MPMovieControlStyleEmbedded; </code></pre> <p>The proper way to do this with a MPMoviePlayerViewController is:</p> <pre><code>movplayer.moviePlayer.controlStyle = MPMovieControlStyleEmbedded; </code></pre> <p>When the player is added as a subView, the pinch gestures will toggle the player between fullScreen and the size of your parentView (player.view.bounds) smoothly, as well as preserve the toolbars and navBars native to the parent.</p> <pre><code>//iPad version with a view (viewForMovie) inside the DetailViewController movplayer = [[MPMoviePlayerViewController alloc] initWithContentURL:[current vidURL]]; movplayer.moviePlayer.controlStyle = MPMovieControlStyleEmbedded; movplayer.view.backgroundColor = [UIColor clearColor]; movplayer.view.frame = viewForMovie.bounds; [viewForMovie addSubview:movplayer.view]; </code></pre> <p>So these two examples show some workarounds for those who want to convert their iPhone or iPad apps to a newer iOS version.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload