AVAudioPlayer 从 Springboard 返回时跳过
我的应用程序期间不断播放音频。当我按下按钮返回 Springboard 然后恢复我的应用程序时,我出现了一些奇怪的行为。音频将继续播放,但每半秒左右就会跳过/切断。暂停和恢复音频似乎没有效果。
我正在使用 AVAudioPlayers 来播放我的音频。这是播放它们的代码...
player = [[AVAudioPlayer alloc] initWithData:data error:&err];
[player play];
player.numberOfLoops = loops;
mSimpleSoundList.push_back(player);
然后在“applicationWillResignActive”中我调用...
const uint32 size = mSimpleSoundList.size();
for(unsigned int i = 0; i < size; ++i) {
AVAudioPlayer* curElement = mSimpleSoundList.at(i);
[curElement pause];
}
然后是重新启动时的代码..
const uint32 size = mSimpleSoundList.size();
for(unsigned int i = 0; i < size; ++i) {
AVAudioPlayer* curElement = mSimpleSoundList.at(i);
[curElement play];
}
I have audio constantly playing during my application. I am having some odd behavior when I press the button to return to Springboard then resume my applications. The Audio will continue playing but will skip/cutout every half second or so. Pausing and resuming the audio seems to have no effect.
I am using AVAudioPlayers to play my Audio. Here is the code to play them...
player = [[AVAudioPlayer alloc] initWithData:data error:&err];
[player play];
player.numberOfLoops = loops;
mSimpleSoundList.push_back(player);
Then in the "applicationWillResignActive" I call...
const uint32 size = mSimpleSoundList.size();
for(unsigned int i = 0; i < size; ++i) {
AVAudioPlayer* curElement = mSimpleSoundList.at(i);
[curElement pause];
}
followed by this code on restart..
const uint32 size = mSimpleSoundList.size();
for(unsigned int i = 0; i < size; ++i) {
AVAudioPlayer* curElement = mSimpleSoundList.at(i);
[curElement play];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
结果是 AudioUnits 故障。
从 Springboard 返回后导致通用跳过的 AudioUnit
Turn out to be an AudioUnits fault.
AudioUnits causing universal skipping after returning from Springboard