Ask coding questions

← Back to all posts
Audio does not play outside of Editor
h
Pankak (49)

If I add audio to my html, for example:

let audio = new Audio("audio.wav"); 
  audio.loop = true;
    audio.addEventListener("ended", function() {
        this.currentTime = 0;
        this.play();
    }, false);
    audio.play();

The audio plays when I use the browser window inside the editor, but when I open it in a new tab it doesn't play.

Any help? Thanks

Comments
hotnewtop
Coder100 (18868)

Send the repl, maybe there was an error?

Coder100 (18868)

and yes, I know how to fix smh @Pankak

Pankak (49)

@Coder100 I already sent repl wdym

Coder100 (18868)

it's playing fine for me... @Pankak

Pankak (49)

@Coder100 I'm using Chrome, what browser are you using? I tried Safari but no luck as well

Coder100 (18868)

chrome as well, try hard-reloading @Pankak