Пример #1
0
 public IPlaylistContentProvider GetPlaylistContentProvider(PlaylistPlaceholder playlist)
 {
     lock (_playlistContentProviders)
     {
         return _playlistContentProviders.GetOrAddValue(playlist, a => new PlaylistContentProvider(a));
     }
 }
Пример #2
0
 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();
 }
Пример #3
0
 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
             };
     }
 }
Пример #4
0
 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);
 }
Пример #5
0
 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);
 }
Пример #6
0
 private async Task OpenPlaylist(PlaylistPlaceholder playlist)
 {
     _playlistFile = await PlaylistFile.OpenAsync(playlist);
     _watchedProvider = new WatchedPlaylistProvider(_playlistFile.Playlist);
     IsRefreshing = _watchedProvider.IsRefreshing;
     _watchedProvider.PropertyChanged += _watchedProvider_PropertyChanged;
 }
Пример #7
0
 public PlaylistContentProvider(PlaylistPlaceholder playlist)
 {
     Tracks = new ReadOnlyObservableCollection<TrackInfo>(_tracks);
     _openPlaylistTask = OpenPlaylist(playlist);
     LoadContent();
 }