I searched soundpool posts and didn't find an answer. What I want to do is stop program activities like reading buttons in order to keep from re-triggering a soundpool sound. Is there a simple code to stop the program until a sound finishes?
Thank you, anyone who knows an answer.
B4X:
sub button_one_click 'example
sp.play(nameID,1,1,1,0,1)
' a VAR is incremented here,which shouldn't be allowed to be rapidly incremented by
'pressing the button that started this routine. Waiting for the sound to finish would discourage
' double or multiple clicking.
End Sub
There is no method within soundpool to do this, neither is there a method to tell you if it's still playing as there is with the media player.
The only way I can think of if you have to do this would be to disable the button for the duration of the sound using a timer, you'd have to know the length of the sound in advance.
If you want to stop all touches it may be easier to cover the app with a panel that has the clicks consumed (with empty click & longclick subs) and then use a timer set for the length of the sound to hide it again.
Thank you. You said there is no way with sound pool then went on to tell me a good way, with a timer. But maybe I should just play the sound with media-player if it would be easier. How do I do that?
I meant that there is nothing built into soundpool that would help. If you are playing lot's of sounds, SoundPool may still be easier but have a look at the Media Player it's simple enough to play a file, and has a _Complete method that will be called once the file has finished playing, check the documentation about initialize2.