音頻當我點擊按鈕 「PLAY」 或 「暫停」,它不會在Chrome中工作:我不能用javascript來控制鉻
<script>
var audioPlayer = document.getElementsByName("player_audio");
function play(){
audioPlayer.play();
}
function pause(){
audioPlayer.pause();
}
</script>
HTML:
<audio id="player_audio" controls>
<source id="audio_sources" src="http://admin.test.cnrmobile.com/18/1463652002.aac">
<p>
<button onclick="play()"> play </button>
</p>
<p>
<button onclick="pause()"> pause </button>
</p>
代替'VAR audioPlayer ='document.getElementsByName'( 「player_audio」)的;'** **使用VAR' audioPlayer ='document.getElementById'(「player_audio」);' – zer00ne
我剛剛更新了我的答案。 – fuzz