Next/Previous buttons on iPhone MPMoviePlayerController

David Salzer picture David Salzer · Jul 16, 2009 · Viewed 10k times · Source

When using the MPMoviePlayerController, the play button is surrounded with "Next" and "Previous" buttons.

How do I get notifications when they are clicked? is there a way to feed MPMoviePlayerController with a list (array) of content?

Answer

Ransom Weaver picture Ransom Weaver · Jul 17, 2009

Nathan is correct about needing to implement your own UI for the player if you want button notifications. You can get notifications from the player about playback state though.

from the AddMusic example, where self is the controller or model containing the instance of MPMusicPlayerController:

- (void) registerForMediaPlayerNotifications {

    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];

    [notificationCenter addObserver: self
                           selector: @selector (handle_NowPlayingItemChanged:)
                               name: MPMusicPlayerControllerNowPlayingItemDidChangeNotification
                             object: musicPlayer];

    [notificationCenter addObserver: self
                           selector: @selector (handle_PlaybackStateChanged:)
                               name: MPMusicPlayerControllerPlaybackStateDidChangeNotification
                             object: musicPlayer];

    /*
     // This sample doesn't use libray change notifications; this code is here to show how
     //     it's done if you need it.
     [notificationCenter addObserver: self
     selector: @selector (handle_iPodLibraryChanged:)
     name: MPMediaLibraryDidChangeNotification
     object: musicPlayer];

     [[MPMediaLibrary defaultMediaLibrary] beginGeneratingLibraryChangeNotifications];
     */

    [musicPlayer beginGeneratingPlaybackNotifications];
}