I setup my SoundPool
, and load a sound resource as 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 a onClick()
, one slow mostly in 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 can be heard. I have fiddled with the volumes, priorities and rates. So far to no avail. Am I missing something obvious?
Turns out that SoundPool
have two bugs/restrictions.
SoundPool
that do not fit in ram will not result in an exception being thrown, nor is there a soundId
returned that can be checked for failure. So you must look at your logs, and pray to the Android gods that your samples fit on the target device.