为什么此代码仅在Chrome(81.0.4044.122)中听起来不错?在Firefox(75.0)和Edge中,有时仅发出声音,然后中断。尝试向按钮发送垃圾邮件。我该如何解决?(编辑)如果我打开了OBS Studio,它可以工作,当我关闭它时,声音会再次切断...
// AUDIO element test.
var sound = document.createElement("audio");
sound.src="http://composerconnection.com/pirsounds/WEB_DESIGN_SOUNDS_WAV1/SOUNDFX/BOMB.WAV";
sound.load();
function soundLoad(){
sound.volume = 0;
sound.play();
IDload.innerHTML = "Loading...";
IDload.onclick = "";
sound.onended = function (){
sound.volume = 1;
IDload.style.display = "none";
IDplay.style.display = "initial";
};
}
function soundPlay(){
if (sound.paused){
sound.volume = 1;
sound.currentTime = 0
sound.play();
}
}
<button id="IDload" onclick="soundLoad()">load</button>
<button id="IDplay" onclick="soundPlay()" style="display:none">Play</button>
听起来像是客户端问题,请检查您的音频设置,如果可选,请检查您的浏览器设置。祝你好运。