soundpool unable to load sample (null)

1.5k Views Asked by At

I'm developing a game, when I wanna load some of sounds, I got this error ” soundpool unable to load sample (null) " (I see it in logcat and It doesn't throw any exceptions).

I googled it but can't find anything.

Any suggestion?thanks for your attention.

This is my code:

        SoundPool soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
        ObjSound = soundPool.load(context, R.raw.objs, 1);
2

There are 2 best solutions below

0
On

The problem was because of bad initialize and loading in memory. I'm was do that piece of code for all of my object ( I have 5 object with 9 same sound , so soundPool.load was repeated 45 times! ) although these sounds ain't high size and shouldn't get memory problem.

Still I don't know the source of problem.

But finally I fix this problem by define soundPool and all of ObjSound static,and init and load them only once in the start of game and use them over the project

0
On

So the source of the problem may be, and should be discarded by order:

  1. The file is not there.
  2. The file is there, but it is not readable for some reason.
  3. The file is there, and it is readable, but it is corrupt or not an audio file.
  4. The file is there, and it is readable, and it is a non corrupted audio file, but SoundPool dislikes it.
  5. Sometimes audios with high frequency just goes bad. Try one with lower frequency