所以我这样说,每当有人打开我的网页时,就会播放背景声音。我正在使用的代码可以工作并且以前曾在不同的项目上工作过,但现在不行了。有人能帮我吗?我的代码:
<div id="player">
<audio autoplay hidden>
<source src="./sounds/bgsound.mp3" type="audio/mpeg">
If you're reading this then your browser is outdated.
</audio>
</div>
<script>
function myFunction() {
var x = document.getElementById("myAudio").autoplay;
document.getElementById("demo").innerHTML = x;
}
</script>