AVAudioPlayer停止播放音频

AVAudioPlayer停止播放音频

本文介绍了当iPhone进入睡眠状态时,AVAudioPlayer停止播放音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只要我的应用程序正在运行,我就需要一直播放背景声音。我试图将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"

每个类别的详细信息都列在

The details about each category are listed at "Audio Session Categories"

这篇关于当iPhone进入睡眠状态时,AVAudioPlayer停止播放音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 01:39