public IPlaylistContentProvider GetPlaylistContentProvider(PlaylistPlaceholder playlist) { lock (_playlistContentProviders) { return _playlistContentProviders.GetOrAddValue(playlist, a => new PlaylistContentProvider(a)); } }
public async Task AddCustomPlaylist(string name) { var newPlaylist = new PlaylistPlaceholder { Key = Guid.NewGuid(), Name = name }; _customPlaylists.Add(newPlaylist); _playlistIndexFile.PlaylistIndex.Playlists.Add(newPlaylist); await _playlistIndexFile.Save(); }
private static void HandleNullModel(ref Primitives.Playlist model, PlaylistPlaceholder placeholder) { if (model == null) { if (placeholder.Key == Primitives.Playlist.MusicLibraryPlaylistKey) model = Primitives.Playlist.CreateMusicLibrary(); else model = new Primitives.Playlist { Key = placeholder.Key, Version = PlaylistVersions.Current }; } }
public static async Task<PlaylistFile> OpenAsync(PlaylistPlaceholder placeholder) { Primitives.Playlist model = null; try { var file = await OpenPlaylistFile(placeholder); model = JsonConvert.DeserializeObject<Primitives.Playlist>(await FileIO.ReadTextAsync(file)); } catch (Exception ex) { Debug.WriteLine(ex.Flatten()); } HandleNullModel(ref model, placeholder); return new PlaylistFile(model); }
private static async Task<StorageFile> OpenPlaylistFile(PlaylistPlaceholder placeholder) { var folder = await ApplicationData.Current.RoamingFolder.CreateFolderAsync(PlaylistFolder, CreationCollisionOption.OpenIfExists); return await folder.CreateFileAsync($"{placeholder.Key.ToString("N")}.json", CreationCollisionOption.OpenIfExists); }
private async Task OpenPlaylist(PlaylistPlaceholder playlist) { _playlistFile = await PlaylistFile.OpenAsync(playlist); _watchedProvider = new WatchedPlaylistProvider(_playlistFile.Playlist); IsRefreshing = _watchedProvider.IsRefreshing; _watchedProvider.PropertyChanged += _watchedProvider_PropertyChanged; }
public PlaylistContentProvider(PlaylistPlaceholder playlist) { Tracks = new ReadOnlyObservableCollection<TrackInfo>(_tracks); _openPlaylistTask = OpenPlaylist(playlist); LoadContent(); }