只要我的应用程序正在运行,我就需要一直播放背景声音。我试图将AVAudioPlayer用于此目的。但是,一旦iPhone进入睡眠模式,它就会停止播放声音。
I need to play a background sound all the time as long as my application is running. I tried to use AVAudioPlayer for this purpose. However, it stops playing the sound as soon as the iPhone goes to sleep mode.
你能让我知道如何解决这个问题吗?
Could you let me know how can I fix this problem?
谢谢
推荐答案您可能需要设置音频会话类别。来自iPhone应用程序编程指南
You may need to set an audio session category. From the "iPhone Application Programming Guide"
类别是为$ b标识音频行为的键$ b申请。通过设置一个类别,你可以将你的音频意图表示为 iPhone OS,例如你的音频是否应该在屏幕锁定时继续。
A category is a key that identifies a set of audio behaviors for your application. By setting a category, you indicate your audio intentions to iPhone OS, such as whether your audio should continue when the screen locks.
每个类别的详细信息都列在音频会话类别
The details about each category are listed at "Audio Session Categories"
更多推荐
当iPhone进入睡眠状态时,AVAudioPlayer停止播放音频
发布评论