通用的网页上的播放本地视频文件
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class WebForm2 : System.Web.UI.Page


{
public string DvUrl;
protected void Page_Load(object sender, EventArgs e)

{
if (!Page.IsPostBack)

{
//string DvUrlS = Request.QueryString["FilePath"].ToString();
//DvUrl += "CamFiles/" + DvUrlS;
DvUrl = "E:\\grindingdemo.mpg";//指定文件路径
SelPlay(DvUrl, 380, 320);
}
}
protected void SelPlay(string strUrl, int strWidth, int StrHeight)

{
string isExt;
if (strUrl != "")

{
int i = strUrl.LastIndexOf(".");
isExt = strUrl.Substring(i + 1, strUrl.Length - i - 1);

}
else

{
Response.Write("<script>alert(\'所选择的影音文件不存在!\');</script>");
return;
}
isExt = isExt.ToLower();
switch (isExt)

{
case "avi":
case "wmv":
case "asf":
case "mov":
Response.Write("<EMBED id=MediaPlayer src=\'" + strUrl + "\' width=\'" + strWidth + "\' height=\'" + StrHeight + "\' loop=\'false\' autostart=\'true\'></EMBED>");
break;
case "rm":
case "ra":
case "rmvb":
case "ram":

/**//*
就是 RealPlay 的播放列表.
可以用记事本新建一个文本文件, 重命名为 ***.ram,
然后其中的内容每个播放文件占一行, 格式如下:
file://路径名\文件名

例如:
file://E:\Private\Favourite\track01.mp3
file://E:\Private\Favourite\track02.mp3

双击它时, RealPlay 按照列表里面的文件顺序播放.

*
*/
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;
case "swf":

case "flv":

Response.Write("<OBJECT codeBase=\'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0\' classid=\'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\' width=\'" + strWidth + "\' height=\'" + StrHeight + "\'> ");
Response.Write("<PARAM NAME=\'movie\' VALUE=\'" + strUrl + "\'> ");
Response.Write("<PARAM NAME=\'play\' VALUE=\'false\'> ");
Response.Write("<PARAM NAME=\'quality\' VALUE=\'high\'> ");
Response.Write("<embed src=\'" + strUrl + "\' quality=\'high\' pluginspage=\'http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\' type=\'application/x-shockwave-flash\' width=\'" + strWidth + "\' height=\'" + StrHeight + "\'></embed> ");
Response.Write("</OBJECT> ");
break;
case "mpg":
Response.Write("<object classid=\'clsid:05589FA1-C356-11CE-BF01-00AA0055595A\' id=\'ActiveMovie1\' width=\'" + strWidth + "\' height=\'" + StrHeight + "\'>");
Response.Write("<param name=\'Appearance\' value=\'0\'>");
Response.Write("<param name=\'AutoStart\' value=\'-1\'>");
Response.Write("<param name=\'AllowChangeDisplayMode\' value=\'-1\'>");
Response.Write("<param name=\'AllowHideDisplay\' value=\'0\'>");
Response.Write("<param name=\'AllowHideControls\' value=\'-1\'>");
Response.Write("<param name=\'AutoRewind\' value=\'-1\'>");
Response.Write("<param name=\'Balance\' value=\'0\'>");
Response.Write("<param name=\'CurrentPosition\' value=\'0\'>");
Response.Write("<param name=\'DisplayBackColor\' value=\'0\'>");
Response.Write("<param name=\'DisplayForeColor\' value=\'16777215\'>");
Response.Write("<param name=\'DisplayMode\' value=\'0\'>");
Response.Write("<param name=\'Enabled\' value=\'-1\'>");
Response.Write("<param name=\'EnableContextMenu\' value=\'-1\'>");
Response.Write("<param name=\'EnablePositionControls\' value=\'-1\'>");
Response.Write("<param name=\'EnableSelectionControls\' value=\'0\'>");
Response.Write("<param name=\'EnableTracker\' value=\'-1\'>");
Response.Write("<param name=\'Filename\' value=\'" + strUrl + "\' valuetype=\'ref\'>");
Response.Write("<param name=\'FullScreenMode\' value=\'0\'>");
Response.Write("<param name=\'MovieWindowSize\' value=\'0\'>");
Response.Write("<param name=\'PlayCount\' value=\'1\'>");
Response.Write("<param name=\'Rate\' value=\'1\'>");
Response.Write("<param name=\'SelectionStart\' value=\'-1\'>");
Response.Write("<param name=\'SelectionEnd\' value=\'-1\'>");
Response.Write("<param name=\'ShowControls\' value=\'-1\'>");
Response.Write("<param name=\'ShowDisplay\' value=\'-1\'>");
Response.Write("<param name=\'ShowPositionControls\' value=\'0\'>");
Response.Write("<param name=\'ShowTracker\' value=\'-1\'>");
Response.Write("<param name=\'Volume\' value=\'-480\'>");
Response.Write("</object>");
break;
case "smi":
Response.Write("<OBJECT id=RVOCX classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA width=\'" + strWidth + "\' height=\'" + StrHeight + "\'>");
Response.Write("<param name=\'_ExtentX\' value=\'6350\'>");
Response.Write("<param name=\'_ExtentY\' value=\'4763\'>");
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=\'-1\'>");
Response.Write("<param name=\'SRC\' value=\'" + strUrl + "\'>");
Response.Write("<param name=\'CONTROLS\' value=\'ImageWindow\'>");
Response.Write("<param name=\'CONSOLE\' value=\'console1\'>");
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("<embed src=\'" + strUrl + "\' type=\'audio/x-pn-realaudio-plugin\' console=\'Console1\' controls=\'ImageWindow\' height=\'" + StrHeight + "\' width=\'" + strWidth + "\' autostart=\'true\'>");
Response.Write("</OBJECT>");
break;
}

}
}

aspx可以是空的:

<%
@ Page Language="C#" AutoEventWireup="true" CodeFile="WebForm2.aspx.cs" Inherits="WebForm2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
相关文章:
-
2021-10-31
-
2021-11-25
-
2021-11-12
-
2022-12-23
-
2022-01-26
猜你喜欢
-
2022-02-14
-
2021-10-27
-
2021-12-12
-
2021-08-26
-
2021-05-31
相关资源
-
下载
2022-12-19
-
下载
2022-12-30
-
下载
2022-12-16
-
下载
2021-06-27
-
下载
2023-01-13