I'm trying to add a piece of audio that plays (only once!) when the timer reaches zero.
It's a Pomodoro timer, so the first timer goes down to zero, should play the audio, and then the next part of the same function 'break' should run:
function timer(){
//Work Timer Countdown
if(studySecs.innerText != 0){
studySecs.innerText--;
} else if(studyMins.innerText != 0 && studySecs.innerText == 0){
studySecs.innerText = 59;
studyMins.innerText--;
}
//Break Timer Countdown
if(studyMins.innerText == 0 && studySecs.innerText == 0){
if(restSecs.innerText != 0){
restSecs.innerText--;
} else if(restMins.innerText != 0 && restSecs.innerText == 0){
restSecs.innerText = 59;
restMins.innerText--;
} else {
restMins == 0;
restSecs == 0;
alarm.play();
}
}
}
TLDR: I want to add 'alarm.play()' to run before the 'break timer' runs and I only want it to play once! Any advice?
Cheers!
Source code is roughly based on this:
https://github.com/learn-webdevYT/pomodoro-timer/blob/master/main.js