FYI ... MediaPlayer looping isn't entirely 'stable'. See: http://code.google.com/p/android/issues/detail?id=18756
On Monday, June 11, 2012 2:35:14 AM UTC-4, Tamás Kovács wrote: > > Sorry I don't have time to read your code. But in the past, I also had > issues, when I needed to loop soundpool sounds that were stopped() > before they needed to play again (in looped mode). > > If you can't find a solution, I can think of two alternatives: > 1. Implement manual looping: not too elegant and accurate, but 'guess' > when you playback has ended, and then start the same sound again > 2. Use MediaPlayer, it is stable in looping > > > On Jun 11, 5:51 am, krishna kumar <send2mess...@gmail.com> wrote: > > package my.app.exp5; > > > > import java.util.HashMap; > > > > import android.content.Context; > > import android.media.AudioManager; > > import android.media.SoundPool; > > import android.util.Log; > > > > public class SoundEffects { > > public boolean released=false; > > protected Context context; > > private SoundPool soundPool; > > private int volume; > > private HashMap<Integer, Integer> soundPoolMap; > > > > protected SoundEffects(Context context) { > > this.context=context; > > > > soundPool=new SoundPool(20, AudioManager.STREAM_MUSIC, 40); > > > > soundPoolMap = new HashMap<Integer, Integer>(); > > > > AudioManager mgr=(AudioManager)context.getSystemService > > (Context.AUDIO_SERVICE); > > > > volume=mgr.getStreamVolume(AudioManager.STREAM_MUSIC); > > } > > > > /* > > public boolean isLoaded() { > > soundPool. > > } > > */ > > > > public void addSound(int resid) { > > int soundId=soundPool.load(context, resid, 1); > > soundPoolMap.put(resid, soundId); > > soundPool.setLoop(soundId, 1); > > } > > > > public void addLoopSound(int resid) { > > int soundId=soundPool.load(context, resid, 1); > > soundPoolMap.put(resid, soundId); > > soundPool.setLoop(soundId, -1); > > } > > > > public void play(int resid) { > > Log.i("SoundEffects", "Playing: "+resid); > > int soundId=soundPoolMap.get(resid); > > soundPool.setLoop(soundId, 1); > > soundPool.play(soundId, volume, volume, 1, 0, 1f); > > } > > > > public void playLoop(int resid) { > > int soundId=soundPoolMap.get(resid); > > soundPool.setLoop(soundId, -1); > > soundPool.play(soundId, volume, volume, 1, -1, 1f); // > here > > loop -1 is not working .... > > } > > > > public void stop(int resid) { > > soundPool.stop(resid); > > > > int soundId=soundPoolMap.get(resid); > > soundPool.setLoop(soundId, 0); > > soundPool.setVolume(soundId, 0f, 0f); > > } > > > > public void release() { > > released=true; > > soundPool.release(); > > } > > > > public void autoPause(int resid) > > { > > soundPool.autoPause(); > > } > > > > } > > > > Looping function not working please anybody help .....it's urgent -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en