Exemple #1
0
        private StreamInfoPack ParseXML(string stringDoc)
        {
            var gc     = new GetCoverArt();
            var sip    = new StreamInfoPack();
            var xmlDoc = new XmlDocument();

            try
            {
                xmlDoc.LoadXml(stringDoc);
            }
            catch
            {
                sip.Status = "error";
                return(sip);
            }

            List <string> list;

            APIhelper.TryParseXML(xmlDoc, "subsonic-response", "status", out list);

            if (list[0] != "ok")
            {
                sip.Status = "error";
                return(sip);
            }
            sip.Status = list[0];
            APIhelper.TryParseXML(xmlDoc, "song", "id", out list);
            sip.Id = list[0];
            APIhelper.TryParseXML(xmlDoc, "song", "parent", out list);
            sip.Parent = list[0];
            APIhelper.TryParseXML(xmlDoc, "song", "title", out list);
            sip.Title = list[0];
            APIhelper.TryParseXML(xmlDoc, "song", "album", out list);
            sip.Album = list[0];
            APIhelper.TryParseXML(xmlDoc, "song", "artist", out list);
            sip.Artist = list[0];
            APIhelper.TryParseXML(xmlDoc, "song", "coverArt", out list);
            sip.CoverArt = gc.GetCoverArtImageUrl(list[0]);
            APIhelper.TryParseXML(xmlDoc, "song", "duration", out list);
            sip.Duration = list[0];

            return(sip);
        }
Exemple #2
0
        public StreamInfoPack GetSongInfo(string songId)
        {
            string url = APIhelper.Url + APIuri + "?v=" + APIhelper.ApiVersion + "&c=" + APIhelper.AppName + "&id=" +
                         songId;

            try
            {
                GetXMLbody(url);
            }
            catch
            {
            }

            if (_xmlBody == null)
            {
                var sip = new StreamInfoPack();
                sip.Status = "error";
                return(sip);
            }

            return(ParseXML(_xmlBody));
        }
        public void SetSongInfo()
        {
            StreamInfoPack sip = APIhelper.Sip;

            if (sip != null && sip.Status != "ok")
            {
                return;
            }

            if (sip != null)
            {
                ProgressBarMaxValue = Convert.ToUInt64(sip.Duration) * 1000;

                Title      = sip.Title;
                Artist     = sip.Artist;
                AlbumTitle = sip.Album;
                AlbumETC   = sip.Artist + " / " + sip.Album;
                CoverArt   = sip.CoverArt;

                SongInfoChangedDateTime = DateTime.Now;
            }
        }