WARN / SoundPool Sample 2 NOT READY

SoundPool works correctly on Android 1.6, but when I run 2.1 in the emulator, I get the error โ€œsample 2 not READYโ€ every time I try to play the sound.

How to fix it?

+4
source share
3 answers

SoundPool on Android 2.0 and above only works with OGG Vorbis files. If you use MP3 or the like, they will not be decoded.

+3
source

On my device, wait a few seconds until the audio stream is ready.

Or use this, OnLoadCompleteListener : http://developer.android.com/reference/android/media/SoundPool.OnLoadCompleteListener.html

I can play ogg / wav / mp3 ...

SoundPool can create different decoders / players for each type of media.

+3
source

Here is the code

 public void loadSound (String strSound, int stream) { boolean loaded = false; mSoundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() { @Override public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { mSoundPool.play(stream, streamVolume, streamVolume, 1, LOOP_1_TIME, 1f); } }); try { stream= mSoundPool.load(aMan.openFd(strSound), 1); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } 
0
source

Source: https://habr.com/ru/post/1299098/


All Articles