我有一个viewController,包含以下方法:
- (IBAction) playMovie {
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"test" ofType:@"m4v"]];
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
moviePlayer.controlStyle = MPMovieControlStyleNone;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
}
由于错误,我无法编译代码:
未定义的符号:
"_MPMoviePlayerPlaybackDidFinishNotification", referenced from:
_MPMoviePlayerPlaybackDidFinishNotification$non_lazy_ptr in AnotherViewController.o
(maybe you meant: _MPMoviePlayerPlaybackDidFinishNotification$non_lazy_ptr)
"_OBJC_CLASS_$_MPMoviePlayerController", referenced from:
objc-class-ref-to-MPMoviePlayerController in AnotherViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
这条消息对我没有意义。
我打算将此方法用作视图控制器的一部分。我是否必须为播放器创建单独的视图控制器,或者情况并非如此?
我在创建此项目时使用SDK 3.1.2但是playMovie方法已根据新的API规则完全重写。当前的SDK版本是4.0.1
答案 0 :(得分:13)
您添加了MediaPlayer.framework框架?