0

I am using soundpool or playing small size of sound but after sometime sound gets off i am getting error of AudioFlinger could not create track, status: -12 What is mean by this line . Anyone aware about this?

  soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
                    @Override
                    public void onLoadComplete(SoundPool sp, int sampleId, int status) {
                        soundPool.play(sampleId, 1.0f, 1.0f, 0, 0, 1.0f);
                    }
                });
                soundPool.load(GameActivity.this, R.raw.btn_click, 1);

Where i should add it.

1 Answers1

0

Release the soundpool before use it again.

if(soundPool != null)
{
   soundPool.release(); 
   // soundPool = null;
}
soundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
        @Override
        public void onLoadComplete(SoundPool sp, int sampleId, int status) {
            soundPool.play(sampleId, 1.0f, 1.0f, 0, 0, 1.0f);
        }
    });
soundPool.load(GameActivity.this, R.raw.hit_black_balloon, 1);
Andy Developer
  • 3,071
  • 1
  • 19
  • 39