We’re talking about different issues here.
The Siri and lock-screen issues are/were real issues that appeared in iOS6, and appear to be fixed in iOS 6.1. I still haven’t been able to reproduce *those* audio issues in the 6.1 betas.
Your issue is completely different, and has to do with audio management. There are 2 problems with the code above:
- You’re loading audio upon every invocation of playSound()
- You’re using loadStream to play what I assume is a short audio effect.
1 comment) Audio should only be loaded once, and then reused. If you’re game requires different sound-sets in different levels, you should only load the sounds required for the current level in the beginning of game-play, and then unload those sounds when switching levels.
2 comment) loadStream should only be used for long sounds (think background music and narration) where you only have a few running at any one time during game-play. This is due to the fact that these audio-handles cannot be shared across multiple channels.
For shorter audio effects where you need multiple audio effects running at the same time you should use loadSound().
I could easily reproduce your issue in the Corona Simulator, as you mentioned.
The problem is not a Corona or Apple bug. In the terminal output after about 90 iterations you get the following error:
WARNING: Failed to create audio sound(loaded.wav)
, and the sound stops.
The issue was solved by moving one line of code.
-- main.lua
local text1
local count = 0
local click = audio.loadStream("loaded.wav")
function playSound()
count = count + 1
audio.play(click, {loops=0, channel=1 })
text1.text = "count: "..count
end
text1 = display.newText( "count: 0", 0, 0, native.systemFontBold, 34 )
text1:setTextColor( 255 )
text1:setReferencePoint( display.CenterReferencePoint )
text1.x, text1.y = display.contentWidth \* 0.5, display.contentHeight \* 0.5
timer.performWithDelay( 100, playSound, 0 )
Even though loadStream() handles is something that shouldn’t be used with short invocations like this, I moved the loadStream() out of playSound() so that it’s only loaded once. By doing that I haven’t had any problems in the Simulator even after 5000+ iterations.
I would still highly recommend using loadSound() in this kind of scenario. [import]uid: 70847 topic_id: 31242 reply_id: 135825[/import]