I'm trying to make the sound stop ringing when the user stops pressing (lift your finger) but it does not work, the sound goes on ...
Negra3.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
soundPool.play(sonido3, 1, 1, 0, 0, 0);
} else if (motionEvent.getAction()==MotionEvent.ACTION_UP)
soundPool.stop();
return false;
}
});
in the part of soundpool.stop();
the parentheses highlights me in red, so I put soundpool.stop(sonido3);
does not mark error but when running the stop does not work, but the sound continues long ... what should I do ?, I clarify that if I put soundpool.autopause();
if it works but it does not convince me :(