Используйте .setMaxStreams(int maxStreams)
внутри SoundPool.Builder()
метод.Как это работает на API 21 или выше, поэтому вам нужно установить условие.т.е.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // lollipop is constant for api 21
AudioAttributes audioAttributes = new AudioAttributes.Builder() // using instance of audio attributes
.setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) // different usage types, press CTRL+B & we get to it's declaration, and we see the description of usage types.
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.build();
soundPool = new SoundPool.Builder()
.setMaxStreams(10) // Sets the maximum of number of simultaneous streams
// that can be played simultaneously.
.setAudioAttributes(audioAttributes)
.build();
}
else{
soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
}