Did MPMusicPlayerController change with iOS 5?

自闭症网瘾萝莉.ら 提交于 2019-12-10 15:52:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!