Hi,
I have an educational app for children. In the app, i play a background sound track on a continuous loop. The sound track audio is declared as follows:
local function stListener(event) if event.completed then print("sound track stopped normally") else print("sound track forced to stop") end end local st = audio.loadSound ( "audio/soundTrack.mp3") audio.reserveChannels( 2 ) local stPlay = audio.play ( st, { channel=1, loops=-1, onComplete=stListener } )
As you can see, the channel the audio plays on is reserved and the audio is set to loop. Also, at no point do i call or use:
audio.stop()
to stop all audio. Nor do i call or use:
audio.stop(stPlay)
to stop the soundtrack.
However, there are two scenarios that force the audio to stop by itself and i would like to know if i can prevent that.
scenario 1 (happens sometimes):
If there are too many other audios played. For example, in the scene where this sound track is played, the child has the opportunity to tap different objects. If the correct object is tapped a certain audio is played (call it ‘correctAudio’). If the wrong object is tapped a ‘wrongAudio’ is played. Now if a child keeps tapping repetitively on different objects (as children tend to do), the ‘correctAudio’ and ‘wrongAudio’ will play many times (as many as the child taps) and thus, sometimes, forcing the background sound track to stop.
scenario 2 (happens always)
At the end of the above mentioned scene, when the child taps the correct sequence of objects, he/she is rewarded by a display of fireworks. I use Particle Candy to display fireworks. Whenever the fireworks start, the sound track is stopped.
Regarding scenario 2, i have searched the Particle Candy library to see if they explicitly call audio.stop() to stop all channels but they don’t. They only use audio.stop to stop emitter attached sounds and they pass the emitter sound handle to audio.stop().
Has anyone else faced a similar problem? Is there a way to protect a channel from being forced to stop? I am thinking that maybe (just guessing here) the audio is being stopped to free channels for other audios to play (this is my thinking regarding scenario 1). But who or what is stopping the audio? Aren’t reserved channels ‘reserved’ and you can’t use that channel unless you specify that particular channel number in audio.play? Another thought is that this could be a bug.
And by the way, the problem occurs on the device as well as the simulator (windows).
Does anyone have a solution? Is there a way to prevent an audio from being stopped?
Many thanks for your help.
Luay