首页 > 资讯列表 > 编程/数据库 >> ASP/.NET

ASP根据视频格式正确的播放的函数

ASP/.NET 2011-06-28 12:06:55 转载来源: AS网站目录整理

思路是先取得文件的类型,并根据类型选择不同的网页播放器代码..三下五去二.....同时为了代码在以后的复用性,写成了通用的调用函数.方便以后在别的系统中调用..<br /><br />

  在给客户做个程序时,突然遇到个问题,就是产品页用户提交视频播放文件时,如何根据提交的网址内的视频格式进行正确的播放呢....郁闷了一会,想好了思路,说动手就动手...

  思路是先取得文件的类型,并根据类型选择不同的网页播放器代码..三下五去二.....同时为了代码在以后的复用性,写成了通用的调用函数.方便以后在别的系统中调用..

  现发布源代码如下:

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=http://www.chinahtml.com/0708/"&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=http://www.chinahtml.com/0708/""12700"">"
   Response.Write "<PARAM NAME=""_ExtentY"" VALUE=http://www.chinahtml.com/0708/""9525"">"
   Response.Write "<PARAM NAME=""AUTOSTART"" VALUE=http://www.chinahtml.com/0708/""-1"">"
   Response.Write "<PARAM NAME=""SHUFFLE"" VALUE=http://www.chinahtml.com/0708/""0"">"
   Response.Write "<PARAM NAME=""PREFETCH"" VALUE=http://www.chinahtml.com/0708/""0"">"
   Response.Write "<PARAM NAME=""NOLABELS"" VALUE=http://www.chinahtml.com/0708/""0"">"
   Response.Write "<PARAM NAME=""SRC"" VALUE=http://www.chinahtml.com/0708/"""&strUrl&""">"
   Response.Write "<PARAM NAME=""CONTROLS"" VALUE=http://www.chinahtml.com/0708/""ImageWindow"">"
   Response.Write "<PARAM NAME=""CONSOLE"" VALUE=http://www.chinahtml.com/0708/""Clip"">"
   Response.Write "<PARAM NAME=""LOOP"" VALUE=http://www.chinahtml.com/0708/""0"">"
   Response.Write "<PARAM NAME=""NUMLOOP"" VALUE=http://www.chinahtml.com/0708/""0"">"
   Response.Write "<PARAM NAME=""CENTER"" VALUE=http://www.chinahtml.com/0708/""0"">"
   Response.Write "<PARAM NAME=""MAINTAINASPECT"" VALUE=http://www.chinahtml.com/0708/""0"">"
   Response.Write "<PARAM NAME=""BACKGROUNDCOLOR"" VALUE=http://www.chinahtml.com/0708/""#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=http://www.chinahtml.com/0708/""12700"">"
   Response.Write "<PARAM NAME=""_ExtentY"" VALUE=http://www.chinahtml.com/0708/""847"">"
   Response.Write "<PARAM NAME=""AUTOSTART"" VALUE=http://www.chinahtml.com/0708/""0"">"
   Response.Write "<PARAM NAME=""SHUFFLE"" VALUE=http://www.chinahtml.com/0708/""0"">"
   Response.Write "<PARAM NAME=""PREFETCH"" VALUE=http://www.chinahtml.com/0708/""0"">"
   Response.Write "<PARAM NAME=""NOLABELS"" VALUE=http://www.chinahtml.com/0708/""0"">"
   Response.Write "<PARAM NAME=""CONTROLS"" VALUE=http://www.chinahtml.com/0708/""ControlPanel,StatusBar"">"
   Response.Write "<PARAM NAME=""CONSOLE"" VALUE=http://www.chinahtml.com/0708/""Clip"">"
   Response.Write "<PARAM NAME=""LOOP"" VALUE=http://www.chinahtml.com/0708/""0"">"
   Response.Write "<PARAM NAME=""NUMLOOP"" VALUE=http://www.chinahtml.com/0708/""0"">"
   Response.Write "<PARAM NAME=""CENTER"" VALUE=http://www.chinahtml.com/0708/""0"">"
   Response.Write "<PARAM NAME=""MAINTAINASPECT"" VALUE=http://www.chinahtml.com/0708/""0"">"
   Response.Write "<PARAM NAME=""BACKGROUNDCOLOR"" VALUE=http://www.chinahtml.com/0708/""#000000"">"
   Response.Write "</OBJECT>"
 End Select
End If
End Sub

调用方式:

Call SelPlay(DvUrl,280,220)

标签: ASP 根据 视频 格式 正确 播放 函数


声明:本文内容来源自网络,文字、图片等素材版权属于原作者,平台转载素材出于传递更多信息,文章内容仅供参考与学习,切勿作为商业目的使用。如果侵害了您的合法权益,请您及时与我们联系,我们会在第一时间进行处理!我们尊重版权,也致力于保护版权,站搜网感谢您的分享!

站长搜索

http://www.adminso.com

Copyright @ 2007~2024 All Rights Reserved.

Powered By 站长搜索

打开手机扫描上面的二维码打开手机版


使用手机软件扫描微信二维码

关注我们可获取更多热点资讯

站长搜索目录系统技术支持