MehDi
MehDi

Reputation: 514

soundpool unable to load sample (null)

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);

Upvotes: 2

Views: 1596

Answers (3)

Hieu Vo
Hieu Vo

Reputation: 3274

You should check the file's mimetype, there are mimetypes which SoundPool doesn't support (for my case, it's audio/x-wave), there is only a simple log unable to load sound, without any explicit error message. Just switch to use common mimetypes (eg. audio/mpeg)

Upvotes: 0

MehDi
MehDi

Reputation: 514

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

Upvotes: 0

Juan Felippo
Juan Felippo

Reputation: 224

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

Upvotes: 1

Related Questions