You need to add MediaPlayer.framework to your target in Xcode and #import MediaPlayer / MediaPlayer.h
then
sort of
@property (nonatomic, retain) MPMusicPlayerController *musicPlayer;
...
self.musicPlayer = [MPMusicPlayerController iPodMusicPlayer];
then in viewDidLoad you need to register for the event
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self
selector:@selector(handleNowPlayingItemChanged:)
name:MPMusicPlayerControllerNowPlayingItemDidChangeNotification
object:self.musicPlayer];
implement handleNowPlayingItemChanged Now
When the current item is changed, you will receive a notification by calling this method
- (void)handleNowPlayingItemChanged:(id)notification {
MPMediaItem *currentItem = self.musicPlayer.nowPlayingItem;
source
share