该代码是由
acoder serveral(139)天前。 因此,我决定将其发布。
function play() {
embed = document.createElement("embed");
embed.setAttribute("src", "soundfile.wav");
embed.setAttribute("hidden", true);
embed.setAttribute("autostart", true);
document.body.appendChild(embed);
}
^ _ ^谢谢,死亡
翻译自: https://bytes.com/topic/javascript/insights/767825-playing-sound-file-javascript-function
本文介绍了一种在网页中使用JavaScript代码播放音频文件的方法。通过创建并设置embed元素,可以实现音频的自动播放,该方法适用于希望在网页上无缝集成音频功能的开发者。

被折叠的 条评论
为什么被折叠?



