Search code examples
objective-ciosmpmovieplayercontrollernsnotificationcenter

MPMoviePlayerViewController notifications


How to set notifications to MPMoviePlayerViewController? Is it the same as in MPMoviePlayerController?

Show example please


Solution

  • The MPMoviePlayerViewController is just a wrapper giving you controls to a MPMoviePlayerController.

    MPMoviePlayerViewController has its own MPMoviePlayerController that sends all the notifications you need to work with it.

    Listening to notifications is done as follows:

    // Register for the playback finished notification
    [[NSNotificationCenter defaultCenter] addObserver:self // the object listening / "observing" to the notification
        selector:@selector(myMovieFinishedCallback:) // method to call when the notification was pushed
        name:MPMoviePlayerPlaybackDidFinishNotification // notification the observer should listen to
        object:self.moviePlayerViewController.moviePlayer]; // the object that is passed to the method
    

    There are a lot more notifications you can and should work with that are listed in the MPMoviePlayerController Class Reference

    So basically, yes - You can use the same notifications as in MPMoviePlayerController