0
我有音频播放器的代码。按下时请激活我以更改播放/暂停按钮的图片。不幸的是我真的不强JS(如何更改html5音频中的播放/按钮图像
<div class="onlineradio"><img src="images/Radio.jpg" alt="" />
<p><video id="yourAudio" width="0" height="0">
<source src='http://178.219.160.126:8000/stream.mp3' type='audio/mpeg' preload="auto" />
</video> <a id="audioControl" href="#"><img src="images/radioscalebutton.png" alt="" /></a></p>
</div>
<script>// <![CDATA[
var yourAudio = document.getElementById('yourAudio'),
ctrl = document.getElementById('audioControl');
ctrl.onclick = function() {
// Update the Button
var pause = ctrl.innerHTML === 'pause!';
ctrl.innerHTML = pause ? 'pause' : 'play';
// Update the Audio
var method = pause ? 'pause' : 'play';
yourAudio[method]();
// Prevent Default Action
return false;
};
// ]]></script>
一切都很好,你只需要改变图像的网址,例如'图像/ radioscalebutton.png'。 – 2014-09-29 08:44:25
引用此:http://stackoverflow.com/questions/3472459/custom-1-button-player-with-html5-audio-tag – 2014-09-29 08:47:42