private async void getAlbumInfo(string artistName, string albumName) { SystemTray.IsVisible = true; prog.IsVisible = true; prog.IsIndeterminate = true; prog.Text = "Loading..."; try { currAlbum = await album.getInfo(artistName, albumName); } catch (TaskCanceledException) { } this.DataContext = currAlbum; //NavigateToString method works bad with encodings, that's why I am using this stuff var store = IsolatedStorageFile.GetUserStoreForApplication(); using (var stream = new IsolatedStorageFileStream("album.html", FileMode.Create, FileAccess.Write, store)) { using (var sw = new StreamWriter(stream)) sw.Write(utilities.makeHtmlFromCdata(currAlbum.description, currAlbum.extralargeImage)); } albumDescription.Navigate(new Uri("album.html", UriKind.Relative)); prog.IsIndeterminate = false; prog.IsVisible = false; SystemTray.IsVisible = false; }
/// <summary> /// album.getInfo last.fm API function /// </summary> /// <param name="artistName">Artist name</param> /// <param name="albumName">Album name</param> /// <param name="username">Username (if used, user's playcount and whether he loved this track or not included)</param> /// <param name="lang">Language to return response in</param> /// <returns>Album information</returns> public static async Task<albumInfo> getInfo(string artistName, string albumName, string username = "", string lang = "en") { RequestParameters rParams = new RequestParameters("album.getinfo"); rParams.Add("artist", artistName); rParams.Add("album", albumName); if (!string.IsNullOrEmpty(username)) rParams.Add("username", username); rParams.Add("lang", lang); XDocument returnedXml = await Request.MakeRequest(rParams); if (Request.CheckStatus(returnedXml) == 0) { albumInfo album = new albumInfo(returnedXml.Element("lfm").Element("album")); return album; } else throw new LastFmAPIException(returnedXml); }