AudioServices(简单)、AVAudioPlayer(中)、OpenAL(困难和过度杀伤力?)
我需要在整个 iPhone 应用程序中播放声音(每个声音大约 5 秒)。当他们被触发时,他们需要立即玩。
目前我正在使用 AudioServices,并且(正如您可能知道的那样)第一次播放声音时它会滞后,然后每次播放它都是完美的。是否有一些可用的代码足够聪明来预加载 AudioServices 声音(也许可以通过静默播放?)。我读过以编程方式调整系统音量将使您的应用程序被拒绝,所以这不是一个选择。从我看来,AudioServices 并不是为音量校正而设计的。
我研究过 OpenAL,虽然可行,但似乎有点过头了。 AVAudioPlayer 似乎是一个更好的选择,我目前正在使用它作为背景音乐。扩展我的音乐播放器以处理“音板”可能是我最后的手段。
关于 OpenAL 的话题,有谁知道哪里有一个像样的(应用商店友好的)iPhone 的 OpenAL 包装器?
提前致谢
I need to play sounds (~5 seconds each) throughout my iphone application. When they're triggered, they need to play immediately.
For the moment I'm using AudioServices and (as you probably know) the first time you play a sound it lags, then every time there after it's perfect. Is there some code available that's clever enough to preload an AudioServices sound (by playing it silently maybe?). I've read adjusting the system volume programmatically will get your app rejected, so that's not an option. Seems AudioServices isn't made for volume correction from what I can see.
I've looked into OpenAL and while feasible seems a little over kill. AVAudioPlayer seems like a little bit of a better option, I'm using that for background music at present. Extending my music player to handle a 'sound board' might be my last resort.
On the topic of OpenAL, does anyone know of a place with a decent (app store friendly) OpenAL wrapper for the iPhone?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Finch 可能非常适合您。它是 OpenAL 的一个小型包装器,具有非常低的延迟和简单的 API。另请参阅所有标记为“Finch”的问题。
Finch could be perfect for you. It’s a tiny wrapper around OpenAL with very low latency and simple API. See also all SO questions tagged ‘Finch’.
如果您使用 AVAudioPlayer,则可以在初始化对象时调用
prepareToPlay
以减少调用play
和音频开始之间的延迟。If you use an AVAudioPlayer, you can call
prepareToPlay
when you initialize the object to reduce the delay between callingplay
and having the audio start.