多媒体播放器
源代码在线查看: xplayer.ascx.cs
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;
using System.Text;
public partial class xPlayer : System.Web.UI.UserControl, System.Web.UI.ICallbackEventHandler
{
protected string returnValue = "default";
public string sCallBackFunctionInvocation;
protected void Page_Load(object sender, EventArgs e)
{
sCallBackFunctionInvocation = this.Page.ClientScript.GetCallbackEventReference(this, "message", "showClipDetail", "context", "OnError", false);
}
public void RaiseCallbackEvent(String eventArgument)
{
DataSet dsClipDetail = this.getClipDetailFromDB(eventArgument);
StringBuilder strDivHTML = new StringBuilder();
if (dsClipDetail.Tables[0].Rows.Count > 0)
{
strDivHTML.Append("");
strDivHTML.Append("");
strDivHTML.Append("");
strDivHTML.Append(string.Format("Details: {0}", dsClipDetail.Tables[0].Rows[0]["details"].ToString()));
strDivHTML.Append("");
strDivHTML.Append("");
strDivHTML.Append("");
}
else
strDivHTML.Append("details not available for media.");
returnValue = strDivHTML.ToString();
}
public string GetCallbackResult()
{
return returnValue;
}
protected DataSet getClipDetailFromDB(string ID)
{
DataSet tmpDs = new DataSet();
DataSet tmpDsVid = new DataSet();
tmpDsVid.Tables.Add("MediaByID");
tmpDsVid.Tables[0].Columns.Add("id");
tmpDsVid.Tables[0].Columns.Add("path");
tmpDsVid.Tables[0].Columns.Add("details");
try
{
tmpDs.ReadXml(Server.MapPath("~/xLitePlayer_data/xMediaPaths.xml"));
tmpDsVid = tmpDs.Clone();
for (int i = 0; i < tmpDs.Tables[0].Rows.Count; i++)
{
if (tmpDs.Tables[0].Rows[i]["id"].ToString() == ID)
{
DataRow dr = tmpDsVid.Tables[0].NewRow();
dr["details"] = tmpDs.Tables[0].Rows[i]["details"].ToString();
tmpDsVid.Tables[0].Rows.Add(dr);
break;
}
}
}
catch (Exception)
{
//TODO throw error;
}
return tmpDsVid;
}
}