C# 视频播放类

复制代码 代码如下:

using System;
using System.Data;
using System.Configuration;
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;
///
/// PlayClass 的摘要说明
///

namespace ConfigTools
{
///
/// PlayClass 的摘要说明。
///原作CSDN,经本人稍加修改
///

public class PlayClass
{
public PlayClass()
{
//
// TOD 在此处添加构造函数逻辑
//
}
public string Play(string url,int width,int height)
{
string strTmp = url.ToLower();
if(strTmp.EndsWith(".wmv")||strTmp.EndsWith(".mp3")||strTmp.EndsWith(".wma")||strTmp.EndsWith(".avi")||strTmp.EndsWith(".asf")||strTmp.EndsWith(".mpg"))
{
return wmv(url,width, height);
}
else if(strTmp.EndsWith(".mp3"))
{
return mp3(url,width,height);
}
else if(strTmp.EndsWith(".swf"))
{
return swf(url,width, height);
}
else if(strTmp.EndsWith(".jpg")||strTmp.EndsWith(".gif"))
{
return img(url,width, height);
}
else if(strTmp.EndsWith(".rm"))
{
return rm(url,width, height);
}
else
{
return "数据错误";
}
}
///
/// wmv格式文件播放
///

///
///
private string wmv(string url, int width, int height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("sb.Append("classid=\"CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6\" type=application/x-oleobject standby=\"Loading Windows Media Player components...\"");
sb.Append("codebase=\"downloads/mediaplayer9.0_cn.exe\" VIEWASTEXT>\n");
sb.Append("\n");
sb.Append("");
//
sb.Append("");
sb.Append("");
sb.Append("\n");
sb.Append("\n");
sb.Append("\n");
sb.Append("\n");
sb.Append("\n");
sb.Append("\n");
sb.Append("\n");
sb.Append("\n");
sb.Append("\n");
sb.Append("\n");
sb.Append("\n");
sb.Append("\n");
sb.Append("\n");
sb.Append("\n");
sb.Append("\n");
sb.Append("\n");
sb.Append("\n");
sb.Append("\n");
sb.Append("\n");
sb.Append("\n");
sb.Append("\n");
sb.Append("

\n");
return sb.ToString();
}
private string wma(string url,int width, int height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
//sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("
");
return sb.ToString();
}
///
/// avi格式文件播放
///

///
///
private string avi(string url,int width, int height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("
");
return sb.ToString();
}
private string mpg(string url, int width, int height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("
");
return sb.ToString();
}
private string rm(string url, int width, int height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("");
sb.Append("");
//sb.Append("");
//sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
//sb.Append("");
sb.Append("
");
return sb.ToString();
}
private string swf(string url, int width, int height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("sb.Append(" height=\"" + height + "\" width=\"" + width + "\" >");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append(""); sb.Append("");
sb.Append("
");
return sb.ToString();
}
private string mp3(string url, int width, int height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("
");
return sb.ToString();
}
private string img(string url, int width, int height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("");
return sb.ToString();
}
}
}

你可能感兴趣的:(C# 视频播放类)