有時候我們會有這樣的需求,在網頁中嵌入視頻播放器,以播放我們的服務器端的視頻,下面我將代碼貼出來: 嵌入快播播放器:
<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; } }