. Net audio file upload and playback code

Source: Internet
Author: User


Public static string GetFlashText (string url)
{
String str = @ "<object id = 'mediaplayer' classid = 'clsid: 6BF52A52-394A-11D3-B153-00C04F79FAA6 'height = '62 'width = '2016'>
<Param name = 'rate' value = '1'/>
<Param name = 'balance 'value = '0'/>
<Param name = 'currentposition' value = '0'/>
<Param name = 'defaultframe 'value = ''/>
<Param name = 'playcount' value = '1'/>
<Param name = 'autostart' value = '-1'/>
<Param name = 'currentmarker' value = '0'/>
<Param name = 'invokeurls' value = '-1'/>
<Param name = 'baseurl' value = ''/>
<Param name = 'Volume 'value = '2'/>
<Param name = 'mute' value = '0'/>
<Param name = 'uimode' value = 'full'/>
<Param name = 'stretchtofit 'value = '0'/>
<Param name = 'windowlessvideo' value = '0'/>
<Param name = 'enabled' value = '-1'/>
<Param name = 'enablescontextmenu 'value = '0'/>
<Param name = 'fullscreen' value = '0'/>
<Param name = 'samples' value = ''/>
<Param name = 'sample' value = ''/>
<Param name = 'samifilename' value = ''/>
<Param name = 'captioningid' value = ''/>
<Param name = 'enableerrordialogs 'value = '0'/>
<Param name = '_ cx' value = '000000'/>
<Param name = '_ cy' value = '000000'/>
<Param name = 'url' value = '"+ URL +"'/> </object> ";
Return str;
}


Protected void button#click (object sender, EventArgs e)
{
Foreach (UploadedFile file in RadUploadContext. Current. UploadedFiles)
{
If (file. FileName! = Null & file. FileName! = "")
{
String strTime = memberid. toString () + "-" + DateTime. now. year. toString () + DateTime. now. month. toString () + DateTime. now. day. toString () + DateTime. now. hour. toString () + DateTime. now. minute. toString () + DateTime. now. millisecond. toString ();
String namefile = file. FileName; // get the original file name
String namelast = namefile. Substring (namefile. LastIndexOf ("."); // get the file extension name, LastIndexOf ()-return the location of characters in parentheses
String FilePath = System. AppDomain. CurrentDomain. BaseDirectory + @ "SaveFilePath/MBmusic/"; // File Upload path
System. IO. FileInfo fi = new System. IO. FileInfo (file. FileName );
If (fi. extension. toLower () = ". mp3 "| fi. extension. toLower () = ". wma "| fi. extension. toLower () = ". rm "| fi. extension. toLower () = ". wav ")
{
String name = strTime + namelast; // name of the last saved file
Music = "http://www.cnblogs.com/SaveFilePath/MBmusic/" + name;
Filesizes = int. Parse (file. ContentLength. ToString ());
String path = FilePath + name;
If (File. Exists (path) = false)
{
File. SaveAs (FilePath + name );
Mf. MF_Path = mv;
// Mf. MF_Path = mv;
}
Else if (File. Exists (path) = true)
{
Name = strTime + "(" + tt + ")" + namelast;
File. SaveAs (FilePath + name );
Music = "http://www.cnblogs.com/SaveFilePath/MBmusic/" + name;
Mf. MF_Path = mv;
// Mf. MF_Path = mv;
}
If (RemainByteSize> = Filesizes)
{
Try
{
// Insert data into the database tutorial
If (addnum> 0 & udps tutorial ize> 0)
{
// Response. Write ("<script> alert ('upload successful !! ') </Script> ");
// Bind ();
}
Else
{
Response. Write ("<script> alert ('upload failed !! ') </Script> ");
Return;
}
Num ++;
}
Catch {}
}
Else
{
Response. Write ("<script> alert ('space is insufficient. Please apply for space !! ') </Script> ");
Return;
}
}
Else
{
Response. Write ("<script> alert ('upload file format error! The file format is mp3, wma, wav. rm! ') </Script> ");
Return;
}
}
Else
{
Response. Write ("<script> alert ('select the uploaded file') </script> ");
Return;
}
}
}

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.