Exemple #1
0
        private LibraryPlaylist ReadPlaylist(XmlDictReader aReader)
        {
            LibraryPlaylist playlist = new LibraryPlaylist();

            while (!aReader.EndOfDict)
            {
                string propKey = aReader.ReadKey();

                if (propKey == "Name")
                {
                    playlist.Name = aReader.ReadValueString();
                }
                else if (propKey == "Playlist ID")
                {
                    playlist.Id = aReader.ReadValueLong();
                }
                else if (propKey == "Playlist Persistent ID")
                {
                    playlist.PersistentId = aReader.ReadValueString();
                }
                else if (propKey == "Visible")
                {
                    playlist.IsVisible = aReader.ReadValueBool();
                }
                else if (propKey == "Distinguished Kind")
                {
                    playlist.DistinguishedKind = aReader.ReadValueLong();
                }
                else if (propKey == "Smart Info" ||
                         propKey == "Smart Criteria")
                {
                    playlist.IsSmart = true;
                    aReader.SkipValue();
                }
                else if (propKey == "Playlist Items")
                {
                    XmlArrayReader itemListReader = aReader.ReadValueArrayBegin();
                    while (!itemListReader.EndOfArray)
                    {
                        XmlDictReader itemReader = itemListReader.ReadValueDictBegin();
                        itemReader.ReadKey();
                        playlist.Items.Add(itemReader.ReadValueLong());
                        itemListReader.ReadValueDictEnd(itemReader);
                    }
                    aReader.ReadValueArrayEnd(itemListReader);
                }
                else
                {
                    aReader.SkipValue();
                }
            }

            return(playlist);
        }
Exemple #2
0
        private void Run()
        {
            try
            {
                // read all items - must be done before playlists
                LibraryXmlReaderItems reader = new LibraryXmlReaderItems(iLibrary.XmlFile);
                while (!reader.End)
                {
                    LibraryItem item = reader.Read();
                    iLibrary.AddItem(item);
                    if (EventItemAdded != null)
                    {
                        EventItemAdded(item);
                    }
                }

                // read playlists - must be done after all items
                LibraryXmlReaderPlaylists playlistReader = new LibraryXmlReaderPlaylists(iLibrary.XmlFile);
                while (!playlistReader.End)
                {
                    LibraryPlaylist playlist = playlistReader.Read();
                    if (playlist.DistinguishedKind == -1 && !playlist.IsSmart && playlist.IsVisible && EventPlaylistAdded != null)
                    {
                        EventPlaylistAdded(playlist);
                    }
                }

                // send finished event
                if (EventFinished != null)
                {
                    EventFinished();
                }
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception aExc)
            {
                UserLog.WriteLine(DateTime.Now + " : reading tracks from Itunes XML failed: " + aExc);
                if (EventError != null)
                {
                    EventError();
                }
            }
        }
Exemple #3
0
        public void Add(NodeContainer aParent, LibraryPlaylist aPlaylist, ref UInt32 aNextId)
        {
            // create the container for the playlist
            NodePlaylist playlist = new NodePlaylist(aPlaylist.Name, aNextId, null);

            aNextId++;

            // given that the ID (from the aNextId variable) is unique, it is easy to construct
            // a unique key for the playlist - having <playlistname><playlistid> ensures
            // uniqueness and alphabetical sorting
            aParent.Add(playlist.Name + playlist.Id.ToString(), playlist);

            // add all tracks
            foreach (long libItemId in aPlaylist.Items)
            {
                if (iItemDict.ContainsKey(libItemId))
                {
                    ItemDesc desc = iItemDict[libItemId];
                    NodeItem item = new NodeItem(aNextId, desc.Id, desc.LibItem);
                    aNextId++;
                    playlist.Add(item);
                }
            }
        }
Exemple #4
0
 private void PlaylistAdded(LibraryPlaylist aPlaylist)
 {
     iDatabase.Add(aPlaylist);
 }
Exemple #5
0
 public void Add(LibraryPlaylist aPlaylist)
 {
     iPlaylistBuilder.Add(iPlaylistContainer, aPlaylist, ref iNextId);
 }