有时候我们会有这样的需求,在网页中嵌入视频播放器,以播放我们的服务器端的视频,下面我将代码贴出来:

嵌入快播播放器:

<table width="100%" align="left">   		<tr>   			<td width="320px">  		 		<div class="box1"  panelTitle="文件列表" panelHeight="450" panelWidth="320" overflow="auto">  		 		文件列表:  		 		     <li><a href="javascript:void(0);"  onclick="play('F:\\30230201\\02-52-01.AVI')";>文件1</a></li>  					 <li><a href="javascript:void(0);"  onclick="play('F:\\Movie\\NewMovie\\失恋33天_DVD.rmvb')";>失恋33天</a></li>  					 <li><a href="javascript:void(0);"  onclick="play('F:\\Movie2\\毕加猪.AVI')";>毕加猪</a></li>  				</div>  	 		</td>  		 	<td align="left">  		 		<div panelHeight="450" panelTitle="视频播放" overflow="auto">  		 		   <object classid="clsid:F3D0D36F-23F8-4682-A195-74C92B03D4AF" width="560" height="430" id="QvodPlayer" name="QvodPlayer" onError="downLoadQvod();">  					  <param name="url" id="qvodurl0" value="">  					  <param name="Autoplay" value="1">   					  <param name="Showcontrol" value="1">    				   </object>  		 		</div>  		 	</td>  		</tr>   	</table>	

快播播放器相应的js控制代码:

<Script Language="JavaScript" src="">  setInterval(show1,5000);//5s显示一次下载进度  var bstartnextplay = false;    function show1()  {  	var pos = QvodPlayer.get_CurTaskProcess()/10;  	alert(pos);  	if(pos > 60)  	{  		StartNextDownFile();  	}  	var posv = "当前下载进度为:  "+ pos.toString(10) + "%";  	var mediaInfo1 = document.getElementById("mediaInfo");  	mediaInfo1.innerText = posv;  }    function PointPlay(playername)  {  	//alert(QvodPlayer);  	QvodPlayer.URL = playername;  	QvodPlayer.Play();  }    function Stop()  {  	QvodPlayer.Stop();  }  function Pause()  {  	QvodPlayer.Pause();  }    function Play()  {  	QvodPlayer.Play();  }    function GetS()  {  	var iv;  	var is = QvodPlayer.PlayState;  	alert(is);  	//alert(iv);  }    function putview()  {  	var v = 0;  	QvodPlayer.put_viewframe(v);  }    function puttrack(v)  {  	QvodPlayer.put_soundtrack(v);  }    function putAdjustVideo(v)  {  	QvodPlayer.put_AdjustVideo(v);  }    function putfull()  {  	var v = true;  	QvodPlayer.Full = v;  }    var mute = false;  function putmute()  {  	if(mute)  	{  		mute = false;  		QvodPlayer.Mute = mute;  	}  	else  	{  		mute = true;  		QvodPlayer.Mute = mute;  	}  	  }  function curpos()  {  	var pos = 0;  	pos  = QvodPlayer.Currentpos;  	alert(pos);  }  function setpos(pos)  {  	QvodPlayer.Currentpos = pos;    }  function setvolue(pos)  {  	QvodPlayer.Volume = pos;  }  function OnLoad()  {  //	alert(document.protocol);  	//var i = document.uniqueID;  	var i = navigator.appName;  	var b = navigator.userAgent;  }  function get_MainInfo()  {  	var filename ;  	filename="this";  	filename = QvodPlayer.get_MainInfo();  	alert(filename);  }  function get_TaskDown()  {  	var taskdown1 = QvodPlayer.get_CurTaskProcess();  	alert(taskdown1);  }    function StartNextDownFile()  {      alert(QvodPlayer.get_CurTaskProcess());  	if(QvodPlayer.get_CurTaskProcess() > 600 && !bstartnextplay)  	{  		var url = 'qvod://69999035|DBE1429630008370A3F01A38FC0C741ED648E9C0|香格里拉01.rmvb|';  		var rv = QvodPlayer.StartNextDown(url);  		bstartnextplay = true;  	}  }


快播其他相应的操作及简介参见:http://bbs.kuaibo.com/thread-592-1-1.html

