Example #1
0
        private async void AutoSuggestBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
        {
            if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput && sender.Text != "")
            {
                try
                {
                    switch (SearchOrder.SelectedIndex)
                    {
                    case 0: sender.ItemsSource = (await NetEaseMusic.SearchAsync <SingleMusicSearchResult>(sender.Text, 10)).Result.Songs; break;

                    case 1: sender.ItemsSource = (await NetEaseMusic.SearchAsync <ArtistSearchResult>(sender.Text, 10, 0, NeteaseMusicAPI.SearchType.Artist)).result.artists; break;

                    case 2: sender.ItemsSource = (await NetEaseMusic.SearchAsync <AlbumSearchResult>(sender.Text, 10, 0, NeteaseMusicAPI.SearchType.Album)).result.albums; break;
                    }
                }
                catch (Exception)
                {
                }
            }
        }
Example #2
0
        private async void AlbumSongList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            if (MediaPlayList.AlbumSongList.CurrentItemIndex == 4294967295)
            {
                return;
            }

            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                BackBlurBrush.Amount = 0;
                BackBlurTicker.Start();
                LrcControl.c_lrc_items.Children.Clear();

                if (MusicPage.ThisPage.MediaControl.MediaPlayer.Source == MediaPlayList.AlbumSongList)
                {
                    try
                    {
                        RollTicker.Start();
                    }
                    catch (Exception) { }
                    SearchSingleMusic PL = MediaPlayList.AlbumSongBackup[Convert.ToInt32(MediaPlayList.AlbumSongList.CurrentItemIndex)];
                    Title.Text           = PL.MusicName;

                    var SongSearchResult = await NetEaseMusic.SearchAsync <SingleMusicSearchResult>(PL.MusicName, 5, 0, NeteaseMusicAPI.SearchType.Song);

                    foreach (var Song in SongSearchResult.Result.Songs.Where(Song => Song.Name == PL.MusicName && Song.Ar[0].Name == PL.Artist && Song.Al.Name == PL.Album).Select(Song => Song))
                    {
                        var bitmap         = new BitmapImage();
                        Image1.ImageSource = bitmap;
                        bitmap.UriSource   = new Uri(Song.Al.PicUrl);
                        break;
                    }

                    GridBack.Background = new ImageBrush
                    {
                        ImageSource = Image1.ImageSource,
                        Stretch     = Stretch.UniformToFill
                    };

                    LyricResult LrcTemp = await NetEaseMusic.GetLyricAsync(PL.SongID[0]);
                    if (LrcTemp.Lrc == null)
                    {
                        TextBlock TB = new TextBlock()
                        {
                            Text     = "纯音乐,无歌词",
                            FontSize = 18
                        };
                        LrcControl.c_lrc_items.Children.Add(TB);
                        RollTicker.Stop();
                    }
                    else
                    {
                        LrcControl.LoadLrc(LrcTemp.Lrc.Lyric, LrcTemp.Tlyric.Lyric);
                    }
                }
                else
                {
                    try
                    {
                        RollTicker.Start();
                    }
                    catch (Exception) { }

                    var bitmap         = new BitmapImage();
                    Image1.ImageSource = bitmap;
                    bitmap.UriSource   = new Uri(MusicSearch.ForDetail_ImageURL);

                    GridBack.Background = new ImageBrush
                    {
                        ImageSource = Image1.ImageSource,
                        Stretch     = Stretch.UniformToFill
                    };

                    Title.Text = MusicSearch.ForDetail_Name;

                    LyricResult LrcTemp = await NetEaseMusic.GetLyricAsync(MusicSearch.ForDetail_ID);
                    if (LrcTemp.Lrc == null)
                    {
                        TextBlock TB = new TextBlock()
                        {
                            Text     = "纯音乐,无歌词",
                            FontSize = 18
                        };
                        LrcControl.c_lrc_items.Children.Add(TB);
                        RollTicker.Stop();
                    }
                    else
                    {
                        LrcControl.LoadLrc(LrcTemp.Lrc.Lyric, LrcTemp.Tlyric.Lyric);
                    }
                }
            });
        }