I answer to myself, JFTR:
For some reason SoundPool were unable to load a wav sample that in fact
works in every other player that I have used. So I simply ended using
another file with a different format. Here is the format of the
offending file, as told by mplayer on my GNU/LiNUX box:
|Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 96000 Hz, 1 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
|
And here it is the one for the other file that does work:
|Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 22050 Hz, 2 ch, s16le, 705.6 kbit/100.00% (ratio: 88200->88200)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
|
There are many differences, but the point is that the second works, so I
simply discarded the first one and move into the second. Knowing this if
I needed the first sound sample, I just need to adjust its rate and
channels with an audio editor like Audacity to solve the problem.
Why it did not just work in first case? Who knows, but if I can solve it
so easy... who cares at all?
On 30/05/12 19:21, Francisco M. Marzoa Alonso wrote:
> Hi there,
>
> I am facing an "Unable to load sample: (null)" error with the SoundPool,
> while trying to load a sample (not surprising, yeah?).
>
> I have discarded all common flaws that should raise that kind of error,
> so the file does exists (I can see it there), the file is readable
> (assets manager seems to read it with no problem), and the file is not
> corrupt (I can reproduce it with a wav player without problems).
>
> So I do not know what could be the cause of this error. Here is the code
> snippet:
>
> try {
> AssetFileDescriptor assetDescriptor = assets.openFd(filename);
> int soundId = soundPool.load(assetDescriptor, 0);
> return new AndroidSound(soundPool, soundId);
> } catch (IOException e) {
> throw new RuntimeException("Couldn't load sound '" +
> filename + "'");
> }
>
> assets is an AssetManager instance, and it loads pretty well other
> samples in the same directory. It does not raises an IOException, so it
> is pretty clear that the file is there and it is readable, but when
> executing the soundPool.load line, it complains with the error "Unable
> to load sample: (null)".
>
> Any ideas?
>
> Thanks a million,
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en