Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Cdub16

macrumors member
Original poster
May 30, 2008
32
0
i have a MPMusicPlayerController and i want it to send a notification when the now playing item changes.

i declare the notification in my view did load:

Code:
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
	
	[notificationCenter addObserver: self
						   selector: @selector (handle_NowPlayingItemChanged:)
							   name: MPMusicPlayerControllerNowPlayingItemDidChangeNotification
							 object: player];
	
	[player beginGeneratingPlaybackNotifications];


and i have a "handle_NowPlayingItemChanged" method where i change the image view to accommodate the album cover for the new song:

Code:
- (void) handle_NowPlayingItemChanged: (id) notification {
	NSLog(@"Handle Method Called");
	MPMediaItem *currentItem = [player nowPlayingItem];
	
	MPMediaItemArtwork *artwork = [currentItem valueForProperty: MPMediaItemPropertyArtwork];
	
	if(artwork){
		imageView.image = [artwork imageWithSize:imageView.frame.size];
		
	}
}

but when the song changes in my player, the Handle Method is not called and the image view does not change, it just plays the next song.
what is wrong?
 
I have noticed that it is called when I skip to the next item but not when a song completes. What SDK are you using?

*edit* Just noticed it those notifications do get sent when the iPod Player isn't running, try rebooting your phone and then launch your app without launching the iPod Music Player.
 
well would the ipod music player matter because this MPMusicPlayerController is an applicationMusicPlayer not an iPodMusicPlayer
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.