Ejemplo n.º 1
0
        public static async Task PreparePlaylistAsync()
        {
            Debug.WriteLine("> Load playlist locally");
            var loadedPlaylist = await LoadFromFileAsync();

            if (CurrentPlaylist == null)
            {
                CurrentPlaylist = loadedPlaylist ?? new Playlist();
            }
            else
            {
                CurrentPlaylist.Clear();
                if (loadedPlaylist.Entries.Count > 0)
                {
                    CurrentPlaylist.Entries.AddRange(loadedPlaylist.Entries.ToList());
                    CurrentPlaylist.CurrentIndex = loadedPlaylist.CurrentIndex;
                }
            }

            // Add waiting episodes
            CurrentPlaylist.AddEpisodes(EpisodesToAdd);

            // Cleanup
            var wrongEpisodes = CurrentPlaylist.Entries.Where(e => e.Episode == null).ToArray();

            foreach (var wrongEpisode in wrongEpisodes)
            {
                CurrentPlaylist.Entries.Remove(wrongEpisode);
            }

            // Check limits
            if (CurrentPlaylist.CurrentIndex >= CurrentPlaylist.Entries.Count)
            {
                CurrentPlaylist.CurrentIndex = CurrentPlaylist.Entries.Count - 1;
            }

            if (CurrentPlaylist.CurrentIndex < 0 && CurrentPlaylist.Entries.Count > 0)
            {
                CurrentPlaylist.CurrentIndex = 0;
            }
        }
Ejemplo n.º 2
0
 public static void PlayListClear()
 {
     CurrentPlaylist.Clear();
     CurrentIndex = 0;
 }