Please look at these code snippets:
private SoundPool soundPool; private int soundID; soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0); soundID = soundPool.load(this, R.raw.batimanbailedosenxutos, 1);
and when I click the button:
soundPool.play(soundID, volume, volume, 1, 0, 1f);
if I press this button twice at the same time, it plays the sound to switch, I want to stop the sound and play again if the user presses the button during playback
I tried to put
soundPool.stop(soundID);
in front of soundPool.play, but I donβt know why it only works for 1 time, when the song is playing, do you guys have any idea why this works only 1 time? and how can i solve this? thanks
source share