Skip to content Skip to sidebar Skip to footer

SoundPool Or MediaPlayer

I am making an android app that plays different sound files by clicking on different image buttons. The sound files will be 10 - 15 seconds max and I plan on having about 20 - 25 d

Solution 1:

Since SoundPool stores sounds uncompressed in memory for instant playback and performing pitch changing effects you should definitely go for MediaPlayer in your case. One reused MediaPlayer instance should be sufficient, unless you need to be able to play back multiple sounds simultaneously. In that case you can create a small pool of reusable MediaPlayer instances. Do not instantiate too many of them because they occupy audio track system resources which are limited to something like 30 as far as I recall.

In my last Android game I use both SoundPool for very short sound clips (~1 sec per clip) and a pool of 5 reusable MediaPlayer instances for longer ones. There is little noticeable playback latency with MediaPlayer.

You could also take that mixed approach. If your app has shorter sound clips that need instantaneous and repeated / simultaneous playback, you could load them into a SoundPool.


Post a Comment for "SoundPool Or MediaPlayer"