views:

82

answers:

2

I know there's a similar question MPMusicPlayerController stops sending notifications, but the answer to that question doesn't solve this problem.

I'm using iOS 4, and this happens on both multitasking-enabled devices and non-multitasking devices. I've tested on iPhone 4, iPhone 3GS, iPod touch 2G, and iPod touch 1G.

I have a project just for testing this problem. It uses MPMusicPlayerController to control iPod music playback, and gets notifications when the nowPlaying item changes, so it can update the artwork, artist, and title. It works fine when you first launch it. But if you do an iTunes sync, which I believe quits the iPod.app on the device, and return to my app, the app no longer gets notifications from the MPMusicPlayerController, so it doesn't update the Now Playing Item display.

The project also lets you select a playlist from your iPod library to start playing. It also stops working after sync. It still can get a list of playlists, but trying to queue them in the iPod music player doesn't do anything.

Releasing the old instance of MPMusicPlayerController doesn't work. Unregistering and re-registering for notifications doesn't work. It seems to be a problem with the IPC between the app and the iPod.app. The only way to fix it is to kill my app and relaunch it.

Anybody else having this problem?

A: 

I'd try re-setting the AVAudioSession category to AVAudioSessionCategorySoloAmbient and re-activating the session.

Art Gillespie
That doesn't work at all. It stops music playback completely, and worse, my app still doesn't get notifications or the ability to queue up a different playlist.
lucius
+2  A: 

I'm having the exact same problem and haven't been able to fix it properly, though I did come up with a temporary solution that's better than leaving my app stuck in an unusable state:

I call exit(0) in my handler for MPMediaLibraryDidChangeNotification, so at least my users won't be stuck unable to do anything wondering how to fix it.

David Patierno
The user would need to relaunch the app after it exits. It does solve the problem but in a rather inelegant way. I think the only real solution it is to file a Radar bug report with Apple and wait for them to fix it.
lucius
I just discovered this bug also occurs if the user is listening to music using bluetooth headphones, makes a phone call, changes the output source in the phone call from bluetooth to iPhone, and ends the call. My app will be unable to play music or set the play queue until either the app is force quit or the music is started again from iPod.app.
David Patierno
Correction: In this new scenario, I *am* able to set the play queue to resume playback, but sending `[musicPlayer play]` does not work. This issue may be unrelated.
David Patierno