QTMovie not playing in new window

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

  1. macrumors newbie

    Joined:
    Jul 4, 2011
    Location:
    Milano (Italy)
    #1
    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
     
  2. macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #2
    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. thread starter macrumors newbie

    Joined:
    Jul 4, 2011
    Location:
    Milano (Italy)
    #3
    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
     
  4. kainjow, Jul 4, 2011
    Last edited: Jul 4, 2011

    Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    Double check that the outlets are setup properly (movieViewer).
     

Share This Page