Music Player: Open File dialog box

Source: Internet
Author: User

Made a simple music player. With open files inside the computer, select songs to play

The main purpose is to master, open the folder, select the file's

  

1         Private voidFrm_load (Objectsender, EventArgs e)2         {3Skinengine1.skinfile ="Diamondblue.ssk";4            5MediaPlayer1.settings.autoStart =false;//disable playback on load6Mediaplayer1.url ="f:\\qqpcmgr\\desktop\\ player \\MUSIC\\1.mp3";7         }8         //generic collection, which is used to load the full path of a music file9list<string> Listpath =Newlist<string>();Ten  One         Private voidButton1_Click (Objectsender, EventArgs e) A         { -             //Instantiate, open file -OpenFileDialog FA =NewOpenFileDialog (); the  -             //the path at initialization time -           Fa. InitialDirectory =@"F:\QQPCmgr\Desktop\ player \music\"; -  +             //Choose the format of the file -Fa. Filter ="Audio MP3 file |*.mp3| le file |*.wav| all files |*.*"; +Fa. Title ="Please select a music file";//Title of the dialog box AFa. MultiSelect =true;//Allow multiple selections atFa. ShowDialog ();//Open dialog Box -  -             string[] Path =FA. FileNames; -              for(inti =0; I < path. Length; i++) -             { -                 //to save a full path to a generic collection in Listpath.add (Path[i]); -                 //to save the file name in ListBox1 to                  This. LISTBOX1.ITEMS.ADD (Path.getfilename (path[i)); +             } -         } the         //Double-click to play Music *         Private voidListbox1_doubleclick (Objectsender, EventArgs e) $         {Panax Notoginseng             Try -             { the                 //gets the full path in the generic collection based on the index, and assigns the value to the URL +Mediaplayer1.url =Listpath[listbox1.selectedindex]; A MediaPlayer1.Ctlcontrols.play (); the             } +             Catch -             { } $         } $     } -}

Music Player: Open File dialog box

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.