Android的媒体播放器播放/暂停按钮 [英] Android Media Player play/pause Button
本文介绍了Android的媒体播放器播放/暂停按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的项目,我在玩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();
}
这篇关于Android的媒体播放器播放/暂停按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文