0
我有一個MAC OSX應用程序,我想在主窗口中按下一個按鈕並打開一個播放電影的新窗口。這是我的IBAction
代碼;QTMovie not playing in new window
- (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是一個QTMovieViewer
outlet在新窗口中。
窗口打開但沒有播放電影;有人可以理解我做錯了什麼嗎?如果需要,我可以發送完整的項目(這是一個非常小的測試項目)。
沒有什麼變化,還是電影不玩。而且這部電影似乎在兩個版本的代碼中都正確加載;我可以在調試器中檢查它,它似乎沒問題。 – Paolo