IPhone SDK 4: strange compilation error, MPMoviePlayerController

I have a viewController containing the following method:

- (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];
}

I cannot compile the code due to an error:

Undefined characters:

  "_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

This message does not make sense to me.

I wanted to use this method as part of a view controller. Should I create a separate view controller for the player, or is it not?

I was working with SDK 3.1.2 when I created this project, but the playMovie method was completely rewritten in accordance with the new API rules. Current SDK 4.0.1 Version

+3
source share
1 answer

Have you added the MediaPlayer.framework framework?

+13
source

Source: https://habr.com/ru/post/1759252/


All Articles