2

i have a code that uploads my videos on a folder and its file path is stored in the sql server database.

i dont know how to play the video on another seperate page

any help or code would be much appreciated.

the following is my upload code

protected void btnInvoke_Click(object sender, EventArgs e)
    { 
        string name = FileUpload1.PostedFile.FileName;
        string ext = System.IO.Path.GetExtension(this.FileUpload1.PostedFile.FileName);
        if (FileUpload1.PostedFile.ContentLength == 0)
        { 
            Label1.Text = "Cannot upload zero length file";
        }

        if (ext == ".wmv" || ext == ".flv" || ext == ".avi" || ext == ".mp4" || ext == ".3GP" || ext == ".wma")
        {
            DateTime dt = DateTime.Now;
            string tme = dt.ToLongTimeString();
            string[] t = tme.Split(':');

            string y = "";
            foreach (string x in t)
            {
                y += x;
            }

            string aa = y + "_" + name;

            string Video = FileUpload1.FileName;
            string folder_path = Server.MapPath("~\\Video\\");
            FileUpload1.SaveAs(folder_path + Video);

            string loc = aa;
            //Session["location1"] = loc;
            SqlConnection sqlconn = new SqlConnection("Data Source=137.158.107.212;Initial Catalog=VideoDatabase;Persist Security Info=True;User ID=G0;Password=*********.");
            SqlCommand sqlcomm = new SqlCommand("videoupload2", sqlconn);
            sqlcomm.CommandType = CommandType.StoredProcedure;

            sqlcomm.Parameters.Add("@video_name", SqlDbType.VarChar, 200).Value = videonametextbox.Text;
            sqlcomm.Parameters.Add("@video_loc", SqlDbType.VarChar, 500).Value = loc;
            sqlcomm.Parameters.Add("@video_language", SqlDbType.VarChar, 200).Value = languagetextbox.Text;

            sqlconn.Open();
            sqlcomm.ExecuteNonQuery();
            sqlconn.Close();

            Label2.Text = "Video Song uploaded Successfully";
        }
        else
        {
            Label2.Text = "please choose video file";
        }
    }

1 Answer 1

1

You can pass the path of your videos to a free Video player such as FlowPlayer. (Free only for non-commercial sites).

Step 1: To include file flowplayer-3.2.12.min.js in the web page you place the following tag in the HEAD section of your web page:

<script src="path/to/the/flowplayer-3.2.12.min.js"></script>

To place the link to your video file in the web page, the simplest way is to use the following A tag on your web page. The video will automatically play there:

<a href="http://www.mywebsite.com/myVideo.flv"
   style="display:block;width:425px;height:300px;"
   id="player">
</a>

Step 3: Finally, to load the player on the A tag just described, you place the following script in your page, following the A tag:

<script language="JavaScript">
  flowplayer("player", "path/to/the/flowplayer-3.2.16.swf");
</script>
Sign up to request clarification or add additional context in comments.

6 Comments

I guess he is going to need some encoding of the uploaded videos to use FlowPlayer
hi, ok i understand how to load the tag for the flow player, but how do i call a specific video from the database to play?
I assume you save the full path of the video in the filesystem into the database right? You can use this path.
so do i type below flowplayer value = "~/Video/"
Yes, and append the filename + file extension
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.