My pen is here: https://codepen.io/Crimson_Macaw/pen/ebRNzg and my main issue that I can’t figure out is how to get the sound to play when the timer reaches 00:00. I’ve copied the relevant parts of other people’s working code and pasted them directly in my code and for some reason it won’t work in my code.
The command to play the sound is in my handleStart function below:
handleStart = () => {
if(this.state.timerStop ){
this.timer = setInterval(() => {
this.setState({
timerStart: true,
timerStop: false
});
if(this.state.timerStart && this.state.minutes >= 0){
this.setState((prevState) => ({seconds: prevState.seconds - 1}))
if(this.state.seconds < 0){
this.setState((prevState) => ({minutes:prevState.minutes - 1,
seconds: 59}))
}
}
}, 1000)
}
if(this.state.minutes == "00" && this.state.seconds == "01"){
this.audio.play();
}
}
The link to the audio file is at the very bottom of the code. The logic of the syntax makes sense to me but maybe it’s just that it’s been coded incorrectly. Would appreciate any help on this one.