MediaPlayer网页播放器代码:

			 <form name="myform" id="myform">  					<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"  					codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,1,5,217"  					id="MediaPlayer" name="MediaPlayer" type=application/x-oleobject width="580" height="420"  					standby="Loading Microsoft Windows Media Player components..."  					VIEWASTEXT align="middle">  						<!--播放的文件地址-->  						<param name="Filename" value="ftp://192.168.1.254/02-52-01.AVI" valuetype="ref" id="aaa"/>  						<!--是否自动调整播放大小-->  						<param name="AutoSize" value="0" />  						<!--是否自动播放-->  						<param name="AutoStart" value="1" />  						<param name="AudioStream" value="-1" />  						<param name="AnimationAtStart" value="0" />  						<param name="AllowScan" value="-1" />  						<param name="BaseURL" value="" />  						<param name="AllowChangeDisplaySize" value="0" />  						<param name="AutoRewind" value="0" />  						<!--左右声道平衡,最左-9640,最右9640-->  						<param name="Balance" value="0" />  						<!--缓冲时间-->  						<param name="BufferingTime" value="5" />  						<param name="CaptioningID" value="" />  						<param name="ClickToPlay" value="0" />  						<param name="CursorType" value="32512" />  						<!--当前播放进度 -1 表示不变,0表示开头 单位是秒,比如10表示从第10秒处开始播放,值必须是-1.0或大于等于0-->  						<param name="CurrentPosition" value="-1" />  						<param name="CurrentMarker" value="0" />  						<param name="DefaultFrame" value="1" />  						<param name="DisplayBackColor" value="0" />  						<param name="DisplayForeColor" value="16777215" />  						<param name="DisplayMode" value="0" />  						<!--视频1-50%, 0-100%, 2-200%,3-全屏 其它的值作0处理,小数则采用四舍五入然后按前的处理-->  						<param name="DisplaySize" value="0" />  						<param name="Enabled" value="-1" />  						<!-- 是否用右键弹出菜单控制-->  						<param name="EnableContextMenu" value="-1" />  						<param name="EnablePositionControls" value="0" />  						<param name="EnableFullScreenControls" value="0" />  						<!--是否允许拉动播放进度条到任意地方播放-->  						<param name="EnableTracker" value="1" />  						<param name="InvokeURLs" value="-1" />  						<param name="Language" value="-1" />  						<!--是否静音-->  						<param name="Mute" value="0" />  						<!--重复播放次数,0为始终重复-->  						<param name="PlayCount" value="1" />  						<param name="PreviewMode" value="0" />  						<!--播放速率控制,1为正常,允许小数-->  						<param name="Rate" value="1" />  						<!--SAMI样式-->  						<param name="SAMIStyle" value="" />  						<!--SAMI语言-->  						<param name="SAMILang" value="" />  						<!--字幕ID-->  						<param name="SAMIFilename" value="" />  						<!--是否显示字幕,为一块黑色,下面会有一大块黑色,一般不显示-->  						<param name="ShowCaptioning" value="0" />  						<!--是否显示控制,比如播放,停止,暂停-->  						<param name="ShowControls" value="-1" />  						<!--是否显示音量控制-->  						<param name="ShowAudioControls" value="-1" />  						<!--显示节目信息,比如版权等-->  						<param name="ShowDisplay" value="0" />  						<!--是否启用上下文菜单-->  						<param name="ShowGotoBar" value="0" />  						<!--是否显示往前往后及列表,如果显示一般也都是灰色不可控制-->  						<param name="ShowPositionControls" value="-1" />  						<!-- 默认是1 -->  						<!--当前播放信息,显示是否正在播放,及总播放时间和当前播放到的时间-->  						<param name="ShowStatusBar" value="-1" />  						<!-- 默认是1 -->  						<!--是否显示当前播放跟踪条,即当前的播放进度条-->  						<param name="ShowTracker" value="-1" />  						<!-- 默认是1 -->  						<!--显示部的宽部,如果小于视频宽,则最小为视频宽,或者加大到指定值,并自动加大高度.此改变只改变四周的黑框大小,不改变视频大小-->  						<param name="VideoBorderWidth" value="0" />  						<!--显示黑色框的颜色, 为RGB值,比如ffff00为×××-->  						<param name="VideoBorderColor" value="0" />  						<!--音量大小,负值表示是当前音量的减值,值自动会取绝对值,最大为0,最小为-9640-->  						<param name="Volume" value="-1070" />  						<!--如果是0可以允许全屏,否则只能在窗口中查看-->  						<param name="WindowlessVideo" value="0" />  						<param name="TransparentAtStart" value="-1" />  						<!-- 默认是0 -->  						<param name="VideoBorder3D" value="0" />  						<param name="SelectionStart" value="0" />  						<param name="SelectionEnd" value="true" />  						<param name="SendOpenStateChangeEvents" value="-1" />  						<param name="SendWarningEvents" value="-1" />  						<param name="SendErrorEvents" value="-1" />  						<param name="SendKeyboardEvents" value="0" />  						<param name="SendMouseClickEvents" value="0" />  						<param name="SendMouseMoveEvents" value="0" />  						<param name="SendPlayStateChangeEvents" value="-1" />  				    </object>  				  </form>


JS控制播放代码:

 function play(path){  			var frm=document.getElementById("myform");  			frm.MediaPlayer.Filename=path;  			frm.MediaPlayer.Play();  		 }