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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en