private void DonwloadFileComplete(object a, DownloadAudioFile e) { var settings = ApplicationData.Current.LocalSettings; settings.Values["CountDownloads"] = (int)settings.Values["CountDownloads"] + 1; QueueTracks.Remove(e); if (QueueTracks.Count == 0) { DispatcherHelper.CheckBeginInvokeOnUI(() => { this.Timer.Stop(); DownloadQueueComplete?.Invoke(this, null); }); } else { var task = Task.Run(async() => { await DownloadAudio(QueueTracks.First()); }); } CurrentDownloadTrack = null; }
public async Task StartDownloadPlaylist(PlaylistFile playlist) { foreach (var audio in playlist.TracksFiles) { var track = new DownloadAudioFile() { Title = audio.Title.Replace("*", "").Replace(".", "").Replace("\"", "").Replace("\\", "").Replace("/", "").Replace("[", "").Replace("]", "").Replace(":", "").Replace(";", "").Replace("|", "").Replace("=", "").Replace(",", ""), AlbumName = playlist.Name.Replace("*", "").Replace(".", "").Replace("\"", "").Replace("\\", "").Replace("/", "").Replace("[", "").Replace("]", "").Replace(":", "").Replace(";", "").Replace("|", "").Replace("=", "").Replace(",", ""), AlbumYear = playlist.Year, Artist = audio.Artist.Replace("*", "").Replace(".", "").Replace("\"", "").Replace("\\", "").Replace("/", "").Replace("[", "").Replace("]", "").Replace(":", "").Replace(";", "").Replace("|", "").Replace("=", "").Replace(",", ""), Cover = audio.Cover, Url = audio.SourceString, FromAlbum = true, AudioFile = audio }; AddToQueue(track); } StorageFolder folder = await KnownFolders.MusicLibrary.TryGetItemAsync("Music X") == null ? await KnownFolders.MusicLibrary.CreateFolderAsync("Music X") : await KnownFolders.MusicLibrary.GetFolderAsync("Music X"); var playlistName = playlist.Name.Replace("*", "").Replace(".", "").Replace("\"", "").Replace("\\", "").Replace("/", "").Replace("[", "").Replace("]", "").Replace(":", "").Replace(";", "").Replace("|", "").Replace("=", "").Replace(",", ""); StorageFolder playlistFolder = await folder.TryGetItemAsync(playlistName) == null ? await folder.CreateFolderAsync(playlistName) : await folder.GetFolderAsync(playlistName); var task = Task.Run(async() => { await DownloadAudio(QueueTracks.First()); }); }