通用媒体播放器(JS版,ASP版)

一、JS版:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>JS版</title>
<style type="text/css">
<!--
.playerDIV {
    background-image: url("");
    width:320px;
    height:240px;
}
-->
</style>
<script>
var rmID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA";
var wmID="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95";
var swfID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";

var thePlayer;

function doPlay(fPath){
  if(!fPath)fPath=document.getElementById("txtURL").value;
  if(fPath==""||fPath==null)return(false);
  fType=fPath.substring(fPath.lastIndexOf(".")+1).toLowerCase();
  if(thePlayer){
      document.getElementById("theTurePlayerID").outerHTML="";
  }
  thePlayer=document.createElement("object");
  thePlayer.width="100%";
  thePlayer.height="100%";
  thePlayer.style.display="none";
  thePlayer.id="theTurePlayerID";
  document.getElementById("playerDIV").appendChild(thePlayer);
  switch(fType){
    case "rm":case "rmvb":
        thePlayer.classid=rmID;
        with(thePlayer){
            _ExtentX=12118;_ExtentY=8573;
            AUTOSTART=-1;SHUFFLE=0;PREFETCH=0;
            NOLABELS=0;CONTROLS="Imagewindow,StatusBar,ControlPanel";
            LOOP=0;NUMLOOP=0;CENTER=0;
            MAINTAINASPECT=0;BACKGROUNDCOLOR="#000000";
        }
        thePlayer.Source=fPath;
        thePlayer.DoPlay();
    break;
    case "swf":
        thePlayer.classid=swfID;
        thePlayer.movie=fPath;
    break;
    default:
        thePlayer.classid=wmID;
        thePlayer.fileName=fPath;
        thePlayer.AutoStart=1;
        thePlayer.ShowControls=1;
        thePlayer.Play();
  }
  
  setTimeout("thePlayer.style.display='';",1000);
}
</script>
</head>

<body onload="doPlay();">
<div class="playerDIV" id="playerDIV" ></div>
<input id="txtURL" value="http://www.fy100.cn/ken/tianbian.mp3" type="hidden" />
<a href="javascript:doPlay('http://www.fy100.cn/ken/tianbian.mp3');">吉祥三宝 (MP3)</a><br />
<a href="javascript:doPlay('http://www.citb.gov.hk/cib/zhtml/image/service2_chi.rm');">短片(RM)</a><br />
<a href="javascript:doPlay('http://www.cmfu.com/quest/130.swf');">Flash</a><br />
</body>
</html>

在原版基础上加入了可自动播放,rm格式加入控制栏。

二、ASP版:

<%
Sub SelPlay(strUrl,strWidth,StrHeight)
    Dim Exts,isExt
    If strUrl <> "" Then
       isExt = LCase(Mid(strUrl,InStrRev(strUrl, ".")+1))
    Else
       isExt = ""
    End If
    Exts = "avi,wmv,asf,mov,rm,ra,ram"
    If Instr(Exts,isExt)=0 Then
     Response.write "非法视频文件"
    Else
     Select Case isExt
      Case "avi","wmv","asf","mov"
       Response.write "<EMBED id=MediaPlayer src="&strUrl&" width="&strWidth&" height="&strHeight&" loop=""false"" autostart=""true""></EMBED>"
      Case "mov","rm","ra","ram"
       Response.Write "<OBJECT height="&strHeight&" width="&strWidth&" classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA>"
       Response.Write "<PARAM NAME=""_ExtentX"" VALUE=""12700"">"
       Response.Write "<PARAM NAME=""_ExtentY"" VALUE=""9525"">"
       Response.Write "<PARAM NAME=""AUTOSTART"" VALUE=""-1"">"
       Response.Write "<PARAM NAME=""SHUFFLE"" VALUE=""0"">"
       Response.Write "<PARAM NAME=""PREFETCH"" VALUE=""0"">"
       Response.Write "<PARAM NAME=""NOLABELS"" VALUE=""0"">"
       Response.Write "<PARAM NAME=""SRC"" VALUE="""&strUrl&""">"
       Response.Write "<PARAM NAME=""CONTROLS"" VALUE=""ImageWindow"">"
       Response.Write "<PARAM NAME=""CONSOLE"" VALUE=""Clip"">"
       Response.Write "<PARAM NAME=""LOOP"" VALUE=""0"">"
       Response.Write "<PARAM NAME=""NUMLOOP"" VALUE=""0"">"
       Response.Write "<PARAM NAME=""CENTER"" VALUE=""0"">"
       Response.Write "<PARAM NAME=""MAINTAINASPECT"" VALUE=""0"">"
       Response.Write "<PARAM NAME=""BACKGROUNDCOLOR"" VALUE=""#000000"">"
       Response.Write "</OBJECT>"
       Response.Write "<BR>"
       Response.Write "<OBJECT height=32 width="&strWidth&" classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA>"
       Response.Write "<PARAM NAME=""_ExtentX"" VALUE=""12700"">"
       Response.Write "<PARAM NAME=""_ExtentY"" VALUE=""847"">"
       Response.Write "<PARAM NAME=""AUTOSTART"" VALUE=""0"">"
       Response.Write "<PARAM NAME=""SHUFFLE"" VALUE=""0"">"
       Response.Write "<PARAM NAME=""PREFETCH"" VALUE=""0"">"
       Response.Write "<PARAM NAME=""NOLABELS"" VALUE=""0"">"
       Response.Write "<PARAM NAME=""CONTROLS"" VALUE=""ControlPanel,StatusBar"">"
       Response.Write "<PARAM NAME=""CONSOLE"" VALUE=""Clip"">"
       Response.Write "<PARAM NAME=""LOOP"" VALUE=""0"">"
       Response.Write "<PARAM NAME=""NUMLOOP"" VALUE=""0"">"
       Response.Write "<PARAM NAME=""CENTER"" VALUE=""0"">"
       Response.Write "<PARAM NAME=""MAINTAINASPECT"" VALUE=""0"">"
       Response.Write "<PARAM NAME=""BACKGROUNDCOLOR"" VALUE=""#000000"">"
       Response.Write "</OBJECT>"
     End Select
    End If
End Sub
'Call SelPlay(DvUrl,280,220)
%>


评论: 1 | 引用: 0 | 查看次数: 7367
发表评论
登录后再发表评论!