I'm working on a game in which one single sound is played each time the phone is shaked. Does it make sense to use a SoundPool and load sounds in the onCreate of my activity, or is it ok to create a mediaplayer each time, as shown below:
private void onShake() {
MediaPlayer mp= MediaPlayer.create(this, whipSound[currentWhip][force]);
mp.start();
}
My guess is that SoundPool is better because the sounds are loaded only once. Am I right?
Thanks
Julien
You can create the mediaPlayer outside the
onShake
method, and then reset and start it on every shake:As expected, SoundPool is much faster...