I have a sound with 4 duration. I want to play continuously this sound by pressing down without stopping it, like piano keys when you pressing down, it plays a sound without looping or stopping.
c.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: // Button Pressed
soundPool.stop(SID1_c);
SID1_c = soundPool.play(sound_c, 1, 1, 1, 0, 0);
c.setBackgroundResource(R.drawable.key4);
return true;
case MotionEvent.ACTION_UP:// Button released
handler =new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
soundPool.stop(SID1_c);
}
},90);
return false;
}
return false;
}
});