I have looked everywhere about music on Android development. I have looked at the API but I didn’t understand it. This is my code:
Button b = (Button) findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
MediaPlayer mp = MediaPlayer.create(Main.this, R.raw.track1);
mp.start();
}
});
How I can change it so that when I press the same button again it stops it?
1 Answer