如果我不处理音频中断会发生什么?
即使音频被中断,或者更准确地说:即使从操作系统以中断状态 kAudioSessionBeginInterruption 调用 MyInterruptionListener ,是否仍然可以播放声音/音乐?
是的,我知道这不是一个好主意。但还是想知道。
Is it possible to still play sound / music even if audio has been interrupted, or more precisely: even if MyInterruptionListener got called from the OS with the interruption state kAudioSessionBeginInterruption ?
Yeah I know that's not good idea to do. But want to know anyways.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您收到中断消息时,您一直在使用的音频资源已被关闭。
对于 AVAudioPlayer,播放将停止,直到您再次启动它。
对于 OpenAL,您的上下文将无效。所有 OpenAL 命令都将失败并出现错误,直到您清除当前上下文并将其再次设置为当前上下文。
对于音频单元,您的图表将处于无效状态。在您将图表设置为非活动状态然后再激活之前,不会播放任何声音。
我不知道如果您在收到中断启动消息后尝试再次启动音频资源会发生什么,但如果审阅者发现这种行为,至少您会在应用程序商店中被拒绝。
By the time you get an interrupt message, the audio resources you've been using have been shut down.
For AVAudioPlayer, playback will be stopped until you start it again.
For OpenAL, your context will be invalid. All OpenAL commands will fail with an error until you clear the current context and set it to current again.
For Audio Units, your graph will be in an invalid state. No sound will be played until you set the graph inactive and then active.
I don't know what would happen if you tried to start your audio resources again upon getting an interrupt start message, but at the very least you'd get rejected in the app store if the reviewers ever discovered this behavior.