由网友(小灬圈圈。)分享简介:在我的项目,我在玩android系统中的媒体播放器的音乐文件,通过使用下面的code In my project, I am playing music file in android media player by using the following codeMediaPlayer mPlayer = Med...
在我的项目,我在玩android系统中的媒体播放器的音乐文件,通过使用下面的code
In my project, I am playing music file in android media player by using the following code
MediaPlayer mPlayer = MediaPlayer.create(MyActivity.this, R.raw.myfile);
mPlayer.start();
以上是codeD的播放按钮的onclick。 我想通过单击该按钮again.ie)的单按钮播放/暂停暂停播放。 我怎能做到这一点。
the above is coded in the onclick of the play button. I want to pause the playback by clicking the same button again.ie) single button for play/pause. How shall i do this.
推荐答案
您可以使用简单的,如果检查处理暂停。试试这个:
You could use simple if-check to handle the pausing. Try this:
if(mPlayer.isPlaying()){
mPlayer.pause();
} else {
mPlayer.start();
}
相关推荐
最新文章