2010-08-12 49 views
3

我有含有下列方法的viewController:iPhone SDK 4:怪异编译错误,的MPMoviePlayerController

- (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

回答

13

您添加了MediaPlayer.framework框架?