I'm using MPMusicPlayerController and I have implemented skip track and previous track controls to control the music playback. When I reach the end of an album/playlist that is in the now playing list. The App no longer skips track nor goes previous track.

Example: First track of album, tap on previous track the app would stop responding and skip track/play/previous track will no longer respond.

Example: Last track of album, tap on previous track the app would stop responding and skip track/play/previous track will no longer respond.

I noticed on the iPod app itself, after it finishes a playlist it'll return to the playlist selection view or it'll return to the album selection view. What state is the MPMusicPlayerController in at this point of time? How can I use it to launch the iPod app when I encounter such a state within my App?

http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPMusicPlayerController_ClassReference/Reference/Reference.html

2

There are 2 best solutions below

0
On

Based on my experience, the state becomes MPMusicPlaybackStateStopped In this state, playlist is actually gone, and needs to be update by playing iPod Music player again. You may use MPMusicPlayerControllerPlaybackStateDidChangeNotification to evaluate the condition of the player and do the action of your choice. Notification Programming Topics: http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/Notifications/Introduction/introNotifications.html#//apple_ref/doc/uid/10000043i

0
On

I've found that if repeatMode is set to MPMusicRepeatModeAll, next track will go back to the first item in the playlist. I think previous will still do nothing.

So, use notifications as described above, or set repeatMode to prevent this from happening.