Display and play MP4 Videos using File Path stored in database using ASP.Net DataList

farzanet
 
on Mar 08, 2014 05:40 AM
26048 Views

I want use flowplayer to paly my flv video file. i have a datalist like below :

 

<asp:DataList ID="frmViedo" runat="server">
<ItemTemplate>
    <div class="flowplayer">
       <video>
           <source type="video/flv" src='<%# Eval("Vurl" , "~/Videos/Video/{0}") %>'>
       </video>
    </div>
</ItemTemplate>
</asp:DataList>

in code behind :

 

if (Request.QueryString["vid"] != null)
{
    frmViedo.DataSource = video.GetVideoById(Convert.ToInt32(Request.QueryString["vid"]));
    frmViedo.DataBind();
}

 

public OleDbDataReader GetVideoById(int id)
{
    string strSelect = "select * from Video where VID = @VID";
    return ExecuteReader(CommandType.Text, strSelect, new OleDbParameter[]{
        new OleDbParameter("@VID" , id),
    });
}

but it don't work and i get this error :

 

Adobe Flash is disabled for this page, click player area to enable.

why?

 

Thanks.

Download FREE API for Word, Excel and PDF in ASP.Net: Download
Mudassar
 
on Mar 10, 2014 12:00 AM
on Mar 14, 2014 05:11 AM

I have modified the sample code from the article Upload Save Retrieve and Play MP4 Video files with live streaming from Database in ASP.Net using C# and VB.Net

1. Save Videos to some folder in your website as shown below.

2. Then add the file details and path to database.

3. Then use the below codes

HTML

<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" />
<hr />
<asp:DataList ID="DataList1" Visible="true" runat="server" AutoGenerateColumns="false"
    RepeatColumns="2" CellSpacing="5">
    <ItemTemplate>
        <u>
            <%# Eval("Name") %></u>
        <hr />
        <a class="player" style="height: 300px; width: 300px; display: block" href='<%# Eval("Path") %>'>
        </a>
    </ItemTemplate>
</asp:DataList>
<script src="FlowPlayer/flowplayer-3.2.12.min.js" type="text/javascript"></script>
<script type="text/javascript">
    flowplayer("a.player", "FlowPlayer/flowplayer-3.2.16.swf", {
        plugins: {
            pseudo: { url: "FlowPlayer/flowplayer.pseudostreaming-3.2.12.swf" }
        },
        clip: { provider: 'pseudo', autoPlay: false},
    });
</script>

Namespaces

using System.IO;
using System.Data.SqlClient;
using System.Configuration;

Code

  protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindGrid();
        }
    }

    private void BindGrid()
    {
        string strConnString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
        using (SqlConnection con = new SqlConnection(strConnString))
        {
            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.CommandText = "select Id, Name, Path from tblFilePaths";
                cmd.Connection = con;
                con.Open();
                DataList1.DataSource = cmd.ExecuteReader();
                DataList1.DataBind();
                con.Close();
            }
        }
    }

Screenshot