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 protected], 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 protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]