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)
上一篇: C语言空指针NULL以及void指针
下一篇: Node.js 学习笔记(1)