gpt4 book ai didi

通过脚本的 HTML 音频控制

转载 作者:行者123 更新时间:2023-11-28 09:35:40 26 4
gpt4 key购买 nike

我是 HTML 的新手,所以请多多包涵...我正尝试通过我网页上的脚本启动音频剪辑,但我很难弄清楚如何执行此操作。这是我尝试使用的 HTML 代码的子集:

<body id="body">
<embed id="audio" src="song.wav" loop="true" hidden="true" autostart="true">
<script>
...
if(state==1)
{
document.getElementById("audio").autostart = "true"
}
else
{
document.getElementById("audio").autostart = "false"
}
...
</script>
</body>

我的目标是根据脚本中变量的状态切换此音频。我上面的内容不起作用,但我觉得我快到了......有什么想法吗?

最佳答案

试试这个。不要用双引号将 true 和 false 括起来

 if(state==1)
{
document.getElementById("audio").autostart = true;
}
else
{
document.getElementById("audio").autostart = false;
}

关于通过脚本的 HTML 音频控制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25540874/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com