iOS 5 中 MPMusicPlayerController 发生了变化吗?

发布于 2024-12-27 01:31:02 字数 384 浏览 1 评论 0原文

我有一个应用程序在 iOS 4.3 中正常工作,升级到 iOS 5 后它的行为方式不同。
在 iOS 4.3 上执行这些行后,mp.playbackState 设置为 MPMusicPlaybackStatePaused,但在 iOS 5 中它仍然设置为 MPMusicPlaybackStatePlaying。

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

我假设playbackState 没有在同一事件循环内更新,可以吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜点 2025-01-03 01:31:02

我认为问题是:

MPMusicPlaybackState playbackState = [musicPlayer playbackState];

在iOS5中并不总是正确的。

这对我来说工作:

if (!isPlay) 
{    
   isPlay = TRUE;
   [appPlayer play];
}
else 
{
   isPlay = FALSE;
   [appPlayer pause];
}

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];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文