MPMusicPlayerControllerNowPlayingItemDidChangeNotification not called?

Discussion in 'iOS Programming' started by Cdub16, May 22, 2010.

  1. Cdub16 macrumors member

    Joined:
    May 30, 2008
    #1
    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?
     
  2. CarlisleUnited macrumors 6502

    Joined:
    Jan 30, 2007
    Location:
    Nederland
    #2
    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.
     
  3. Cdub16 thread starter macrumors member

    Joined:
    May 30, 2008
    #3
    well would the ipod music player matter because this MPMusicPlayerController is an applicationMusicPlayer not an iPodMusicPlayer
     
  4. CarlisleUnited macrumors 6502

    Joined:
    Jan 30, 2007
    Location:
    Nederland
    #4
    It's a bug, these things happen in beta software. Try building you app in a 3.X environment and see if that clears things up. It did for me.
     

Share This Page