0

最近我不得不为 IE8 的 Web 应用程序替换声音通知模块。它是用 Flash 完成的,并且带来了很多问题。

重现这些声音的新方法是通过embed标签,如下所示:

<embed id='player-msg' hidden='true' autoplay='true' 
       src='../../App_Themes/Operator/sounds/ding.mp3' type='audio/mp3'/>

然后我们尝试这样玩:

document.getElementById('player-msg').play();

它不起作用。或者至少不是在所有计算机中,这已经够糟糕的了。

当我使用自动播放附加嵌入时,它总是有效:

var embed = $("<embed id='player-msg' hidden='true' autoplay='true'
    src='../../App_Themes/Operator/sounds/ding.mp3' type='audio/mp3'/>");
$("body").append(embed);

我究竟做错了什么?非常感谢!

4

0 回答 0