全兼容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>

转载于:https://www.cnblogs.com/hcmdy/p/5342188.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值