コード例 #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
ファイル: PlaylistFile.cs プロジェクト: sunnycase/TomatoMusic
 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
ファイル: PlaylistFile.cs プロジェクト: sunnycase/TomatoMusic
 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
ファイル: PlaylistFile.cs プロジェクト: sunnycase/TomatoMusic
 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();
 }