SoundPool repeating issue for Samsung Galaxy S3

Posted by Alaa Eldin on Stack Overflow See other posts from Stack Overflow or by Alaa Eldin
Published on 2012-09-09T12:19:11Z Indexed on 2012/09/10 9:38 UTC
Read the original article Hit count: 322

Filed under:
|
|

I'm trying to play a background sound for my application, I use SoundPool class, my problem is that, sound plays well only when I set the loop parameter with zero value, but it doesn't work for any other value.

My code for initialization is:

    soundpool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0);
    soundsMap = new HashMap<Integer, Integer>();
    soundsMap.put(1, soundpool.load(this, R.raw.soundfile_1, 1));
    soundsMap.put(2, soundpool.load(this, R.raw.soundfile_2, 1));

my code for playing is

 soundpool.play(1,  0.9f, 0.9f, 1, -1, 1f);

as I mentioned sound works when I put (0) instead of (-1) for the loop value, anyone has any idea why (-1) or any value other than (0) doesn't work (there is no output sound) ?

© Stack Overflow or respective owner

Related posts about java

Related posts about android