Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

paolomac

macrumors newbie
Original poster
Jul 4, 2011
2
0
Milano (Italy)
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;

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
 
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?
 
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
 
Double check that the outlets are setup properly (movieViewer).
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.