private void OpenMusicFiles(string[] files) { var albumCover = ""; var awaiter = FindAlbumCover(Path.GetDirectoryName(files[0])).GetAwaiter(); awaiter.OnCompleted(() => { albumCover = awaiter.GetResult(); pbAlbumCover.ForeColor = ForeColor; pbAlbumCover.SizeMode = PictureBoxSizeMode.StretchImage; pbAlbumCover.ImageLocation = albumCover; }); var openedFiles = new List <MusicFile>(); foreach (var fileName in files) { MusicFile newMedia = new MusicFile(fileName, (uint)lbOpenedFiles.Items.Count + 1) { AlbumCover = albumCover }; lbOpenedFiles.Items.Add(newMedia); openedFiles.Add(newMedia); UrlToIndex.Add(newMedia.Url, lbOpenedFiles.Items.Count - 1); } Player.PlayMusicFiles(openedFiles, true); }
private void OpenFolderToolStripMenuItem_Click(object sender, EventArgs e) { FolderBrowserDialog fbd = new FolderBrowserDialog(); if (fbd.ShowDialog() != DialogResult.OK) { return; } UrlToIndex.Clear(); ClearGui(); var files = Directory.GetFiles(fbd.SelectedPath).ToList(); OpenMusicFiles(files.Where(IsSong).ToArray()); }
private void MainForm_PlayListPlayClicked(object sender, PlaylistPlayClickedEventArgs e) { Focus(); ClearGui(); UrlToIndex.Clear(); List <MusicFile> musicFiles = new List <MusicFile>(); e.SongsToBePlayed.ForEach(song => { MusicFile mf = new MusicFile(song); musicFiles.Add(mf); lbOpenedFiles.Items.Add(mf); UrlToIndex.Add(mf.Url, lbOpenedFiles.Items.Count - 1); }); Player.PlayMusicFiles(musicFiles, true); }
private void OpenMusicFileToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog { Filter = @"All files (*.flac, *.mp3, *.wav)|*.flac;*.mp3;*.wav|Mp3 files(*.mp3)|*.mp3|Flac files (*.flac)|*.flac|Wav files (*.wav)|*.wav", Title = @"Open Music" }; if (ofd.ShowDialog() != DialogResult.OK) { return; } UrlToIndex.Clear(); ClearGui(); OpenMusicFile(ofd.FileName); }
private void OpenMusicFile(string fileName) { MusicFile newMedia = new MusicFile(fileName, (uint)lbOpenedFiles.Items.Count + 1); var awaiter = FindAlbumCover(Path.GetDirectoryName(fileName)).GetAwaiter(); awaiter.OnCompleted(() => { var albumCover = awaiter.GetResult(); pbAlbumCover.SizeMode = PictureBoxSizeMode.StretchImage; pbAlbumCover.ImageLocation = albumCover; newMedia.AlbumCover = albumCover; }); CurrentMedia = newMedia; lbOpenedFiles.Items.Add(newMedia); UrlToIndex.Add(newMedia.Url, 0); Player.PlayMusicFile(CurrentMedia); }