/// <summary> /// Returns playList builded from selected files. /// </summary> /// <param name="shufled"></param> /// <returns>PlayList</returns> public static PlayList BuildPlayListFromFiles(bool shufled) { PlayList list = null; OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "MP3 Files (.mp3)|*.mp3"; dialog.Multiselect = true; if (dialog.ShowDialog() == DialogResult.OK) { string[] path = dialog.FileNames; var fileInfos = path.Select(f => new FileInfo(f)); FileInfo[] fInfos = fileInfos.ToArray(); list = new PlayList(fInfos); if (list.getPlayListSize() == 0) { return(null); } if (shufled) { list.shufleQueue(); } } return(list); }
//--------------------------check-boxes event handlers--------------------------------- /// <summary> /// Rnd. check box event handler. If checked, shufles the play list or sort back if unchecked. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void random_CheckedChanged(object sender, EventArgs e) { if (random.Checked && currentPlayList != null) { currentPlayList.shufleQueue(); } else if (!random.Checked && currentPlayList != null) { currentPlayList.unShufle(); } }
/// <summary> /// Checks wether user already selected sufle option and builds playlist from folder selected. /// </summary> /// <param name="shufled"></param> /// <returns>PlayList</returns> public static PlayList BuildPlayList(bool shufled) { PlayList list = null; FolderBrowserDialog dialog = new FolderBrowserDialog(); if (dialog.ShowDialog() == DialogResult.OK) { string path = dialog.SelectedPath; DirectoryInfo dInfo = new DirectoryInfo(path); // File info docs FileInfo[] fInfor = dInfo.GetFiles("*.mp3"); list = new PlayList(fInfor); if (list.getPlayListSize() == 0) { return(null); } if (shufled) { list.shufleQueue(); } } return(list); }