I have a CountDownTimer
as follows:
cuentaAtras = new CountDownTimer(mili, 1000) {
public void onTick(long millisUntilFinished) {
long seconds = millisUntilFinished / 1000;
if (seconds <= TIEMPO3){
if (tic1.isPlaying()){
tic1.stop();
tic2.start();
}
} else if (seconds <= TIEMPO && seconds > TIEMPO2 + 10){
tic1.start();
}
}
public void onFinish() {
if (tic2.isPlaying())
{
tic2.stop();
}
ticExp.start();
tic1.reset();
tic2.reset();
ticExp.reset();
}
}.start();
The variables tic1
, tic2
and ticExp
are of type MediaPlayer
and I initialize them as follows:
tic1 = MediaPlayer.create(getApplicationContext(), R.raw.tic1);
tic1.setLooping(true);
tic2 = MediaPlayer.create(getApplicationContext(), R.raw.tic3);
tic2.setLooping(true);
ticExp = MediaPlayer.create(getApplicationContext(), R.raw.exp);
The problem comes when the onFinish
method is executed, since the ticExp
should be reproduced, but that never happens.
I have tried putting it in the onTick
method, and if it is playing, so it is discarded that the audio file is corrupted or something.
I have no idea why in onTick
it plays and in the onFinish
it never gets heard. (But if you get to execute the other instructions, such as tic2
stop listening)
I hope to hear your suggestions to solve a problem that is giving me headaches. Thanks.