网页视频点播

时间:2021-06-04 15:55:03

    <script type='text/javascript' src='JWplayer/swfobject.js'></script>
<body>
<div id='mediaspace'>This text will be replaced</div>
<input type="button" id="a" onclick="pv_m('../**.avi','470','400');" value="播放Mediaplayer格式的视频" />
<input type="button" id="Button1" onclick="pv_r('../猫和老鼠.rmvb','470','400');" value="播放Realplay格式的视频" />
<input type="button" id="Button2" onclick="flv_swf();" value="播放flv,swf格式的视频" />
</body>
<script type='text/javascript'>
//视频FLV和MP4,音频MP3和AAC,图片JPG、GIF和PNG-----------------------JW player播放器
function flv_swf()
{
var so = new SWFObject('../JWplayer/player-viral.swf','mpl','470','320','9');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addParam('wmode','opaque');
so.addVariable('file','../bunnies.xml');
so.addVariable('playlist','left');
//so.addParam('flashvars','&displayheight=0&file=../video.flv&width=272&lightcolor=0x330000&backcolor=0xEEEEEE&frontcolor=0x222222&autoscroll=false&autostart=false&repeat=true&playlistsize=160&volume=80&playlist=left&displayclick=none&repeat=list')

so.write('mediaspace');//表示播放器所在位置,player为将要包含播放器的元素的id名称。
}
//由于播放器下载到浏览器并初始化完成需要一个过程,所以需要播放器在加载完成后能够通知我们
var player;
function playerReady(obj)
{
  player=document.getElementById(obj["id"]);
 
}
//    用javascript控制播放器,当播放器初始化完毕后player就会保存该播放器对象,我们就可以通过这个对象来控制播放器了

  player.sendEvent("load","");//加载新的媒体文件
  player.sendEvent("play","true"); //立即播放
  player.sendEvent("stop"); //停止播放
  player.sendEvent("volume","100");//音量,100为最大
  player.sendEvent("mute","true");//静音

list.xml文件

<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
 <channel>

  <item>
   <title>Video</title>
   <media:content url="../video.flv" type="mp3"/>
  </item>

  <item>
   <title>标题</title>
   <media:content url="路径" type="mp3"/>
  </item>

……

 </channel>
</rss>

 

//播放Mediaplayer格式的视频,包括.avi .mpg .mpeg .wmv .wma .asf .mid .mp3等 
function pv_m(u, w, h){ 
var pv=''; 
pv += '<object width="'+w+'" height="'+h+'" id="iask_v" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">'; 
pv += '<param name="FileName" value="'+u+'">'; 
pv += '<param name="AutoStart" value="1">'; 
pv += '<param name="AutoSize" value="1">'; 
pv += '<param name="ShowControls" value="1">'; 
pv += '<param name="ShowPositionControls" value="0">'; 
pv += '<param name="ShowAudioControls" value="1">'; 
pv += '<param name="ShowTracker" value="1">'; 
pv += '<param name="ShowDisplay" value="0">'; 
pv += '<param name="ShowStatusBar" value="1">'; 
pv += '<param name="ShowGotoBar" value="0">'; 
pv += '<param name="ShowCaptioning" value="0">'; 
pv += '<param name="PlayCount" value="1">'; 
pv += '<param name="AnimationAtStart" value="0">'; 
pv += '<param name="TransparentAtStart" value="0">'; 
pv += '<param name="AllowScan" value="0">'; 
pv += '<param name="EnableContextMenu" value="0">'; 
pv += '<param name="ClickToPlay" value="0">'; 
pv += '<param name="InvokeURLs" value="1">'; 
pv += '<param name="DefaultFrame" value="">'; pv+='<param   name= "play.asx "   value= "play.asx ">'; 
pv += '<embed src="'+u+'" width="'+w+'" height="'+h+'" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/isapi/redir.dll?prd=windows&;sbp=mediaplayer&ar=media&sba=plugin&" name="MediaPlayer" showcontrols="1" showpositioncontrols="0" showaudiocontrols="1" showtracker="1" showdisplay="0" showstatusbar="1" autosize="0" showgotobar="0" showcaptioning="0" autostart="1" autorewind="0" animationatstart="0" transparentatstart="0" allowscan="1" enablecontextmenu="1" clicktoplay="0" invokeurls="1" defaultframe=""></embed>'; 
pv += '</object>'; 

//document.write(pv); 
document.getElementById("mediaspace").innerHTML=pv;

//播放Realplay格式的视频,包括.rm .ram .rmvb等 
function pv_r(u, w, h){ 
var pv=''; 
pv += '<object width="'+w+'" height="'+h+'" id="iask_v" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA">'; 
pv += '<param name="SRC" value="'+u+'">'; 
pv += '<param name="AUTOSTART" value="1">'; 
pv += '<param name="CONTROLS" value="Imagewindow,StatusBar,ControlPanel">'; 
pv += '<param name="_ExtentX" value="18415">'; 
pv += '<param name="_ExtentY" value="9102">'; 
pv += '<param name="SHUFFLE" value="0">'; 
pv += '<param name="PREFETCH" value="0">'; 
pv += '<param name="NOLABELS" value="0">'; 
pv += '<param name="CONSOLE" value="Clip1">'; 
pv += '<param name="LOOP" value="0">'; 
pv += '<param name="NUMLOOP" value="0">'; 
pv += '<param name="CENTER" value="0">'; 
pv += '<param name="MAINTAINASPECT" value="0">'; 
pv += '<param name="BACKGROUNDCOLOR" value="#000000">'; 
pv += '<embed src="'+u+'" width="'+w+'" height="'+h+'" type="audio/x-pn-realaudio-plugin" console="Clip1" controls="Imagewindow,StatusBar,ControlPanel" autostart="true">'; 
pv += '</object>'; 
//document.write(pv); 
document.getElementById("mediaspace").innerHTML=pv;

//播放Quicktime格式的视频,包括.mov .amr .3gp等 
function pv_q(u, w, h){ 
var pv=''; 
pv += '<object width="'+w+'" height="'+h+'" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab">'
pv += '<param name="src" value="'+u+'">'; 
pv += '<param name="controller" value="true">'; 
pv += '<param name="type" value="video/quicktime">'; 
pv += '<param name="autoplay" value="true">'; 
pv += '<param name="target" value="myself">'; 
pv += '<param name="bgcolor" value="black">'; 
pv += '<param name="pluginspage" value="http://www.apple.com/quicktime/download/index.html">'
pv += '<embed src="'+u+'" width="'+w+'" height="'+h+'" controller="true" align="middle" bgcolor="black" target="myself" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/index.html"></embed>'
pv += '</object>'; 
//document.write(pv); 
document.getElementById("mediaspace").innerHTML=pv;
}