Why is my SoundPool disabled?

I configure my SoundPool and load an audio resource like this in onCreate() :

 soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0); soundId = soundPool.load(this, R.raw.edible_underwear, 1); 

And then I try to play this sound twice in onClick() , one slow mostly in the left speaker, and one fast mostly in the right speaker:

 soundPool.play(soundId, 0.9f, 0.1f, 0, -1, 0.7f); soundPool.play(soundId, 0.1f, 0.1f, 0, -1, 1.5f); 

No sound is heard. I looked for volumes, priorities and bids. Until now, to no avail. Am I missing something?

+3
android audio soundpool
Sep 08 '09 at 15:36
source share
1 answer

It turns out that SoundPool has two errors / limitations.

  • The sound volume is from 0.0f to, but not inclusive, 1.0f. Both 1.0f and 0.0f do not work, so you should limit the volume to 0.99f.
  • Loading samples into SoundPool that do not fit into ram will not result in an exception being thrown, and a soundId that can be checked for failure will not be returned. Therefore, you should look at your magazines and pray to the gods of Android so that your patterns match the target device.
+16
Sep 17 '09 at 10:26
source share



All Articles