public async Task AddNew(StopOperationToken stopToken) { List <StorageFolder> folders = await GetStorageFolders(); List <IPlaylist> adds = new List <IPlaylist>(); foreach (StorageFolder folder in folders.OrderBy(f => f.Path)) { if (stopToken.IsStopped) { return; } if (Playlists.Any(p => p.AbsolutePath == folder.Path)) { continue; } IPlaylist playlist = new Playlist(folder.Path); playlist.Parent = Playlists; await playlist.Reset(stopToken); if (playlist.Songs.Count > 0) { adds.Add(playlist); } } if (stopToken.IsStopped) { return; } Playlists.Change(null, adds); }
public async Task Reset(StopOperationToken stopToken) { IsPlaying = false; List <IPlaylist> refreshedPlaylists = new List <IPlaylist>(); List <StorageFolder> folders = await GetStorageFolders(); foreach (StorageFolder folder in await GetStorageFolders()) { IPlaylist playlist = new Playlist(folder.Path); playlist.Parent = Playlists; await playlist.Reset(stopToken); if (stopToken.IsStopped) { return; } if (playlist.Songs.Count > 0) { refreshedPlaylists.Add(playlist); } } IPlaylistCollection playlists = new PlaylistCollection(); playlists.Change(null, refreshedPlaylists); if (stopToken.IsStopped) { return; } Playlists = playlists; CurrentPlaylist = playlists.FirstOrDefault(); }