我的音频文件不断过时

时间:2017-01-21 18:30:14

标签: javascript html

所以即时制作游戏,我试图通过添加一些音频使其更加身临其境。唯一的问题是当我实现音频时,一段时间后它将不再播放,当我在DevTools控制台中查看错误时,它看起来像这样:Failed to load resource: the server responded with a status of 403 (Forbidden)。我的Chrome浏览器。链接到其他网站也会发生这种情况。请帮忙。

var woodOut = document.getElementById("woodOut");
var wood = 0;
var woodbtn = document.getElementById("collectWood");
var woodFile = new Audio('https://e.edim.co/120160553/kWewWnUA8Uv9r8Ym.mp3?response-content-disposition=filename%3D%22chopping_wood.mp3%22%3B%20filename%2A%3DUTF-8%27%27chopping-wood.mp3&Expires=1482405575&Signature=jhI4RQ50M9OKN4De2xINypM0Y7Q65IHbvasUeCkUL0Vj7ufjdFj6QogQD9t9K7HlHVC0JY7pbmyFIKUA-kxQnOAxJtp8PD0UkIKHHnr9y9asDOdpRIzFI2TzEqSX1Mz9Bg9S2OrlQe6G7Mr3yxa56XpQBLSxbswlKlC4UlxO8w3RyhSja5J2JWVtkjFZkV7m08gwv-EFVYAzgQXJ0fELy4qVdzTu~EOeuEjO0bDIbflMQUY51AeIoheXGej2FckJfwM9TWMysB5UE9i4FKKjczIy-O0nCtRAnPl5SAO-0tE-IrOVtQUIHNFV~0LVOcxCmcWA~wX42538owQVdf1gmQ__&Key-Pair-Id=APKAJMSU6JYPN6FG5PBQ');

woodbtn.addEventListener("click", collect);

//updates woodOut
setInterval(function(){
  woodOut.innerHTML = wood;
}, 1);

function collect(){
  wood += 1;
  woodFile.play();
}
<button id="collectWood">Collect Wood</button>
<p id="woodOut"></p>

0 个答案:

没有答案