【问题标题】:mulitiple audio files javascript on single page单个页面上的多个音频文件javascript
【发布时间】:2016-04-19 21:13:01
【问题描述】:

所以我找到了一个快速音频播放按钮的 sn-p 代码 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>

【问题讨论】:

    标签: javascript wordpress html5-audio


    【解决方案1】:

    此代码中似乎只链接了一个音频文件。

    &lt;audio id="creditCardMa"&gt; 在其&lt;source src="#"&gt; 子级中没有引用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-03
      • 1970-01-01
      • 1970-01-01
      • 2013-10-12
      相关资源
      最近更新 更多