Alex Rivera | Logout

Getting wrong playback state in MP Music Player Controller in ios 5

Asked 2012-04-12T06:47:20.327
8

i am getting wrong playback state in MP music player. while playing a song i am getting pause state. My app is working fine in ios 4.but i am having this issue in ios 5. can anybody Help me ??

My code is here.

[musicPlayer stop];
if (userMediaItemCollection)
{
   userMediaItemCollection=nil; 
}
musicPlayer.nowPlayingItem=nil;

userMediaItemCollection=[MPMediaItemCollection collectionWithItems:[mediaItemCollection    items]];

[musicPlayer setQueueWithItemCollection:userMediaItemCollection];
[musicPlayer setNowPlayingItem:    
[[userMediaItemCollectionitems]objectAtIndex:indexOfCurrentObject]];
[self enablePrevAndNextButtons];

[musicPlayer play];        
}

-(void)playbackStateDidChanged:(NSNotification *)notification
{

 if (musicPlayer.playbackState!=MPMusicPlaybackStatePlaying)
 {
    [playPauseButton setBackgroundImage:[UIImage imageNamed:@"play_iPad.png"] forState:UIControlStateNormal];
 }
 else if(musicPlayer.playbackState==MPMusicPlaybackStatePlaying)
 {
    [playPauseButton setBackgroundImage:[UIImage imageNamed:@"pause_iPad.png"] forState:UIControlStateNormal];
 }
Edit
Report

1 Answer

3

None of these workarounds fix the issue for my app. It is a bug in iOS, and my app will never function properly until Apple fixes it.

I have a music player with a play/pause button. When music is playing, the button shows the "pause" icon. When music is paused, the button shows the "play" icon - just like all music apps. I can replicate the bug at any time by doing the following: 1. Play music in my app (the play/pause button shows the "pause" icon correctly) 2. Background my app and lock my phone for ~10 minutes 3. Double tap home and hit the pause button from the iPod controls 4. Unlock my phone and open my app again 5. Music will be stopped, but my app still shows the "pause" icon when it should so "play"

I've done extensive debugging and logging to ensure that the method that updates my play/pause button is always called when my application becomes active. The issue is that when I re-enter my app, the playback state of MPMusicPlayer is still set to MPMusicPlaybackStatePlaying even when music is stopped/paused.

I filed a bug report for this about a year ago and haven't heard anything from Apple. If someone else would file one it would be greatly appreciated.

answered 2012-09-27T13:43:30.373

Your Answer