0
所以我找到了一個快速音頻播放按鈕代碼片段 https://siongui.github.io/2012/10/12/javascript-toggle-sound-onclick/。我想合併多個音頻文件,但是在頁面加載時,我創建的音頻按鈕只播放最後一個音頻文件。 enter code here
播放音頻 您的瀏覽器不支持此音頻格式。 多個音頻文件單個頁面上的javascript
<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>