当我点击按钮操作歌曲时,按下它再次操作互操作 如果再次按下再次启动声音,我怎么能不重叠?
public class Circal extends Activity {
Button sound = (Button) findViewById(R.id.sound);
sound.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MediaPlayer player = MediaPlayer.create(Circal.this,R.raw.one);
player.start();
}
});
}
答案 0 :(得分:1)
如果条件已经开始,则添加if条件
if(player.isPlaying()){
player.pause(); // pause before doing anything
player.seekTo(0); // go to 0 seconds
}
player.start()