/// <summary> /// 从云端API获得专辑列表 /// </summary> /// <param name="bum">专辑名</param> /// <returns>无</returns> private async Task GetAlbumAsync(string bum) { AlbumSearchResult Result = await NetEaseMusic.SearchAsync <AlbumSearchResult>(bum, 30, 0, NeteaseMusicAPI.SearchType.Album); AlbumList.Clear(); if (Result.result.albums == null) { return; } foreach (var item in Result.result.albums) { AlbumList.Add(new SearchAlbum(new Uri(item.picUrl), item.name, item.artist.name, item.id)); } }
private async void MusicSearch_SingerPage_Loaded(object sender, RoutedEventArgs e) { if (IsSame) { IsSame = false; Locker.Set(); return; } if (PivotControl.SelectedIndex != 0) { PivotControl.SelectedIndex = 0; } HotSongCollection = new ObservableCollection <SearchSingleMusic>(); AlbumCollection = new ObservableCollection <SingerAlbum>(); MVCollection = new ObservableCollection <SingerMV>(); HotSongList.ItemsSource = HotSongCollection; GridViewControl.ItemsSource = AlbumCollection; MVGridView.ItemsSource = MVCollection; foreach (var Song in Artist.HotSongs) { TimeSpan Duration = TimeSpan.FromMilliseconds(Song.Dt); if (Song.Ar.Count == 1) { HotSongCollection.Add(new SearchSingleMusic(Song.Name, Song.Ar[0].Name, Song.Al.Name, string.Format("{0:D2}:{1:D2}", Duration.Minutes, Duration.Seconds), Song.Id, Song.Al.Pic.ToString(), Song.Mv)); } else if (Song.Ar.Count > 1) { string CombineName = string.Empty; foreach (var names in Song.Ar) { CombineName = CombineName + names.Name + "/"; } CombineName = CombineName.Remove(CombineName.Length - 1); HotSongCollection.Add(new SearchSingleMusic(Song.Name, CombineName, Song.Al.Name, string.Format("{0:D2}:{1:D2}", Duration.Minutes, Duration.Seconds), Song.Id, Song.Al.Pic.ToString(), Song.Mv)); } else { HotSongCollection.Add(new SearchSingleMusic(Song.Name, "Unknown", Song.Al.Name, string.Format("{0:D2}:{1:D2}", Duration.Minutes, Duration.Seconds), Song.Id, Song.Al.Pic.ToString(), Song.Mv)); } } AlbumSearchResult Result = await NeteaseMusicAPI.GetInstance().SearchAsync <AlbumSearchResult>(Artist.Artist.Name, 30, 0, NeteaseMusicAPI.SearchType.Album); if (Result.result.albums != null) { foreach (var item in Result.result.albums) { AlbumCollection.Add(new SingerAlbum(item.name, item.id, new Uri(item.picUrl))); } } foreach (var item in HotSongCollection) { if (CancelToken.IsCancellationRequested) { break; } if (item.MVExists) { var MVResult = await NeteaseMusicAPI.GetInstance().GetMVAsync((int)item.MVid); if (MVResult.Data == null) { continue; } MVCollection.Add(new SingerMV(MVResult.Data.Name, MVResult.Data.BriefDesc, (int)item.MVid, new Uri(MVResult.Data.Cover))); } } Locker.Set(); }