Html5使用audio播放音乐
html代码
<audio id="myaudio" src="http://ws.stream.qqmusic.qq.com/C100003R74Cn0JR4O6.m4a?fromtag=0" controls="controls">
</audio>
或
<button onclick="playPause()">播放/暂停</button> <audio id="audio1" width="420" > <source src="example.mp4" type="audio/mp4" /> <source src="example.ogg" type="audio/ogg" /> </audio>
js代码
var myAudio = document.getElementById('audio1');
function playPause(){
if(myAudio.paused){
myAudio.play();
}else{
myAudio.pause();
}
}
耐得住寂寞,才能登得顶
Gitee码云:https://gitee.com/lyc96/projects