全兼容ie chrome firefox 的 windows media play 示例

IE直接使用,firefox需要装插件wmpfirefoxplugin,chrome需要装wmpChrome

wmp api 见:wmp api

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script type="text/javascript">


		function showPlayer(id,url){  
    var vhtml = '<object id="wmp"';  
    var userAg = navigator.userAgent;  
    if(-1 != userAg.indexOf("MSIE")){  
        vhtml+=' classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"';  
    }  
    else if(-1 != userAg.indexOf("Firefox") || -1 != userAg.indexOf("Chrome") || -1 != userAg.indexOf("Opera") || -1 != userAg.indexOf("Safari")){  
        vhtml+=' type="application/x-ms-wmp"';  
    }  
    vhtml+=' width="700" height="400">';  
    vhtml+='<param name="URL" value="'+url+'"/>';  
    //下面这些播放器的参数自己配置吧  
    vhtml+='<param name="autoStart" value="true" />';  
    vhtml+='<param name="invokeURLs" value="false">';  
    vhtml+='<param name="playCount" value="100">';  
    vhtml+='<param name="Volume" value="100">';  
    vhtml+='<param name="defaultFrame" value="datawindow">';  
    vhtml+='</object>';  
    document.getElementById(id).innerHTML = vhtml;  
}  
	//showPlayer(id,url)id=为要插入播放器的父层id url=歌曲地址  
	
		
		
	 

	

	
	function play(elem)
	{
		
		document.getElementById('wmp').URL=elem.href;
		
	}
	
	




</script>
<style type="text/css">


</style>

</head>

<body onLoad='showPlayer("player","");'>

<div id="player"> 

   
 
    
     
 </div>   
		
		<a href="http://video-js.zencoder.com/oceans-clip.mp4"  onClick="play(this);return false;">视频示例1</a>     
        <a href="http://www.w3school.com.cn/example/html5/mov_bbb.mp4"  onClick="play(this);return false;">视频示例2</a>             
        <a href="http://html5video.org/media/sintel.mp4"  onClick="play(this);return false;">视频示例3</a>
		
</body>
</html>

posted @ 2014-03-06 13:48  lxn91  阅读(199)  评论(0编辑  收藏  举报