• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: MPMoviePlayerController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MPMoviePlayerController


  • Subject: Re: MPMoviePlayerController
  • From: Matt Neuburg <email@hidden>
  • Date: Sat, 16 Apr 2011 09:39:19 -0700

On Apr 16, 2011, at 9:00 AM, Jeffrey Walton wrote:

>
> For what its worth, Apple's sample [1] is broken - it can't even play
> the movie it supplies with its sample.
>
> Jeff
>
> [1] http://developer.apple.com/library/ios/#samplecode/MoviePlayer_iPhone/Introduction/Intro.html

That's a well-known bug in the example. It has nothing to do with the movie. In fact, I used that same movie in the tests for my book (you can see in the screen shots in the discussion of MPMoviePlayerController).

The history appears to be that this was a Mac OS X example and was then made available for iOS, and the example has forgotten to compensate. The code says [self.moviePlayer play], but they've forgotten the most important step: add the MPMoviePlayerController's view to the interface. So in fact the movie *is* playing - you just can't see it because it isn't in the interface. (On Mac OS X I think the movie played in a different window, but of course there is no "different window" on iOS.)

It's easy to fix:

-(IBAction)playMovieButtonPressed:(id)sender
{
    MoviePlayerAppDelegate *appDelegate =
        (MoviePlayerAppDelegate *)[[UIApplication sharedApplication] delegate];
    [appDelegate initAndPlayMovie:[self localMovieURL]];
    UIView* v = [appDelegate moviePlayer].view;
    appDelegate.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
    v.frame = CGRectMake(54,39,205,135);
    [[sender superview] addSubview:v];
    return;
}

You could easily have found this out with Google; explanations of how to fix this example are plastered all over the Internet.

m.

PS. And of course, the chapter in my book about MPMoviePlayerController lays a lot of stress on your responsibility to put the darned view into the interface! :)

--
matt neuburg, phd = email@hidden, http://www.apeth.net/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
Programming iOS 4! http://www.apeth.net/matt/default.html#iosbook
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: MPMoviePlayerController
      • From: Jeffrey Walton <email@hidden>
    • Re: MPMoviePlayerController
      • From: Jeffrey Walton <email@hidden>
References: 
 >Re: MPMoviePlayerController (From: Matt Neuburg <email@hidden>)
 >Re: MPMoviePlayerController (From: Jeffrey Walton <email@hidden>)

  • Prev by Date: Re: Global Shortcuts
  • Next by Date: Re: MPMoviePlayerController
  • Previous by thread: Re: MPMoviePlayerController
  • Next by thread: Re: MPMoviePlayerController
  • Index(es):
    • Date
    • Thread