Reputation: 514
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
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
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
Reputation: 224
So the source of the problem may be, and should be discarded by order:
Upvotes: 1