所以我找到了一段快速音频播放按钮代码
https://siongui.github.io/2012/10/12/javascript-toggle-sound-onclick/。我想要合并多个音频文件,但在页面加载时,我创建的音频按钮只播放最后一个音频文件。
enter code here
播放音频
您的浏览器不支持此音频格式。
<script type="text/javascript">
function toggleSound() {
var audioElem = document.getElementById('creditCardFem');
if (audioElem.paused)
audioElem.play();
else
audioElem.pause();
}
function toggleSoun() {
var audioCreditM = document.getElementById('creditCardMa');
if (audioCreditM.paused)
audioCreditM.play();
else
audioCreditM.pause();
}
</script>
<div class="audioPlayer">
<button id="player" type="button"
onclick="javascript:toggleSound();">
Play Audio
</button>
<audio id="creditCardFem">
<source src="http://www.smartaction.com/wp-content/uploads/2015/06/Financial_Services_Credit_Card_Payment_Female_Inbound.mp3" type="audio/mpeg" type="audio/mpeg">
Your browser does not support this audio format.
</audio>
</div>
<div class="audioPlayer">
<button id="player" type="button"
onclick="javascript:toggleSoun();">
Play Audio
</button>
<audio id="creditCardMa">
<source src=#">
Your browser does not support this audio format.
</audio>
</div>
答案 0 :(得分:0)
似乎在此代码中只链接了一个音频文件。
<audio id="creditCardMa">
在其<source src="#">
孩子中没有引用。