/***************************************************
* 模块名称: 视频播放功能模块
* 创建人: 张洪桥
* 创建日期: 2007-03-30
* 涉及数据表:
* 最后修改人:
* 最后修改日期:
* 修改记录:
***************************************************/
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 VedioStudy_Play : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button1_Click(object sender, EventArgs e)
{
//VedioStudy_Play pc = new VedioStudy_Play();
Label1.Text = Play("Vedios/test.rmvb", 500, 450);
}
/// <summary>
/// 播放函数
/// </summary>
/// <param name="url">文件的相对路径</param>
/// <param name="width">视频宽度</param>
/// <param name="height">视频高度</param>
/// <returns></returns>
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")||strTmp.EndsWith(".rmvb"))
{
return rm(url, width, height);
}
//else if (strTmp.EndsWith(".rmvb"))
// {
// return rmvb(url,width,height);
// }
else
{
return "数据错误";
}
}
/// <summary>
/// wmv格式文件播放
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
private string wmv(string url, int width, int height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<object id=/"WMPlay/" style=/"WIDTH: " + width + "px;height:" + height + "px/" /n");
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("<param name=/"URL/" value='" + url + "'>/n");
sb.Append("<param name=/"controls/" value=/"ControlPanel,StatusBa/">");
//<PARAM NAME="CONTROLS" VALUE="ControlPanel,StatusBar">
sb.Append("<param name=/"hidden/" value=/"1/">");
sb.Append("<param name=/"ShowControls/" VALUE=/"0/">");
sb.Append("<param name=/"rate/" value=/"1/">/n");
sb.Append("<param name=/"balance/" value=/"0/">/n");
sb.Append("<param name=/"currentPosition/" value=/"-1/">/n");
sb.Append("<param name=/"defaultFrame/" value=/"/">/n");
sb.Append("<param name=/"playCount/" value=/"100/">/n");
sb.Append("<param name=/"autoStart/"