Re: QTMovie not playing in new window
Re: QTMovie not playing in new window
- Subject: Re: QTMovie not playing in new window
- From: Michael Babin <email@hidden>
- Date: Wed, 06 Jul 2011 07:18:12 -0500
On Jul 4, 2011, at 4:21 AM, Paolo Franzetti wrote:
> - (IBAction) playButtonClicked: (id) sender
> {
> MoviePlayerController *moviePlayerWindow = [[MoviePlayerController alloc] initWithWindowNibName:@"MoviePlayer"];
> [moviePlayerWindow showWindow:self];
>
> NSError *error;
> NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"sample_iTunes" ofType:@"mov"];
> QTMovie *movie = [QTMovie movieWithFile:moviePath error:&error];
> if (error) {
> NSLog(@"%@", [error localizedDescription]);
> } else {
> [movie gotoBeginning];
> [moviePlayerWindow.movieViewer setMovie:movie];
> [moviePlayerWindow.movieViewer play:nil];
> }
>
> }
>
> movieViewer is a QTMovieViewer outlet inside the new window.
In addition to Kyle's observations, I would also point out that your method of checking for failure in +[QTMovie movieWithFile:error:] is incorrect. The primary check for failure is the return value (did it return nil?). Only if it returns nil should you then pay any attention to the error value.
QTMovie *movie = [QTMovie movieWithFile:moviePath error:&error];
if (movie == nil) {
if (error) {
/* log or otherwise handle error */
}
}
else {
/* use movie */
}
_______________________________________________
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