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 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 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); }