I'm creating an application that plays a sound or a song, but I can not seem to stop it. This way I have to stop the application manually so the sound stops. How can I stop the music at the push of 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();}