PDA

View Full Version : QTMovie not playing in new window




paolomac
Jul 4, 2011, 03:31 AM
I have a MAC OSX application in which I would like to press a button in the main window and open a new window in which a movie is played. This is my IBAction code;

- (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.

The window opens but no movie is played; can someone understand what I am doing wrong ? I can send the complete project (it is a test one, very small) if needed.

Thank you very much for any help.

Paolo



jiminaus
Jul 4, 2011, 08:00 AM
Because you didn't mention it I need to ask, are you getting a log message in the debug area or debugger console because movieWithFile:error: is failing? Is anything nil, include the result of moviePlayerWindow.movieViewer?

paolomac
Jul 4, 2011, 10:05 AM
I didn't get any error in movie loading; the movie seems to be properly loaded (I can see the structure properly populated into the debugger).

What do you mean by "include the result of moviePlayerWindow.movieViewer"?

Thanks

kainjow
Jul 4, 2011, 01:19 PM
Double check that the outlets are setup properly (movieViewer).