I'm making a small android app like image below:
I have a sound button. All I want is background music will play across all activity and when I click on sound button, music will stop. Or click to play music again.
I dont know how to make it. PLease help me! or give me link to refer.
I'd gladly appreciate your help it Thanks!
Hi please Follow below steps
MediaPlayer mediaPlayer = MediaPlayer.create(this, R.raw.song);
set this in your button's click event.
mediaPlayer.start();
3.Stop it by mediaPlayer.stop();
but when you stopping mediaPlayer before that just check mediaPlayer.isPlaying()
with if Condition. then Stop. else error thrown.
or follow this Example Turorial Link