I've been trying to create a countdown that plays a buzzer wav (R.raw.buzzer1) when it runs out of time. Every code I've seen on this site causes my app to force close. How would I do this? For example,
public void onFinish()
{
// play the sound somehow?
}
Thanks!
try this:
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();
}
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.