1
I’m creating an application that performs a sound or a song, but I can’t make the sound stop. This way I am forced to stop the application manually so that the sound stops. How can I stop the music by pressing a button?
The code I’m using is this:
public void repro(View view){
MediaPlayer mp = MediaPlayer.create(MainActivity.this, R.raw.som); mp.setOnCompletionListener(new OnCompletionListener() {
@Override public void onCompletion(MediaPlayer mp) {
mp.release(); }
}); mp.start();}
Hello Pablo, first thank you very much, your help was very important.
– jefferson
Following his guidelines I managed to add a "pause" button and the "stop" button, only the "pause" worked correctly, the problem was that when the sound was stopped using the "stop" button it was not possible to start the sound again, but there is no problem, with the "pause" button working is what matters.
– jefferson