我一直试图创建一个倒计时,当它耗尽时间时播放蜂鸣器(R.raw.buzzer1)。我在这个网站上看到的每个代码都会导致我的应用程序强制关闭。我该怎么做?例如,
public void onFinish()
{
// play the sound somehow?
}
谢谢!
答案 0 :(得分:0)
试试这个:
MediaPlayer mpxmPlayer2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mpxmPlayer2 = new MediaPlayer();
mpxmPlayer2 = MediaPlayer.create(this, R.raw.digital_preview);
cntr_aCounter.start();
}
CountDownTimer cntr_aCounter = new CountDownTimer(3000, 1000) {
public void onTick(long millisUntilFinished) {
Log.e("CountDown",millisUntilFinished+"");
}
public void onFinish() {
mpxmPlayer2.start();
}
};