Re: MPMoviePlayerController
Re: MPMoviePlayerController
- Subject: Re: MPMoviePlayerController
- From: Jeffrey Walton <email@hidden>
- Date: Sat, 16 Apr 2011 14:34:13 -0400
On Sat, Apr 16, 2011 at 12:39 PM, Matt Neuburg <email@hidden> wrote:
>
> 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;
> }
>
Hi Doctor,
With your changes, and the changes below, I was able to crash Xcode
(but the movie never played).
Apple appears to have serious problems with its MediaPlayer library
and its accompanying documentation. Its amazing it made t through QA
and was released for general consumption.
Jeff
// return a URL for the movie file in our bundle
-(NSURL *)localMovieURL
{
if (self.movieURL == nil)
{
// NSString *moviePath = [bundle pathForResource:@"Movie" ofType:@"m4v"];
NSString* path = [NSHomeDirectory()
stringByAppendingPathComponent:@"Documents"];
if(path)
{
NSString* moviePath = [path stringByAppendingPathComponent:@"02
Lost Verizon.m4v"];
if (moviePath)
{
self.movieURL = [NSURL fileURLWithPath:moviePath];
}
}
}
return self.movieURL;
}
_______________________________________________
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