jwplayer HTML5

[plain]  view plain copy
  1. <html>    
  2.     
  3. <head>    
  4. <script type="text/javascript" src="/static/jwplayer.js"></script>    
  5.     
  6. </head>    
  7.     
  8. <body>    
  9.     
  10. <div id="container">Loading the player ...</div>    
  11. <script type="text/javascript">    
  12.     jwplayer("container").setup({    
  13.         flashplayer: "/static/player.swf",    
  14.         file: "/static/video.mp4",    
  15.         height: 622,    
  16.                 width:1104,    
  17.                 stretching : 'fill',    
  18.                 streamer:"start",    
  19.                 provider:"http",  
  20.                modes :[  
  21.                  {type:"html5"}  
  22.                 ]  
  23. });    
  24. </script>    
  25. </body>    
  26. </html>    

[plain]  view plain copy
  1. modes: [  
  2. { type: "html5" },  
  3. { type: "flash", src: "/static/player.swf" },  
  4. { type: "download" }  
  5. ]  


//页面加载的时候预加载第一个视频文件
function startPlayVideo(videoUrl, width, height){
	var thePlayer;
	if(IsPC()){
		thePlayer = jwplayer('flashplayer').setup({
	        flashplayer:'http://'+window.location.host+'/flash/jwplayer/jwplayer.flash.swf',
	        //file: 'http://192.168.1.10:8080/'+$('#videourl').val(),
	        file: 'rtmp://...:8080/vod/mp4:'+videoUrl,
	        autostart: true, //开启自动播放
	        bufferlength: 180, //缓存时间为三分钟
	        smoothing: true, //开启平滑处理
	        showvolume:true, //显示音量控制按钮
	        width: width,
	        height: height,
	        dock: false
	    });
	}else{
		thePlayer = jwplayer('flashplayer').setup({
	        //flashplayer: 'http://'+window.location.host+'/flash/jwplayer/jwplayer.flash.swf',
	        file: "http://.../videos/"+videoUrl,
	        autostart: true, //开启自动播放
	        bufferlength: 180, //缓存时间为三分钟
	        smoothing: true, //开启平滑处理
	        showvolume:true, //显示音量控制按钮
	        width: width,
	        height: height,
	        dock: false,
	        modes: [
	               {type:"html5"}
	        ]
	    });
	}
	var timer = setTimeout(function() {
		thePlayer.play(false);
	}, 500);
	timer = null;
}
//判断是否是PC端
function IsPC()
{
	   var userAgentInfo = navigator.userAgent;
	   var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"); 
	   var flag = true;
	   for (var v = 0; v < Agents.length; v++) {
	       if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }
	   }
	   return flag;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值