Click here to Skip to main content
15,888,816 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionHow to upload a video in sql server 2005 then play it in asp.net Pin
Isaac Kit8-May-13 15:42
Isaac Kit8-May-13 15:42 
QuestionRe: How to upload a video in sql server 2005 then play it in asp.net Pin
Sandeep Mewara9-May-13 6:50
mveSandeep Mewara9-May-13 6:50 
AnswerRe: How to upload a video in sql server 2005 then play it in asp.net Pin
Isaac Kit9-May-13 11:10
Isaac Kit9-May-13 11:10 
AnswerRe: How to upload a video in sql server 2005 then play it in asp.net Pin
Isaac Kit9-May-13 11:39
Isaac Kit9-May-13 11:39 
SuggestionRe: How to upload a video in sql server 2005 then play it in asp.net Pin
ZurdoDev10-May-13 7:16
professionalZurdoDev10-May-13 7:16 
GeneralRe: How to upload a video in sql server 2005 then play it in asp.net Pin
Isaac Kit11-May-13 8:44
Isaac Kit11-May-13 8:44 
SuggestionRe: How to upload a video in sql server 2005 then play it in asp.net Pin
ZurdoDev13-May-13 1:58
professionalZurdoDev13-May-13 1:58 
GeneralRe: How to upload a video in sql server 2005 then play it in asp.net Pin
Isaac Kit15-May-13 4:44
Isaac Kit15-May-13 4:44 
Thank You Ryan. the URL is getting set correctly but I can't watch any kind of video
here are all steps I tried
A. I use those code for the aspx interface

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ITube._Default" %>

<%@ Register src="UploadVideo.ascx" tagname="UploadVideo" tagprefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

<uc1:UploadVideo ID="UploadVideo1" runat="server" />

</div>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Artists.aspx">HyperLink</asp:HyperLink>
<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="~/test2.aspx">HyperLink</asp:HyperLink>
<br />
<br />
<asp:Button ID="ButtonShowVideo" runat="server" onclick="ButtonShowVideo_Click"
Text="Show Video" />
<br />
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<object id="player" classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6"
height="170" width="300">
<param name="url" value='<%# "Handler1.ashx?id=" + Eval("ID") %>'/>
<param name="showcontrols" value="true" />
<param name="autostart" value="true" />
</object>
</ItemTemplate>
</asp:Repeater>
<%--<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>

<object id="MediaPlayer" height="200" width="300" classid="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6" TYPE="application/x-oleobject">
<%--<param name="FileName" value="video.axd?videoid=MyPostID">
<param name="url" value='<%# "Handler1.ashx?id=" + Eval("ID") %>'/>
<param name="autostart" value="true">
<param name="ShowControls" value="true">
<embed type="application/x-mplayer2" src="video.axd?videoid=MyPostID" name="MediaPlayer"
height="400" width="500" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="1"> </embed>
<%--<object id="player" classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" height="170" width="300">
<param name="url" value='<%# "Handler1.ashx?id=" + Eval("ID") %>'/>
<param name="showcontrols" value="true" />
<param name="autostart" value="true" />
</object>
</ItemTemplate>
</asp:Repeater>--%>
<%--<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<u>
<%# Eval("Video_Name") %></u>
<hr />
<a class="player" style="height: 300px; width: 300px; display: block" href='<%# "Handler1.ashx?id=" + Eval("ID") %>'/>
</a>
<%--</ItemTemplate>--%>

<%--<param name="filename" value ="a.MP4"/>
<PARAM name="autostart" VALUE="true"/>
<PARAM name="ShowControls" VALUE="true"/>
<param name="ShowStatusBar" value="true"/>
<PARAM name="ShowDisplay" VALUE="true"/>
</object>
</ItemTemplate>
</asp:Repeater>--%>
<br />
<br />
<br />
<asp:Button ID="ButtonBind" runat="server" onclick="ButtonBind_Click"
Text="Bind" />
<asp:GridView ID="GridView1" runat="server" BackColor="White"
BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4"
ForeColor="Black" GridLines="Vertical">
<footerstyle backcolor="#CCCC99" />
<rowstyle backcolor="#F7F7DE" />
<Columns>
<asp:templatefield>

<ItemTemplate>
<u>
<%# Eval("Video_Name") %></u>
<hr />
<a class="player" style="height: 300px; width: 300px; display: block" href='<%# "Handler1.ashx?id=" + Eval("ID") %>'/>
</a>
</ItemTemplate>


</asp:templatefield>
</Columns>
<pagerstyle backcolor="#F7F7DE" forecolor="Black" horizontalalign="Right" />
<selectedrowstyle backcolor="#CE5D5A" font-bold="True" forecolor="White" />
<headerstyle backcolor="#6B696B" font-bold="True" forecolor="White" />
<alternatingrowstyle backcolor="White" />
</asp:GridView>
<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>
</form>
</body>
</html>

///////////////////

