简体   繁体   中英

SoundPool repeating issue for Samsung Galaxy S3

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) ?

The file size is probably too big for looping as has been reported here: http://www.talkandroid.com/android-forums/android-development-answers-tutorials-code-snippets/5132-soundpool-setloop-possible-bug.html

The file size seems pretty big for SoundPool in general, so maybe the sound clip should be cut into smaller clips and/or MediaPlayer used.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM