Simple player under the WinForm

Source: Internet
Author: User

Writing this player, encountered a lot of problems, such as only the implementation of the WAV audio file playback, and for this picture in the middle of the button

The ability to pause is not possible, and when clicked, make its text "?", for which the property is not known when the button is selected

How, so we need to continue to improve

Player Code
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.ComponentModel;4 usingSystem.Data;5 usingSystem.Drawing;6 usingSystem.Linq;7 usingSystem.Text;8 usingSystem.Threading.Tasks;9 usingSystem.Windows.Forms;Ten usingSystem.Media; One usingSystem.IO; A  - namespaceWindowsFormsApplication1 - { the      Public Partial classForm1:form -     { -          PublicForm1 () -         { + InitializeComponent (); -         } +  A         Private voidForm1_Load (Objectsender, EventArgs e) at         { -             -         } -list<string> listsongs =Newlist<string> ();//define path generic variables that store song names -         Private voidButton5_click (Objectsender, EventArgs e) -         { inOpenFileDialog OFD =NewOpenFileDialog (); -Ofd. Title ="Please select an audio file"; toOfd. InitialDirectory =@"F:\wav_music"; +Ofd. Filter="audio files |*.wav| all files |*.*"; -Ofd. multiselect=true;//multi-Select Settings the OFD. ShowDialog (); *             string[] path = ofd. FileNames;//get the full path of an audio file $              for(inti =0; I < path. Length; i++)Panax Notoginseng             { -LISTBOX1.ITEMS.ADD (Path.getfilename (path[i));//intercepts the file path obtained to the filename and adds it to the listbox theListsongs.add (Path[i]);//add a path to the list collection +  A             } the                 +  -         } $         /// <summary> $         ///Double-click the Play Music method.  -         /// </summary> -         /// <param name= "Sender" ></param> the         /// <param name= "E" ></param> -       Wuyi         Private voidListbox1_doubleclick (Objectsender, EventArgs e) the         { -SoundPlayer SP =NewSoundPlayer ();// WuSp. Soundlocation =Listsongs[listbox1.selectedindex]; - sp. Play (); About         } $         /// <summary> -         ///play the next song -         /// </summary> -         /// <param name= "Sender" ></param> A         /// <param name= "E" ></param> +  the         Private voidButton4_Click (Objectsender, EventArgs e) -         { $             //gets the currently selected music item the             intindex =Listbox1.selectedindex; theindex++; theSoundPlayer SP =NewSoundPlayer (); the             if(Index = =listsongs.count) -             { in  theindex =0; the             } AboutListbox1.selectedindex = index;//reassign the index to the listbox selection.  theSp. Soundlocation =Listsongs[index]; the sp. Play (); the             +                 -              the            Bayi             the         } the         /// <summary> -         ///Play the previous song -         /// </summary> the         /// <param name= "Sender" ></param> the         /// <param name= "E" ></param> the          the         Private voidButton2_Click (Objectsender, EventArgs e) -         { the             //gets the currently selected music item the             intindex =Listbox1.selectedindex; theindex--;94SoundPlayer SP =NewSoundPlayer (); the             if(Index = =0 ) the             { theindex = Listsongs.count-1;98             } AboutListbox1.selectedindex =index; -Sp. Soundlocation =Listsongs[index];101 sp. Play ();102 103         }104     } the}

Simple player under the WinForm

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.