1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

QTMovie not playing in new window

Discussion in 'Mac Programming' started by paolomac, Jul 4, 2011.

  1. macrumors newbie

    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.

  2. macrumors 65816


    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?
  3. macrumors newbie

    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"?

  4. kainjow, Jul 4, 2011
    Last edited: Jul 4, 2011

    Moderator emeritus


    Double check that the outlets are setup properly (movieViewer).

Share This Page