I have searched StackOverflow and cannot find a situtation like mine. I am using four buttons with each button playing a sound file.
I am using SoundPool:SoundPool sound = new SoundPool(4, AudioManager.STREAM_MUSIC, 0);
I am also using the OnLoadCompleteListener()
which uses Log to create an I notification in LogCat.
When I launch the program in the emulator I see all four samples complete loading. During the program three of the sounds will play, however, one will always say:WARN/SoundPool(4842): sample 0 not READY
Any Ideas.. cause i'm quite flabbergasted. The sound files are 16-bit pcm wave file playing squarewave tones.
Load Code:
sound.setOnLoadCompleteListener(new OnLoadCompleteListener(){
@Override
public void onLoadComplete(SoundPool sound, int sampleId, int status) {
if(status != 0)
Log.e("SOUND LOAD"," Sound ID: " + sampleId + " Failed to load.");
else
Log.i("SOUND LOAD"," Sound ID: " + sampleId + " loaded.");
}
});
soundID[0] = sound.load(this, R.raw.greennote, 1);
soundID[1] = sound.load(this, R.raw.rednote, 1);
soundID[2] = sound.load(this, R.raw.yellownote, 1);
soundID[3] = sound.load(this, R.raw.bluenote, 1);
Play Sound:
streamid.setStreamId(myActivity.sound.play(id, 0.5f, 0.5f, 0, 0, 1));
I'm having the same issues. From my experiments, it looks like there's something wrong with the ID handling. SoundPool just doesn't like sound IDs with the number 0.
So I have found a work-around. Start my sample IDs with 1, not 0. Hope this works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With