HTML5播放器

    function showPlayer(id,url){
var player='';
player+= '';
player+= '';
player+= '';
player+= '';
player+= '';
player+= '';
document.getElementById(id).innerHTML=player;
}
showPlayer("player","https://lyb.li/6gITY1.mp3");
var HTML5Audio=document.getElementById("HTML5Player");
HTML5Audio.volume="0.5";

闲着无聊,写了个兼容非HTML5的HTML5播放器。

其实就是个小玩意,给初学者一个范例。

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="content-type" content="text/html;charset=utf-8">

<title>Music Player</title>

</head>

<body>

<div id="player"></div>

<script type="text/javascript">

function showPlayer(id,url){

var player='<audio id="HTML5Player" src="'+url+'" controls="controls">';

player+= '<object id="WMPPlayer" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="230" height="64">';

player+= '<param name="URL" value="'+url+'"/ />';

player+= '<param name="autoStart" value="0" />';

player+= '<param name="Volume" value="50" />';

player+= '</object>';

player+= '</audio>';

document.getElementById(id).innerHTML=player;

}

showPlayer("player","Ikiru_Mykool.mp3");

var HTML5Audio=document.getElementById("HTML5Player");

HTML5Audio.volume="0.5";

</script>

</body>

</html>
 

日常