在aspx页面或浏览器上播放视频 [英] Play video on aspx page or browser

查看:669
本文介绍了在aspx页面或浏览器上播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够将视频和图像保存在sql数据库中,也可以在存储在数据库中的浏览器上成功显示图像。唯一的问题是视频文件。我无法检索它们并显示在aspx页面(浏览器)上。

以下是我用来将视频文件保存在数据库中的示例代码。任何人都可以建议我检索和播放它们的任何选项。

Hi, I am able to save the video and the images in the sql database, also I can successfully display the images on browser once stored in the database. The only problem is with the video files. I am unable to retrieve them and display on the aspx page(browser).
Below is the sample code used by me to save the video files in database. Could any one suggest me any options to retrieve and play them.

private DataTable GetVideoInfo()
{
    string connectionString = @"MyDatabase";
    SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM VTable", connectionString);
    DataTable table = new DataTable();
    adapter.Fill(table);
    return table;
}

private DataTable GetSpecificVideo()
{
    string connectionString = @"MyDatabase";
    SqlDataAdapter adapter = new SqlDataAdapter("SELECT ID FROM VTable", connectionString);
    //adapter.SelectCommand.Parameters.Add("@ID", SqlDbType.Int).Value = (int)i;
    DataTable table = new DataTable();
    adapter.Fill(table);
    return table;
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{

}

private DataTable GetSpecificVideo(object i)

//pass the id of the video
{

    connection = new SqlConnection("MyDatabase");

    SqlDataAdapter adapter = new SqlDataAdapter("SELECT Video, ID " + "FROM Vtable WHERE ID = @id", connection);

    adapter.SelectCommand.Parameters.Add("@id", SqlDbType.Int).Value = (int)i;

    DataTable table = new DataTable();

    adapter.Fill(table);

    return table;

}

public SqlConnection connection { get; set; }
protected void Button1_Click(object sender, EventArgs e)
{
    
    int id = Convert.ToInt32(TextBox2.Text);
    Repeater1.DataSource = GetSpecificVideo(id);
    Repeater1.DataBind();
}
}

推荐答案

我不知道为什么你可以存储和检索图像而不是视频文件;没有区别。但是,对于ASP.NET应用程序,我建议将图像和视频文件作为文件保存在服务器端文件系统中,使用一组唯一名称,并将这些名称存储在数据库中。



对于玩游戏,您首先可以使用HTML5 < video> 元素: https://en.wikipedia.org/wiki/HTML5_video [ ^ ]。



-SA
I have no idea why you can store and retrieve images but not video files; there is no difference. However, for ASP.NET applications, I would recommend to keep both images and video files as file in the server-side file system, under some set of unique names, and store just those names in your database.

For playing you can use, first of all, HTML5 <video> element: https://en.wikipedia.org/wiki/HTML5_video[^].

—SA


这篇关于在aspx页面或浏览器上播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