public void LoadState(string parameter, Dictionary <string, object> statePageState)
        {
            if (!statePageState.ContainsKey(StatePlaylistKey) || PlaylistItems.Any())
            {
                return;
            }
            var bytes         = Convert.FromBase64String((string)statePageState[StatePlaylistKey]);
            var memoryStream  = new MemoryStream(bytes);
            var xmlSerializer = new XmlSerializer(typeof(PlaylistItemCollection));
            var playlist      = (PlaylistItemCollection)xmlSerializer.Deserialize(memoryStream);

            PlaylistItems.Clear();
            PlaylistItems.AddRange(playlist);
        }
Example #2
0
        /// <summary>
        /// Get the PlaylistItems and associated songs for this playlist
        /// </summary>
        /// <param name="playlistItems"></param>
        public void GetContents(IEnumerable <SongPlaylistItem> playlistItems)
        {
            // Get all the SongPlaylistItem entries associated with this SongPlaylist and then the Song entries for each of them
            PlaylistItems.AddRange(playlistItems.Where(item => item.PlaylistId == Id));

            foreach (SongPlaylistItem playlistItem in PlaylistItems)
            {
                playlistItem.Song        = Songs.GetSongById(playlistItem.SongId);
                playlistItem.Artist      = Artists.GetArtistById(ArtistAlbums.GetArtistAlbumById(playlistItem.Song.ArtistAlbumId).ArtistId);
                playlistItem.Song.Artist = playlistItem.Artist;
            }

            PlaylistItems.Sort((a, b) => a.Index.CompareTo(b.Index));
        }
Example #3
0
        /// <summary>
        /// Get the PlaylistItems and associated songs for this playlist
        /// </summary>
        /// <param name="playlistItems"></param>
        public void GetContents(IEnumerable <PlaylistItem> playlistItems)
        {
            // Get all the AlbumPlaylistItem entries associated with this AlbumPlaylist and then the Album entries for each of them
            PlaylistItems.AddRange(playlistItems.Where(item => item.PlaylistId == Id));

            foreach (AlbumPlaylistItem playlistItem in PlaylistItems)
            {
                playlistItem.Album = Albums.GetAlbumById(playlistItem.AlbumId);

                // Get the contents of this playlist as the SongIndex processing assumes that the Songs are available
                playlistItem.Album.GetSongs();
            }

            PlaylistItems.Sort((a, b) => a.Index.CompareTo(b.Index));
        }