Question

I had an app which worked correctly in iOS 4.3, after upgrading to iOS 5 it behaves in another way.
After executing these lines on iOS 4.3 mp.playbackState is set to MPMusicPlaybackStatePaused, however in iOS 5 it is still set to MPMusicPlaybackStatePlaying.

MPMusicPlayerController *mp = [MPMusicPlayerController applicationMusicPlayer];
if(mp.playbackState == MPMusicPlaybackStatePlaying)
    [mp pause];

I assume that playbackState is not updated within the same event loop, is it ok?

Was it helpful?

Solution

I think the issue is:

MPMusicPlaybackState playbackState = [musicPlayer playbackState];

in iOS5 is not always correct.

This work for me:

if (!isPlay) 
{    
   isPlay = TRUE;
   [appPlayer play];
}
else 
{
   isPlay = FALSE;
   [appPlayer pause];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top