Beispiel #1
0
        public static void ParseRecentPlaylist(string xml)
        {
            XDocument doc = XDocument.Parse(xml);
            foreach (XElement element in doc.Root.Elements())
            {
                XElement x = element.Element("{http://schemas.zune.net/catalog/music/2007/10}track");
                if (x != null)
                {
                    RecentSong song = new RecentSong();
                    song.Title = x.Element("{http://schemas.zune.net/catalog/music/2007/10}title").Value;
                    song.Album = x.Element("{http://schemas.zune.net/catalog/music/2007/10}album").
                        Element("{http://schemas.zune.net/catalog/music/2007/10}title").Value;
                    song.Artist = x.Element("{http://schemas.zune.net/catalog/music/2007/10}primaryArtist").
                        Element("{http://schemas.zune.net/catalog/music/2007/10}name").Value;

                    song.AlbumID = x.Element("{http://schemas.zune.net/catalog/music/2007/10}album")
                        .Element("{http://schemas.zune.net/catalog/music/2007/10}id").Value.Remove(0,9);

                    
                    WebClient client = new WebClient();
                    client.DownloadStringAsync(new Uri("http://catalog.zune.net/v3.2/en-US/music/album/" + song.AlbumID));
                    client.DownloadStringCompleted += (s, e) => HandleDownload(s, e, song);     
                }
            }
        }
Beispiel #2
0
        private static void HandleDownload(object sender, DownloadStringCompletedEventArgs e, RecentSong song)
        {
            try
            {
                XDocument xdoc = XDocument.Parse(e.Result);
                string imageId = xdoc.Root.Element("{http://schemas.zune.net/catalog/music/2007/10}image")
                    .Element("{http://schemas.zune.net/catalog/music/2007/10}id").Value.Remove(0, 9);
                
                BitmapImage image = new BitmapImage(new Uri(string.Format("http://catalog.zune.net/v3.2/image/{0}?width=100&height=100", imageId)));
                song.AlbumArt = image;
            }
            catch
            {
                song.AlbumArt = new BitmapImage(new Uri("Images/unknown.png", UriKind.Relative));
            }

            ProfileViewModelLocator.ProfileModel.RecentPlaylist.Add(song);
        }