1

I used the below code in my JS file for a sliding puzzle game, but it does not work. What am I doing wrong?

var backgroundSound= new Audio("tetris.mp3");
backgroundSound.addEventListener('ended', function() {
    this.currentTime = 0;
    this.play();
}, false);
backgroundSound.play();
Shiladitya
  • 11,650
  • 15
  • 23
  • 35
Andy
  • 11
  • 1

1 Answers1

0

You can use loop to do that:

backgroundSound.loop = true;
Armedin Kuka
  • 665
  • 4
  • 10