Click here to Skip to main content
14,421,436 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi Evry one, I am trying to code a web application for videos and musics, I got stack on trying to upload Video’s path in the database and the system is not giving any error but the browser is just freezing. I can easily upload songs and pictures but the other major problem is with songs paths they’r no playing when I bind them to the repeater. Bellow is my project sample codes:Table, Stored Procedures, NewSoundClass, Main codes and Source code. I am using TableAdapter.
If any one can help please, I'll really appreciate it ..pls,pls
Help also with the codes for downloading music and videos.

Table TBSound

Col_Name		Data_Type		AllowNull
SoundId		int			Unchecked
SoundName		nvarchar(50)	Checked
Soundstream		nvarchar(MAX)	Checked


I have two store procedures:

1.	ALTER PROCEDURE dbo.SaveM
(
	@SoundName nvarchar(50),
	@Soundstream nvarchar(MAX)
)
AS
	SET NOCOUNT OFF;
INSERT INTO [dbo].[TBSound] ([SoundName], [Soundstream]) VALUES (@SoundName, @Soundstream);
	
-	SELECT SoundId, SoundName, Soundstream FROM TBSound WHERE (SoundId = SCOPE_IDENTITY())
-----------------------------------------------------------------------------
2.	ALTER PROCEDURE dbo.SelectQuerySound
(
	@SoundId int
)
AS
	SET NOCOUNT ON;
SELECT        Soundstream
FROM            TBSound
1.	WHERE        (SoundId = @SoundId)


Here bellow is my class where I call my stored procedures using TableAdapter

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for NewSound
/// </summary>
public class NewSound
{
    SoundDataSet1TableAdapters.TBSoundTableAdapter MyVid = new SoundDataSet1TableAdapters.TBSoundTableAdapter();  
	public NewSound()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public bool SaveMed(string SoundName, string SoundStream)
    {
        int MySound = MyVid.SaveM(SoundName, SoundStream);
        return MySound == 1;
    }
    public SoundDataSet1.TBSoundDataTable SearchM(int SoundId)
    {
        return MyVid.GetDataBySound(SoundId); 
    }
}

My Main Codes
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;  

public partial class _Default : System.Web.UI.Page 
{
    NewSound VidSound = new NewSound();
 
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSaveUpload_Click(object sender, EventArgs e)
    {
       //string stream = File.ReadAllBytes(FileUpload1.PostedFile.FileName);

       string FileName = Path.GetFileName(FileUpload1.FileName);

       //Save files to disk
       FileUpload1.SaveAs(Server.MapPath("Videos/" + FileName));

            //File.ReadAllBytes(@"d:\m.flv");
       VidSound.SaveMed(TextBox1.Text,FileName);  
        
        //com.Parameters.AddWithValue("@voice", stream);

    }
    protected void btnRepeater_Click(object sender, EventArgs e)
    {
        RepeatData.DataSource = VidSound.SearchM(Convert.ToInt32(TextBox1.Text));
        RepeatData.DataBind();  
    }
}

Source Codes
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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></title>
    
</head>
<body>
    <form id="form1"  runat="server">
    <div>
    
        <table class="style1">
            <tr>
                <td>
                     </td>
                <td class="style2" colspan="3">
                    Inserting Sound And Video in the Database</td>
                
            <tr>
                <<br mode="hold" />                <td class="style3">
                    <asp:TextBox ID="TextBox1" runat="server">
                </td>
                <td colspan="2">
                    <asp:FileUpload ID="FileUpload1" runat="server" />
                </td>
                
                <td>
                     </td>
                <td class="style3">
                    <asp:Label ID="Label1" runat="server" Text="Label">
                </td>
                <td>
                    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
                    <asp:Button ID="Button2" runat="server" onclick="Button2_Click" 

                        Text="Repeater" />
                <td>
                    <asp:Repeater ID="RepeatData" runat="server">
                    <itemtemplate>
            <object id="player" 

                       classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" 

                       height="170" width="300">
                <param name="url">
                  value='<%# "VideoHandler.ashx?id=" + Eval("SoundId") %>'/>
                <param name="showcontrols" value="true" />
                <param name="autostart" value="true" />
            </object>
        </param></itemtemplate>
            </td></td></tr>
        </tr></table>
    
    </div>
    </form>
</body>
</html>



the idea is to have by the end a gridview that look like this:

Sound Id	Sound Name	View/Listen	Get it
01	        Single Lady	Play	        Download
Posted
Updated 31-Dec-13 4:07am
v2
Comments
ZurdoDev 31-Dec-13 8:53am
   
What's your question exactly?
Nelek 31-Dec-13 9:36am
   
See the title of the message. ;P
ZurdoDev 31-Dec-13 9:45am
   
Ah yes, so clear. :)
   
What is exactly happening when the code executes? When you click on Play button what happens?
Member 10490380 2-Jan-14 9:38am
   
When I click on play button the repeater is not palying the son or the video, so pls i need a help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100