问题
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?
回答1:
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];
}
来源:https://stackoverflow.com/questions/8854923/did-mpmusicplayercontroller-change-with-ios-5