Skip to content

Instantly share code, notes, and snippets.

@romyilano
Created February 14, 2013 20:09
Show Gist options
  • Select an option

  • Save romyilano/4955946 to your computer and use it in GitHub Desktop.

Select an option

Save romyilano/4955946 to your computer and use it in GitHub Desktop.
// here i register a MPMusicPlayerController object to the NSNotificationCenter
MPMusicPlayerController *musicPlayer =
[MPMusicPlayerController applicationMusicPlayer];
[musicPlayer setQueueWithItemCollection: userMediaItemCollection];
[musicPlayer beginGeneratingPlaybackNotifications];
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter
addObserver:self
selector:@selector(handleNowPlayingItemChanged:)
name:@"MPMusicPlayerControllerNowPlayingItemDidChangeNotification"
object:musicPlayer];
[notificationCenter
addObserver:self
selector:@selector(handlePlaybackStateChanged:)
name:@"MPMusicPlayerCOntrollerPlaybackStateDidChangeNotification"
object:musicPlayer];
[musicPlayer play];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment