Click here to Skip to main content
15,907,395 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I want to insert video player in my asp page.what is the code for video player in asp.net and how can i upload videos int that player..
Posted

<head>
    <title>Flash Video</title>
</head>
<body>
    @Video.Flash(path: "Media/sample.swf",
                 width: "400",
                 height: "600",
                 play: true,
                 loop: true,
                 menu:  false,
                 bgColor: "red",
                 quality: "medium",
                 scale: "exactfit",
                 windowMode: "transparent")
</body>
 
Share this answer
 
Upload Video
C#
protected void btnSub_Click(object sender, EventArgs e)
    {
        try
        {
            UploadVideo obj = new UploadVideo();
            string filename = fuUploadVideo.FileName;
            string path = Server.MapPath("Uploads4");
            string strFinalFileName = Path.GetFileName(fuUploadVideo.FileName);
            long FileLength = fuUploadVideo.PostedFile.ContentLength;
            long uploadchunklimit;
            int SizeLimit = (int)FileLength;
            if (FileLength <= 1024)
            {
                uploadchunklimit = 1;
                SizeLimit = (int)FileLength;
            }
            else if (FileLength > 1024)
            {
                uploadchunklimit = FileLength / 1024;
                SizeLimit = 10;
            }
            else if (FileLength <= 10240 && FileLength > 1024)
            {
                uploadchunklimit = FileLength / 1024;
            }
            else
            {
                uploadchunklimit = FileLength / 1024;
            }

            long lngSize = (long)SizeLimit;
            lngSize = 1024 * 1024;
            string ext = Path.GetExtension(fuUploadVideo.PostedFile.FileName);
            
            fuUploadVideo.PostedFile.SaveAs(Server.MapPath("Uploads4\\" + filename));
            path = "Uploads4\\" + filename;
            SqlConnection con = new SqlConnection(str);
           
            cmd = new SqlCommand("Insert into electronicmedia(Video_Name,url) values(@Video,'" + path + "')", con);
            cmd.Parameters.AddWithValue("Video", TextBox2.Text);
            cmd.CommandType = CommandType.Text;
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
            lblinfo.Text = " uploaded successfully ";
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
        }


for playing
C#
<embed id='embed1' runat="server" name='mediaPlayer' type='application/x-mplayer2' pluginspage='http://microsoft.com/windows/mediaplayer/en/download/'  displaysize='4' autosize='-1' bgcolor='darkblue' showcontrols='true' showtracker='-1' showdisplay='0' showstatusbar='-1' videoborder3d='-1' width='500' height='405'  designtimesp='5311' loop='false'>


   </embed>


fetch data in datalist and use itemCommand event
C#
protected void DataList1_ItemCommand1(object source, DataListCommandEventArgs e)
  {
      try
      {
          if (e.CommandName == "select")
          {
              string path = e.CommandArgument.ToString().Trim();
              embed1.Attributes.Add("src", e.CommandArgument.ToString().Trim());
              this.modal1.Show();
          }
      }
      catch (Exception ex)
      {
          Response.Write(ex.ToString());
      }
  }
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900