private void button1_Click(object sender, EventArgs e) { string[] filenames, filepaths; openFileDialog1.Filter = "All Media Files|*.wav;*.aac;*.wma;*.wmv;*.avi;*.mpg;*.mpeg;*.m1v;*.mp2;*.mp3;*.mpa;*.mpe;*.m3u;*.mp4;*.mov;*.3g2;*.3gp2;*.3gp;*.3gpp;*.m4a;*.cda;*.aif;*.aifc;*.aiff;*.mid;*.midi;*.rmi;*.mkv;*.WAV;*.AAC;*.WMA;*.WMV;*.AVI;*.MPG;*.MPEG;*.M1V;*.MP2;*.MP3;*.MPA;*.MPE;*.M3U;*.MP4;*.MOV;*.3G2;*.3GP2;*.3GP;*.3GPP;*.M4A;*.CDA;*.AIF;*.AIFC;*.AIFF;*.MID;*.MIDI;*.RMI;*.MKV"; //set default path for OFD if (Directory.Exists("Songs")) { openFileDialog1.InitialDirectory = "Songs"; } if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { filenames = openFileDialog1.SafeFileNames; filepaths = openFileDialog1.FileNames; for (int i = 0; i < filenames.Length; i++) { //elegxos wste na min uparxoun idia image files sto checkedlistbox if (!SongsNPaths.ContainsKey(filenames[i])) {//pairname ta names sto listbox kai names&paths sto dictionary songsnpaths listBox1.Items.Add(filenames[i]); SongsNPaths.Add(filenames[i], filepaths[i]); //gia kathe audio file dimiourgw ena tracks obj diabazw ta metadata tou kai to apothikeuw se ena dictionary me key to onoma tou audio file Tracks track = new Tracks(); track.path = filepaths[i]; track.songName = filenames[i]; track.readMetaData(filepaths[i]); TracksDict.Add(filenames[i], track); track.playingFrequency++; //gia to frequency pou akouei o xrhsths ena tragoudi //to obj ginetai serialize mono tin prwti fora //tis alles fores aplws auxanetai to frequency if (!File.Exists(@"Tracks\" + track.songName + ".txt")) { Tracks.serializeTrack(track); } else { Tracks tr = Tracks.DeserializeTrack(track.songName); tr.playingFrequency++; Tracks.serializeTrack(tr); } } } } }
private void button14_Click(object sender, EventArgs e) { if (listBox2.SelectedItem != null) { //update button //xamadiabazei ta metadata apo kathe track p periexetai mesa sto playlist //key ---> onoma tou audio file //value ---> Tracks object Dictionary <string, Tracks> Playlist = new Dictionary <string, Tracks>(); Playlist = Tracks.deserializePlaylist(listBox2.SelectedItem.ToString()); foreach (var keyValuePair in Playlist) { keyValuePair.Value.readMetaData(keyValuePair.Value.path); } Tracks.serializePlaylist(listBox2.SelectedItem.ToString(), Playlist); } }
private void button13_Click(object sender, EventArgs e) {//load ta tragoudia sto listbox1 //stin sunexeia adeiazoume to dict songpaths kai to gemizoume me ta tragoudia tou playlist to idio kanw kai gia to TracksDict if (listBox2.SelectedItem != null) { if (axWindowsMediaPlayer1.URL != null) { axWindowsMediaPlayer1.URL = null; } listBox1.Items.Clear(); SongsNPaths.Clear(); TracksDict.Clear(); Dictionary <string, Tracks> Playlist = new Dictionary <string, Tracks>(); Playlist = Tracks.deserializePlaylist(listBox2.SelectedItem.ToString()); foreach (var keyValuePair in Playlist) { listBox1.Items.Add(keyValuePair.Key); SongsNPaths.Add(keyValuePair.Key, keyValuePair.Value.path); TracksDict.Add(keyValuePair.Key, keyValuePair.Value); } } }