Tell us what’s happening:
I’m trying to build the React Pomodoro Clock. How do I play an audio in React? I have everything working so far, but I can’t get the audio played. Error message: Uncaught Error:
The error you provided does not contain a stack trace. Uncaught (in promise) DOMException <
This is all the audio related code I have:
Your code so far
constructor () {
super()
this.state = defaultState
this.startStop = this.startStop.bind(this);
this.reset = this.reset.bind(this);
this.increment = this.increment.bind(this);
this.decrement = this.decrement.bind(this);
this.audio = React.createRef();
}
interval = setInterval(() => {
if(this.state.timerMinutes === 0 && this.state.timerSeconds === 0) {
this.audio.current.play();
this.audio.current.currentTime = 0;
this.audio.current.play();
... }
render(){
return(
...
<audio id="beep" src="sounds/beep.wav" type="audio/wav" ref={this.audio} />
)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36 OPR/60.0.3255.151 (Edition avira-2)
.
Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/front-end-libraries-projects/build-a-pomodoro-clock