Search code examples
ios6mpmediaitem

Why is my MPMediaItem NowPlayingItem returning null?


I am incorporating the iPod player in my app. I am able to create a queue, then play the songs. I am not able to get the current song's property values. I have registered for the notifications and the log shows the notifications are bing triggered.

MPMediaItem *currentItem = self.musicPlayer.nowPlayingItem;
NSLog(@"currentItem = %@", currentItem);

Log output shows: currentItem = (null)

I'm running Xcode 4.5.2 iOS 6.0.

Any help is greatly appreciated.


Solution

  • For anyone else who may run into the same issue, the problem was that I synced my Music after running my application. You need to observe for Library changes:

    MPMediaLibraryDidChangeNotification
    
    [[MPMediaLibrary defaultLibrary] beginGeneratingLibraryChangeNotifications];