【发布时间】:2012-05-25 18:46:50
【问题描述】:
protected void Button2_Click(object sender, EventArgs e)
{
UploadLogic bl = new UploadLogic();
input = ListBox1.SelectedIndex >= 0 ? ListBox1.SelectedItem.ToString() : "";
DataSet ds = new DataSet();
ds = bl.Content_details(input);
if (ds.Tables[0].Rows.Count > 0)
{
Byte[] bytes = (Byte[])ds.Tables[0].Rows[0].ItemArray.GetValue(3);
Response.Buffer = true;
Response.Charset = "utf-16";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1250");
Response.ContentType = ds.Tables[0].Rows[0].ItemArray.GetValue(2).ToString();
Response.AddHeader("content-disposition", string.Format("File_Path; filename={0}", input));
Response.OutputStream.Write(bytes, 0, input.Length);
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
}
else
{
Label1.Text = "No File Found..!";
}
}
我编写了这段代码,但它只从数据库下载文件。如果我想播放音频和视频,那我该怎么做呢?
【问题讨论】:
-
我想我没看错,播放媒体文件有几种方法,一种是使用Flash,你可以很容易地搜索Flash播放器,然后你可以在你的HTML中嵌入一个,也有针对这种情况的 JaveScript 解决方案,但是由于您想在服务器端代码中设置源文件,因此最好使用 Flash 播放器