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