Пример #1
0
        private QuickPlaylist CreateQuickPlaylist(XElement playlistXml)
        {
            var id           = int.Parse(playlistXml.Attribute(PlaylistId).Value);
            var title        = playlistXml.Attribute(PlaylistTitle).Value;
            var filterType   = (FilterType)Enum.Parse(typeof(FilterType), playlistXml.Attribute(PlaylistFilter).Value);
            var filterValues = playlistXml.Attribute(PlaylistFilterValue).Value.Split(ValueSeparator);

            var playlist = new QuickPlaylist(id, title, true, filterType, filterValues);

            return(playlist);
        }
Пример #2
0
        private void Play(QuickPlaylist playlist)
        {
            var tracks = _trackSearchService.GetTracks(playlist.FilterType, playlist.FilterValues);

            if (!tracks.Any())
            {
                _messenger.Send(new ShowDialogMessage(_messenger, MessageType.Error, "Auto Playlist Error", "No tracks meet these criteria"));
                return;
            }

            _playRequestHandler.PlayPlaylist(playlist.GetDefaultTitle(), tracks, SortType.Random);
        }
Пример #3
0
        public void Save(QuickPlaylist playlist)
        {
            var xml = _xmlProvider.Get() ?? CreateXmlDocument();

            var favouriteQuickPlaylistsXml = xml.Root.Element(PlaylistsFavouriteQuick);

            if (favouriteQuickPlaylistsXml == null)
            {
                favouriteQuickPlaylistsXml = new XElement(PlaylistsFavouriteQuick);
                xml.Root.Add(favouriteQuickPlaylistsXml);
            }

            XElement playlistXml;

            if (!playlist.Favourite)
            {
                playlistXml = favouriteQuickPlaylistsXml
                              .Elements(PropertyNames.Playlist)
                              .Single(pl => pl.Attribute(PlaylistId).Value == playlist.Id.ToString());

                playlistXml.Remove();
            }
            else
            {
                var playlists = favouriteQuickPlaylistsXml
                                .Elements(PropertyNames.Playlist);

                var maxId = playlists.Any()
                    ? playlists.Max(pl => Convert.ToInt16(pl.Attribute(PlaylistId).Value))
                    : 0;

                playlist.Id = maxId + 1;

                playlistXml = new XElement(PropertyNames.Playlist);
                playlistXml.Add(new XAttribute(PlaylistId, playlist.Id));
                playlistXml.Add(new XAttribute(PlaylistTitle, playlist.GetDefaultTitle()));
                playlistXml.Add(new XAttribute(PlaylistFilter, playlist.FilterType.ToString()));
                playlistXml.Add(new XAttribute(PlaylistFilterValue, string.Join(ValueSeparator.ToString(), playlist.FilterValues)));

                favouriteQuickPlaylistsXml.Add(playlistXml);
            }

            _xmlProvider.Save(xml);
        }
Пример #4
0
 public QuickPlaylistViewModel(QuickPlaylist playlist)
 {
     Playlist = playlist;
 }
Пример #5
0
 public void Save(QuickPlaylist playlist)
 {
     _repository.Save(playlist);
 }