«
ASP根据提交的视频格式进行正确的播放的函数

时间:2008-5-31    作者:Deri    分类: 分享


   <p>  在给客户做个程序时,突然遇到个问题,就是产品页用户提交视频播放文件时,如何根据提交的网址内的视频格式进行正确的播放呢....郁闷了一会,想好了思路,说动手就动手...</p><p>  思路是先取得文件的类型,并根据类型选择不同的网页播放器代码..三下五去二.....同时为了代码在以后的复用性,写成了通用的调用函数.方便以后在别的系统中调用..</p><p>  现发布源代码如下:</p><code>Sub SelPlay(strUrl,strWidth,StrHeight)<br />Dim Exts,isExt<br />If strUrl <> "" Then<br />  isExt = LCase(Mid(strUrl,InStrRev(strUrl, ".")+1))<br />Else<br />  isExt = ""<br />End If<br />Exts = "avi,wmv,asf,mov,rm,ra,ram"<br />If Instr(Exts,isExt)=0 Then<br />Response.write "非法视频文件"<br />Else<br />Select Case isExt<br /> Case "avi","wmv","asf","mov"<br />  Response.write "<EMBED id=MediaPlayer src="&strUrl&" width="&strWidth&" height="&strHeight&" loop=""false"" autostart=""true""></EMBED>"<br /> Case "mov","rm","ra","ram"<br />  Response.Write "<OBJECT height="&strHeight&" width="&strWidth&" classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA>"<br />  Response.Write "<PARAM NAME=""_ExtentX"" VALUE=""12700"">"<br />  Response.Write "<PARAM NAME=""_ExtentY"" VALUE=""9525"">"<br />  Response.Write "<PARAM NAME=""AUTOSTART"" VALUE=""-1"">"<br />  Response.Write "<PARAM NAME=""SHUFFLE"" VALUE=""0"">"<br />  Response.Write "<PARAM NAME=""PREFETCH"" VALUE=""0"">"<br />  Response.Write "<PARAM NAME=""NOLABELS"" VALUE=""0"">"<br />  Response.Write "<PARAM NAME=""SRC"" VALUE="""&strUrl&""">"<br />  Response.Write "<PARAM NAME=""CONTROLS"" VALUE=""ImageWindow"">"<br />  Response.Write "<PARAM NAME=""CONSOLE"" VALUE=""Clip"">"<br />  Response.Write "<PARAM NAME=""LOOP"" VALUE=""0"">"<br />  Response.Write "<PARAM NAME=""NUMLOOP"" VALUE=""0"">"<br />  Response.Write "<PARAM NAME=""CENTER"" VALUE=""0"">"<br />  Response.Write "<PARAM NAME=""MAINTAINASPECT"" VALUE=""0"">"<br />  Response.Write "<PARAM NAME=""BACKGROUNDCOLOR"" VALUE=""#000000"">"<br />  Response.Write "</OBJECT>"<br />  Response.Write "<BR>"<br />  Response.Write "<OBJECT height=32 width="&strWidth&" classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA>"<br />  Response.Write "<PARAM NAME=""_ExtentX"" VALUE=""12700"">"<br />  Response.Write "<PARAM NAME=""_ExtentY"" VALUE=""847"">"<br />  Response.Write "<PARAM NAME=""AUTOSTART"" VALUE=""0"">"<br />  Response.Write "<PARAM NAME=""SHUFFLE"" VALUE=""0"">"<br />  Response.Write "<PARAM NAME=""PREFETCH"" VALUE=""0"">"<br />  Response.Write "<PARAM NAME=""NOLABELS"" VALUE=""0"">"<br />  Response.Write "<PARAM NAME=""CONTROLS"" VALUE=""ControlPanel,StatusBar"">"<br />  Response.Write "<PARAM NAME=""CONSOLE"" VALUE=""Clip"">"<br />  Response.Write "<PARAM NAME=""LOOP"" VALUE=""0"">"<br />  Response.Write "<PARAM NAME=""NUMLOOP"" VALUE=""0"">"<br />  Response.Write "<PARAM NAME=""CENTER"" VALUE=""0"">"<br />  Response.Write "<PARAM NAME=""MAINTAINASPECT"" VALUE=""0"">"<br />  Response.Write "<PARAM NAME=""BACKGROUNDCOLOR"" VALUE=""#000000"">"<br />  Response.Write "</OBJECT>"<br />End Select<br />End If<br />End Sub</code><p>  调用方式:</p>
<p> </p>

   <code>Call SelPlay(DvUrl,280,220)</code></p></p>