Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public LibraryHeader Read(string aFilename)
        {
            LibraryHeader header = new LibraryHeader();
            XmlReader     reader = OpenFile(aFilename);

            try
            {
                XmlDictReader dictReader = new XmlDictReader(reader);
                while (!dictReader.EndOfDict)
                {
                    string key = dictReader.ReadKey();

                    if (key == "Major Version")
                    {
                        header.MajorVersion = dictReader.ReadValueLong();
                    }
                    else if (key == "Minor Version")
                    {
                        header.MinorVersion = dictReader.ReadValueLong();
                    }
                    else if (key == "Application Version")
                    {
                        header.AppVersion = dictReader.ReadValueString();
                    }
                    else if (key == "Features")
                    {
                        header.Features = dictReader.ReadValueLong();
                    }
                    else if (key == "Show Content Ratings")
                    {
                        header.ShowContentRatings = dictReader.ReadValueBool();
                    }
                    else if (key == "Music Folder")
                    {
                        header.MusicFolder = dictReader.ReadValueString();
                    }
                    else if (key == "Library Persistent ID")
                    {
                        header.LibraryId = dictReader.ReadValueString();
                    }
                    else
                    {
                        dictReader.SkipValue();
                    }
                }
            }
            finally
            {
                reader.Close();
            }

            return(header);
        }
Ejemplo n.º 3
0
        private LibraryItem ReadItem(XmlDictReader aReader)
        {
            LibraryItem track = new LibraryItem();

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

                if (propKey == "Track ID")
                {
                    track.TrackId = aReader.ReadValueLong();
                }
                else if (propKey == "Name")
                {
                    track.Name = aReader.ReadValueString();
                }
                else if (propKey == "Artist")
                {
                    track.Artist = aReader.ReadValueString();
                }
                else if (propKey == "Album Artist")
                {
                    track.AlbumArtist = aReader.ReadValueString();
                }
                else if (propKey == "Composer")
                {
                    track.Composer = aReader.ReadValueString();
                }
                else if (propKey == "Album")
                {
                    track.Album = aReader.ReadValueString();
                }
                else if (propKey == "Genre")
                {
                    track.Genre = aReader.ReadValueString();
                }
                else if (propKey == "Kind")
                {
                    track.Kind = aReader.ReadValueString();
                }
                else if (propKey == "Size")
                {
                    track.Size = aReader.ReadValueLong();
                }
                else if (propKey == "Total Time")
                {
                    track.TotalTime = aReader.ReadValueLong();
                }
                else if (propKey == "Disc Number")
                {
                    track.DiscNumber = aReader.ReadValueLong();
                }
                else if (propKey == "Disc Count")
                {
                    track.DiscCount = aReader.ReadValueLong();
                }
                else if (propKey == "Track Number")
                {
                    track.TrackNumber = aReader.ReadValueLong();
                }
                else if (propKey == "Track Count")
                {
                    track.TrackCount = aReader.ReadValueLong();
                }
                else if (propKey == "Year")
                {
                    track.Year = aReader.ReadValueLong();
                }
                else if (propKey == "Date Modified")
                {
                    track.DateModified = aReader.ReadValueDate();
                }
                else if (propKey == "Date Added")
                {
                    track.DateAdded = aReader.ReadValueDate();
                }
                else if (propKey == "Bit Rate")
                {
                    track.BitRate = aReader.ReadValueLong();
                }
                else if (propKey == "Sample Rate")
                {
                    track.SampleRate = aReader.ReadValueLong();
                }
                else if (propKey == "Persistent ID")
                {
                    track.PersistentId = aReader.ReadValueString();
                }
                else if (propKey == "Track Type")
                {
                    track.TrackType = aReader.ReadValueString();
                }
                else if (propKey == "Location")
                {
                    track.Location = aReader.ReadValueString();
                }
                else
                {
                    aReader.SkipValue();
                }
            }

            return(track);
        }