AudioTrack, SoundPool or MediaPlayer, which should I use?

SoundPool is actually an audio mixer. It can play short clips only, regardless of whether they are encoded as “ogg” or “mp3” or they are uncompressed. SoundPool always store them in memory uncompressed, and note that the limit is 1 MB. If your clip is too big in memory, SoundPool will fall silent and you’ll … Read more

Play sound using soundpool example

Create a folder named as raw under your_app/res/. Then paste your ringtone in this folder, for example your_app/res/raw/ringtone.mp3. Now use the following code: SoundPool soundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0); int soundId = soundPool.load(context, R.raw.ringtone, 1); // soundId for reuse later on soundPool.play(soundId, 1, 1, 0, 0, 1); Be sure to release the SoundPool resources … Read more