Esempio n. 1
0
        private async void btn_playSelect_Click(object sender, RoutedEventArgs e)
        {
            if (list_songs.ItemsSource == null || list_songs.Items.Count == 0 || list_songs.SelectedItems.Count == 0)
            {
                Utils.ShowMessageToast("没有选中任何内容");
                return;
            }

            Utils.ShowMessageToast("开始读取播放地址");
            foreach (MusicHomeSongModel item in list_songs.SelectedItems)
            {
                if (MusicHelper.playList.Find(x => x.songid == item.id.ToString()) == null)
                {
                    var m = await MusicHelper.GetMusicUri(item.id.ToString());

                    if (m != null)
                    {
                        MusicHelper.AddToPlay(new MusicPlayModel()
                        {
                            url    = m,
                            artist = item.author,
                            pic    = item.cover_url,
                            songid = item.id.ToString(),
                            title  = item.title
                        });
                    }
                    else
                    {
                        await new MessageDialog("无法读取歌曲:" + item.title + " 的播放地址").ShowAsync();
                    }
                }
            }

            Utils.ShowMessageToast("已添加到播放列表");
        }
Esempio n. 2
0
        private async void btn_Play_Click(object sender, RoutedEventArgs e)
        {
            if (this.DataContext == null)
            {
                return;
            }



            var m = await MusicHelper.GetMusicUri(_songId);

            if (m != null)
            {
                MusicHelper.AddToPlay(new MusicPlayModel()
                {
                    url = m
                });
            }
            else
            {
                await new MessageDialog("无法读取歌曲播放地址").ShowAsync();
            }
            Utils.ShowMessageToast("已经添加到播放列表");
        }
Esempio n. 3
0
        private async void LoadMusic(string id)
        {
            try
            {
                string url = string.Format("https://api.bilibili.com/audio/music-service-c/songs/playing?access_key={0}&appkey={1}&build=5250000&mid={2}&mobi_app=android&platform=android&song_id={3}&ts={4}",
                                           ApiHelper.access_key, ApiHelper._appKey, ApiHelper.GetUserId(), id, ApiHelper.GetTimeSpan);
                url += "&sign=" + ApiHelper.GetSign(url);

                string re = await WebClientClass.GetResults(new Uri(url));

                SongInfoModel obj = JsonConvert.DeserializeObject <SongInfoModel>(re);
                if (obj.code == 0)
                {
                    if (obj.data.mid == 0)
                    {
                        user.Visibility  = Visibility.Collapsed;
                        intro.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        user.Visibility  = Visibility.Visible;
                        intro.Visibility = Visibility.Visible;
                    }
                    if (obj.data.pgc_info != null)
                    {
                        btn_OpenPcMenu.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        btn_OpenPcMenu.Visibility = Visibility.Collapsed;
                    }
                    this.DataContext = obj.data;

                    //if (obj.data.is_collect==0)
                    //{
                    //    btn_Collect.Visibility = Visibility.Visible;
                    //    btn_CancelCollect.Visibility = Visibility.Collapsed;
                    //}
                    //else
                    //{
                    //    btn_Collect.Visibility = Visibility.Collapsed;
                    //    btn_CancelCollect.Visibility = Visibility.Visible;
                    //}

                    if (obj.data.up_is_follow == 0)
                    {
                        btn_FollowUser.Visibility       = Visibility.Visible;
                        btn_CancelFollowUser.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        btn_FollowUser.Visibility       = Visibility.Collapsed;
                        btn_CancelFollowUser.Visibility = Visibility.Visible;
                    }


                    if (MusicHelper.playList.Find(x => x.songid == _songId) == null)
                    {
                        var m = await MusicHelper.GetMusicUri(_songId);

                        if (m != null)
                        {
                            MusicHelper.AddToPlay(new MusicPlayModel()
                            {
                                url    = m,
                                artist = obj.data.author,
                                pic    = obj.data.cover_url,
                                songid = id,
                                title  = obj.data.title
                            });
                        }
                        else
                        {
                            await new MessageDialog("无法读取歌曲播放地址").ShowAsync();
                        }
                        Utils.ShowMessageToast("已经添加到播放列表");
                    }
                }
                else
                {
                    Utils.ShowMessageToast(obj.msg);
                }
            }
            catch (Exception)
            {
                Utils.ShowMessageToast("读取歌曲信息错误");
            }
        }