. NET Learning notes----2015-07-04 (music player)

Source: Internet
Author: User

     Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); }        /// <summary>        ///Click to play a previous song/// </summary>        /// <param name= "Sender" ></param>        /// <param name= "E" ></param>        Private voidButton2_Click (Objectsender, EventArgs e) {            //get the index of the currently selected song            intindex =Listbox1.selectedindex; Index--; if(Index <0) {Index= ListBox1.Items.Count-1; } Listbox1.selectedindex=index; Sp. Soundlocation=List[index]; Sp.        Play (); }        /// <summary>        ///Click to play the next song/// </summary>        /// <param name= "Sender" ></param>        /// <param name= "E" ></param>        Private voidButton3_Click (Objectsender, EventArgs e) {            //get the index of the currently selected song            intindex =Listbox1.selectedindex; Index++; if(Index = =listBox1.Items.Count) {index=0; }            //re-assigns the changed index to the index of the currently selected itemListbox1.selectedindex =index; Sp. Soundlocation=List[index]; Sp.        Play (); }        //the full path used to store music fileslist<string> list =Newlist<string>(); Private voidBtnopen_click (Objectsender, EventArgs e) {OpenFileDialog OFD=NewOpenFileDialog (); Ofd. Title="Please select a music file"; Ofd. InitialDirectory=@"C:\Users\hhlt_00\Desktop\Music"; Ofd. MultiSelect=true; Ofd. Filter="music files |*.wav| All files |*.*"; Ofd.            ShowDialog (); //get the full path of all the files that we have selected in the folder            string[] Path =OFD.            FileNames;  for(inti =0; I < path. Length; i++)            {                //load the file name of the music files into the listboxListBox1.Items.Add (Path.getfilename (path[i)); //put the full path of the music file into the generic collectionlist.            ADD (Path[i]); }        }        /// <summary>        ///implement double-click Playback/// </summary>        /// <param name= "Sender" ></param>        /// <param name= "E" ></param>        ///SoundPlayer SP =NewSoundPlayer (); Private voidListbox1_doubleclick (Objectsender, EventArgs e) {sp. Soundlocation=List[listbox1.selectedindex]; Sp.        Play (); }    }

. NET Learning notes----2015-07-04 (music player)

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.