Javascript 使用此代码在游戏中循环音频,但它不起作用。为什么?
我在我的JS文件中使用了下面的代码来制作一个滑动益智游戏,但它不起作用。我做错了什么Javascript 使用此代码在游戏中循环音频,但它不起作用。为什么?,javascript,html,audio,Javascript,Html,Audio,我在我的JS文件中使用了下面的代码来制作一个滑动益智游戏,但它不起作用。我做错了什么 var backgroundSound= new Audio("tetris.mp3"); backgroundSound.addEventListener('ended', function() { this.currentTime = 0; this.play(); }, false); backgroundSound.play(); 您可以使用loop来执行此操作: background
var backgroundSound= new Audio("tetris.mp3");
backgroundSound.addEventListener('ended', function() {
this.currentTime = 0;
this.play();
}, false);
backgroundSound.play();
您可以使用
loop
来执行此操作:
backgroundSound.loop = true;
您可以使用
loop
来执行此操作:
backgroundSound.loop = true;
潜在重复,请参见潜在重复,请参见