I am writing a simple Android game. I have trouble in playing a simple "game complete" sound effect, as soon as the game is finished (either won or lost), before there is the option to start a new game.
My source code is:
soundPool.play(complete, 1,1, 0, 0, 1);
soundPool.autoPause();
If I don't use autoPause()
the background music continues to loop, and I don't want that in the "Game Over" screen. As it is now, the "complete" sound doesn't play properly.
Any idea or help, etc. would be much appreciated.
You need to stop the background music, and get rid of autoPause.
Let's assume you started the background music loop like this:
int bg_music_loop = soundPool.play(BACKGROUND_MUSIC_ID, volume, volume, 1, 0, 1f);
Then you'd stop it using
soudPool.stop(bg_music_loop);
And then you can start your game-over sound:
soundPool.play(complete, 1,1, 0, 0, 1);