我使用此功能播放声音

var soundObject = null;
function PlaySound() {

    if (soundObject != null) {
        document.body.removeChild(soundObject);
        soundObject.removed = true;
        soundObject = null;
    }
    soundObject = document.createElement("embed");
    //soundObject.setAttribute("src", "../Sounds/beep-01a1.wav");
    soundObject.setAttribute("src", "../Sounds/Small Blink.mp3");

    soundObject.setAttribute("hidden", true);
    soundObject.setAttribute("autostart", true);
    document.body.appendChild(soundObject);
    // alert('hii sound');
}


它在所有浏览器(而不是Microsoft Edge浏览器)中都能正常工作,并在浏览器javascript - Microsoft Edge浏览器嵌入音频显示嗡嗡声图标-LMLPHP中显示蜂鸣器图标

任何帮助都是可观的,谢谢。

最佳答案

Edge浏览器似乎忽略了“隐藏”属性。尝试这个:

soundObject.setAttribute("style", "display:none");

08-06 00:08