Asp.net calls the windows automatic player Media player

Source: Internet
Author: User

Front-end code

<Embed src = "<% = VUrl %>" noerror = "true" style = "width: 579px; height: 321px"> </embed>

 

Background code

// Watch the video
Protected void seeVi ()
{
Try
{
String SQL = "select * from tb_Video where VideoID =" + Convert. ToInt32 (Request. QueryString ["VideoID"]);
OleDbDataReader odr = mydo. row (SQL); // call the row Method in the database operation class
Odr. Read (); // a previous record
VUrl = "Video" + "\" + odr ["VideoUrl"]. ToString (); // path for storing the Video tutorial
If (! File. Exists (Server. MapPath (".") + "\" + VUrl) // you can check whether this tutorial Exists.
{
String dlsql = "delete from tb_Video where VideoID =" + Convert. ToInt32 (Request. QueryString ["VideoID"]);
Mydo. adlData (dlsql );
Page. RegisterStartupScript ("true", "<script> alert ('the file does not exist! Please return! '); Location = 'index. aspx' </script> ");
}
VideoTitle = odr ["VideoName"]. ToString ();
Content = odr ["VideoContent"]. ToString ();
Name = odr ["Name"]. ToString ();
FBDate = odr ["FBDate"]. ToString ();
ClickSum = odr ["ClickSum"]. ToString ();
}
Catch (Exception ex)
{
Response. Write (ex. Message. ToString ());
}
}

File Download:

If (Session ["UserName"]! = Null)
{
String path = Server. MapPath (". \") + VUrl;
// Initialize the FileInfo class instance, which is packaged as the file path
FileInfo fi = new FileInfo (path );
Response. Write (path );
// Determine whether a file exists
If (fi. Exists)
{
// Save the file to the Local Machine
Response. Clear ();
Response. AddHeader ("Content-Disposition", "attachment; filename =" + Server. UrlEncode (fi. Name ));
Response. AddHeader ("Content-Length", fi. Length. ToString ());
Response. ContentType = "application/octet-stream ";
Response. Filter. Close ();
Response. WriteFile (fi. FullName );
Response. End ();
}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.