为什么无法在简单的(HTML,CSS,JS)网站在线实现音频属性

问题描述 投票:0回答:1

实际上,我的问题是,它不会自动播放歌曲(chinese.mp3)文件中的音频。我把它放在github上了。

没有错误(控制台)

网站没有故障。

但是,只是缺少音频。

你能帮我吗?

----我的 Memory Mania 游戏项目的链接:-

github

---其在线(netlify)托管链接:- 链接

我已经尝试过:

<div class="music">
        <audio autoplay>
          <source src="./songs/chinese.mp3" type="audio/mp3" id="myaudio" />
          Your browser does not support the audio element.
        </audio>
</div>

甚至在过去的一些提交中也应用了这个:


<audio autoplay id="myaudio">
          <source src="./songs/chinese.mp3" type="audio/mp3" allow="autoplay"/>
          Your browser does not support the audio element.
        </audio>

使用的js:


// ---------------    auto - play    --------------------
var x = document.getElementById("myaudio").autoplay;
javascript html github audio autoplay
1个回答
0
投票

浏览器不会直接运行音频,它就像一个保护系统,您必须激活音频,在某些浏览器(例如Firefox)中您会在搜索栏中看到图标,启用音频并享受!

© www.soinside.com 2019 - 2024. All rights reserved.