我正在制作一个在线学习课程,我想要这个按钮:
为了能够被单击,然后播放音频文件,然后当您单击按钮时,它会再次暂停。
我想用html5来做这一切,但我只能在点击的时候让它播放。
有人能帮帮我吗?
发布于 2020-10-12 00:43:10
简短的回答:
你可能不能,使用JS,通过freecodecamp.org学习JS (如果你已经学习了超文本标记语言和CSS )
这是一个课程网站,它可能需要一些JS和PHP等
使用HTML5音频标签:
<audio controls>
<source src="sound.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio> 工作:https://www.w3schools.com/TAGS/tryit.asp?filename=tryhtml5_audio
你需要这个文件来播放它。
我还找到了一种简单的方法:
<audio src="demo.mp3" controls></audio>
<!-- Seems to not work... use the other one found in the repl below -->您需要<!DOCTYPE html>
这是我能得到的最接近的了,你需要使用JS...
https://repl.it/@DarmiyaevDev/Audio#index.html
这都是纯HTML5
对不起,我认为您需要JS来使用图像onclick音频。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>repl.it</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script src="script.js"></script>
<image src="audio.png" width="50vh" height="50vh"></image>
<audio controls>
<source src="8 Bit FX.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</body>
</html>
https://stackoverflow.com/questions/64306512
复制相似问题