我的页面上有多个播放器。并使用下面的代码 Play/Pause Button HTML5 Audio
HTML
<a href="javascript:void(0)" onclick="aud_play_pause(this)">
<i class="control icon-play"></i>
<audio class="xnine-player" src="/path/to/file#1.mp3" preload="auto"></audio>
</a>
<a href="javascript:void(0)" onclick="aud_play_pause(this)">
<i class="control icon-play"></i>
<audio class="xnine-player" src="/path/to/file#2.mp3" preload="auto"></audio>
</a>
JAVASCRIPT
<script>
function aud_play_pause(object) {
var myAudio = object.querySelector(".xnine-player");
var myIcon = object.querySelector(".control");
if (myAudio.paused) {
myIcon.className = "control icon-pause";
myAudio.play();
} else {
myIcon.className = "control icon-play";
myAudio.pause();
}
}
</script>
只有这段代码对我不起作用。当我点击图标时没有任何事情......