当用户在 iOS 5 上锁定屏幕时 applicationMusicPlayer 停止

发布于 2024-12-07 21:26:40 字数 167 浏览 2 评论 0原文

我将音频会话类别设置为 kAudioSessionCategory_MediaPlayback,激活该会话,该会话没有返回任何错误,并且当我锁定设备时 iPod 音乐仍然停止。这发生在 iOS 5 GM 上,所以我猜这会发生在最终版本中。在 iOS 4+ 上,当前代码运行良好。有什么想法如何解决这个问题吗?非常感谢:)

I set the audio session category to kAudioSessionCategory_MediaPlayback, I active the session, which returns no errors, and still the iPod music stops when I lock the device. This happens on iOS 5 GM, so I guess this will happen in the final version. On iOS 4+ the current code works fine. Any ideas how to fix this? Huge thanks :)

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

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

发布评论

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

评论(2

失眠症患者 2024-12-14 21:26:40

这不是一个错误。为了节省电量,锁定手机现在被视为用户按下了主页按钮。事实上,applicationMusicPlayer 现在在锁定时会停止,这只是此更改的副作用。

要解决此问题,您应该切换到 AVPlayer 并在后台模式下使用 iOS 4 的音频。

It's not a bug. To save power locking the phone is now treated as if the user pressed the home button. The fact that applicationMusicPlayer stops now when locking is just a side effect of this change.

To work around this problem you should switch to AVPlayer and make use iOS 4's audio in background mode.

泡沫很甜 2024-12-14 21:26:40

针对我的特定问题修复了此问题 - 当设备进入锁定屏幕时如何检测 OS4 和 OS5 行为之间的差异。

在 OS4 中,应用程序会执行“applicationWillResignActive”,但在 OS5 上,它会一直执行“applicationDidEnterBackground”,这看起来与用户点击“Home”按钮完全相同。

事实证明,如果您检查 '- (void)applicationDidEnterBackground:(UIApplication *)application' 中给出的应用程序的 UIApplicationState,它有 3 个可能的值:

typedef enum {
   UIApplicationStateActive,
   UIApplicationStateInactive,
   UIApplicationStateBackground
} UIApplicationState;

当用户在 OS5 上点击 home 时,您会得到 UIApplicationStateBackground,但是当用户点击 Lock,你会得到 UIApplicationStateInactive。

希望有帮助。

祝大家节日快乐。

Fixed this issue for my particular problem - how to detect the difference between OS4 and OS5 behavior when device gets to the Lock screen.

In OS4 app does 'applicationWillResignActive' but on OS5 it goes all the way to 'applicationDidEnterBackground' which looks exactly the same as the user hitting the Home button.

It turns out that if you check the UIApplicationState of the application given in '- (void)applicationDidEnterBackground:(UIApplication *)application', it has 3 possible values:

typedef enum {
   UIApplicationStateActive,
   UIApplicationStateInactive,
   UIApplicationStateBackground
} UIApplicationState;

When the user hits home on OS5, you get UIApplicationStateBackground, but when the user hits Lock, you get UIApplicationStateInactive.

Hope that helps.

Happy Holidays everyone.

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