QTMovie 无法在新窗口中播放
我有一个 MAC OSX 应用程序,我想在其中按主窗口中的按钮并打开一个播放电影的新窗口。这是我的 IBAction 代码;
- (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
出口。
窗口打开但没有播放电影;有人能理解我做错了什么吗?如果需要,我可以发送完整的项目(这是一个测试项目,非常小)。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将
NSError *error;
更改为NSError *error = nil;
Try changing
NSError *error;
toNSError *error = nil;