15
I'm using this code below to play an audio file in android
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource("fileSourceHere");
mediaPlayer.prepare();
mediaPlayer.start();
I have a button on that program. When click on that button, it'll check if music playing. If music playing, it'll stop that. How can I check if music playing? I tried the code below but it didn't work
if(mediaPlayer.isPlaying() == true){
mediaPlayer.pause();
}else{
mediaPlayer.start();
}