windows Media player 等avi,wmv,asf,mov,rm,ra,ram的Web播放

本文介绍了一段用于判断视频文件格式并根据不同格式输出相应播放代码的C#程序。该程序首先从URL中提取文件扩展名,然后根据扩展名确定视频类型,并针对不同类型的视频文件(如AVI、WMV、RM等)输出特定的HTML代码以实现网页内嵌播放。


        string Exts = string.Empty;
        string isExt = string.Empty;

        if (strUrl != "")
        {
            isExt = strUrl.Substring(strUrl.LastIndexOf('.') + 1).ToLower();
        }
        else
        {
            isExt = "";
        }

        Exts = "avi,wmv,asf,mov,rm,ra,ram";
        if (Exts.IndexOf("isExt") >= -1)
        {
            switch (isExt)
            {
                case "avi":
                case "wmv":
                case "asf":
                case "mov":
                    this.Response.Write("<EMBED id=MediaPlayer src=" + strUrl + " width=" + strWidth + "  height=" + StrHeight + " loop=false autostart=true ></EMBED>");
                    break;
                case "rm":
                case "ra":
                case "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>");
                    break;
            }
        }
        else
        {
            this.Response.Write("非法視頻文件");
        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值