B. and for the aspx.cs

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Data.SqlClient;
namespace ITube
{
public partial class _Default : System.Web.UI.Page
{


protected void Page_Load(object sender, EventArgs e)
{

}



protected void ButtonShowVideo_Click(object sender, EventArgs e)
{
Repeater1.DataSource = GetSpecificVideo(8);
//the video id (2 is example)

Repeater1.DataBind();

}

protected void ButtonBind_Click(object sender, EventArgs e)
{
GridView1.DataSource = GetVideoInfo();
GridView1.DataBind();
}
private DataTable GetVideoInfo()
{
string connectionString = ConfigurationManager.ConnectionStrings["uploadConnectionString"].ConnectionString;
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM VideoArts", connectionString);
DataTable table = new DataTable();
adapter.Fill(table);
return table;
}
private DataTable GetSpecificVideo(object i)
{
string connectionString = ConfigurationManager.ConnectionStrings["uploadConnectionString"].ConnectionString;
SqlDataAdapter adapter = new SqlDataAdapter("SELECT Video, ID FROM VideoArts WHERE ID = @id", connectionString);
adapter.SelectCommand.Parameters.Add("@id", SqlDbType.Int).Value = (int)i;
DataTable table = new DataTable();
adapter.Fill(table);
return table;
}

}
}
}

C. and for the Handler1.ashx i use those codes

//<%@ WebHandler Language="C#" Class="VideoHandler" %>

using System;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

//using System;
//using System.Collections;
//using System.Data;
//using System.Linq;
//using System.Web;
//using System.Web.Services;
//using System.Web.Services.Protocols;
//using System.Xml.Linq;
//using System.Data.SqlClient;
//using System.Configuration;



namespace ITube
{
/// <summary>
/// Summary description for $codebehindclassname$
/// </summary>
//[WebService(Namespace = "http://tempuri.org/")]
//[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Handler1 : IHttpHandler
{

public void ProcessRequest(HttpContext context)
{
// context.Response.ContentType = "text/plain";
// context.Response.Write("Hello World");
string connectionString = ConfigurationManager.ConnectionStrings["uploadConnectionString"].ConnectionString;
// string connectionString = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;

SqlConnection connection = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand("SELECT Video, Video_Name" + " FROM VideoArts WHERE ID = @id", connection);
cmd.Parameters.Add("@id", SqlDbType.Int).Value = context.Request.QueryString["id"];
try
{
connection.Open();
SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default);
if (reader.HasRows)
{
while (reader.Read())
{
context.Response.ContentType = reader["Video_Name"].ToString();
context.Response.BinaryWrite((byte[])reader["Video"]);
}
}
}
finally
{
connection.Close();
}

}

public bool IsReusable
{
get
{
return true;
}
}
}
}

D. to the upload interface UploadVideo.ascx


<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UploadVideo.ascx.cs" Inherits="ITube.UploadVideo" %>
<head>
<style type="text/css">
.style1
{
width: 100%;
}
</style>
</head>
<table class="style1">
<tr>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" />
</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td>
<asp:Button ID="ButtonUpload" runat="server" onclick="ButtonUpload_Click"
Text="Upload" />
</td>
<td width="50%">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</td>
</tr>
</table>

//////////////////////////////////
but when I try to upload a video sometime it accept but for a mp4 video format it refuse
another problem when i want to watch a video, for some videos it just play the sound but no video.
Another thing is it possible that people can see howmany time a video was played on my playlist?
QuestionDrag Object From User's Computer into Webpage Pin
ASPnoob8-May-13 12:48
ASPnoob8-May-13 12:48 
AnswerRe: Drag Object From User's Computer into Webpage Pin
Blikkies8-May-13 21:53
professionalBlikkies8-May-13 21:53 
GeneralRe: Drag Object From User's Computer into Webpage Pin
ASPnoob8-May-13 22:07
ASPnoob8-May-13 22:07 
GeneralRe: Drag Object From User's Computer into Webpage Pin
Blikkies8-May-13 22:17
professionalBlikkies8-May-13 22:17 
GeneralRe: Drag Object From User's Computer into Webpage Pin
ASPnoob8-May-13 23:03
ASPnoob8-May-13 23:03 
QuestionHelp with SmarterStats web services Pin
Jassim Rahma8-May-13 12:03
Jassim Rahma8-May-13 12:03 
QuestionODP.Net provider error Pin
vanikanc8-May-13 7:09
vanikanc8-May-13 7:09 
AnswerRe: ODP.Net provider error Pin
Jasmine25018-May-13 7:48
Jasmine25018-May-13 7:48 
GeneralRe: ODP.Net provider error Pin
vanikanc8-May-13 7:59
vanikanc8-May-13 7:59 
GeneralRe: ODP.Net provider error Pin
Jasmine25018-May-13 9:07
Jasmine25018-May-13 9:07 
Questionwhich is the best practice to generate report in pdf format using ASP.NET MVC3? Pin
manoj.jsm8-May-13 0:20
manoj.jsm8-May-13 0:20 
Questionexpansion of axd in trace.axd Pin
Member 87018137-May-13 21:28
Member 87018137-May-13 21:28 
QuestionRe: expansion of axd in trace.axd Pin
Sandeep Mewara7-May-13 22:41
mveSandeep Mewara7-May-13 22:41 
AnswerRe: expansion of axd in trace.axd Pin
Member 870181310-May-13 7:46
Member 870181310-May-13 7:46 
QuestionHow to Display image with Grideview Pin
langpolen7-May-13 20:55
langpolen7-May-13 20:55 
AnswerRe: How to Display image with Grideview Pin
Sandeep Mewara7-May-13 22:42
mveSandeep Mewara7-May-13 22:42 
AnswerRe: How to Display image with Grideview Pin
AANIL DHAKAD8-May-13 2:56
AANIL DHAKAD8-May-13 2:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.