开发者

QTMovie not playing in new window

I have a MAC OSX application in which I would like to press a button in the main window开发者_如何学C 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.


Try changing NSError *error; to NSError *error = nil;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