Beispiel #1
0
 private async void DownloadItem_LoadedAsync(object sender, RoutedEventArgs e)
 {
     tb.Text = MData.MusicName + " - " + MData.SingerText;
     d       = new HttpDownloadHelper(MData.MusicID, path);
     Loadedd();
     d.ProgressChanged += (pro) =>
     {
         Dispatcher.Invoke(() =>
         {
             finished = true;
             Pb.Value = pro;
             zt.Text  = pro + "%";
         });
     };
     d.Finished += () =>
     {
         Dispatcher.Invoke(() =>
         {
             finished = true;
             zt.Text  = "已完成";
         });
     };
     d.GetSize += (s) =>
     {
         Dispatcher.Invoke(() =>
         {
             size.Text = s;
         });
     };
     if (index == 0 || index == 1 || index == 2)
     {
         d.Download();
     }
     await MusicLib.GetLyric(MData.MusicID, path.Replace(".mp3", ".lrc"));
 }
Beispiel #2
0
        private async void FanBt_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (Data.HasGJ)
            {
                Data.HasGJ      = false;
                FanBt.p.Stretch = Stretch.Fill;
                await MusicLib.DelSingerLikeById(Data.mSinger.Mid);

                FanBt.TName = "关注";
                FanBt.pData = Geometry.Parse("M451.318,451.318L87.282,451.318C53.528,451.318 26.548,478.486 26.548,512 26.548,545.747 53.739,572.682 87.282,572.682L451.318,572.682 451.318,936.718C451.318,970.472 478.486,997.452 512,997.452 545.747,997.452 572.682,970.261 572.682,936.718L572.682,572.682 936.718,572.682C970.472,572.682 997.452,545.514 997.452,512 997.452,478.253 970.261,451.318 936.718,451.318L572.682,451.318 572.682,87.282C572.682,53.528 545.514,26.548 512,26.548 478.253,26.548 451.318,53.739 451.318,87.282L451.318,451.318z");
                FanBt.Theme = 2;
            }
            else
            {
                Data.HasGJ = true;
                await MusicLib.AddSingerLikeById(Data.mSinger.Mid);

                if (Data.HasBigPic)
                {
                    FanBt.Theme = 1;
                }
                else
                {
                    FanBt.Theme = 0;
                }
                FanBt.TName     = "已关注";
                FanBt.p.Stretch = Stretch.Uniform;
                FanBt.pData     = Geometry.Parse("M825.742222 376.035556l-349.866666 355.612444a45.169778 45.169778 0 0 1-64.568889 0L213.560889 530.602667a46.478222 46.478222 0 0 1-13.368889-32.768c0-25.6 20.48-46.364444 45.624889-46.364445 12.629333 0 24.064 5.233778 32.312889 13.653334l165.489778 168.106666 317.610666-322.844444a45.283556 45.283556 0 0 1 32.312889-13.539556 46.08 46.08 0 0 1 45.624889 46.364445 46.648889 46.648889 0 0 1-13.425778 32.824889z");
            }
        }
        public async void GetSingerList(int cur_page = 1)
        {
            if (cur_page == 1)
            {
                ItemsList.Opacity = 0;
            }
            mw.OpenLoading();
            ixSingerList = cur_page;
            var data = await MusicLib.GetSingerIFollowListAsync(cur_page);

            if (cur_page == 1)
            {
                ItemsList.Children.Clear();
            }
            foreach (var d in data)
            {
                var sinx = new SingerItem(d)
                {
                    Margin = new Thickness(12, 0, 12, 20)
                };
                sinx.MouseDown += mw.GetSinger;
                ItemsList.Children.Add(sinx);
            }
            mw.WidthUI(ItemsList);
            mw.CloseLoading();
            if (cur_page == 1)
            {
                await Task.Delay(10);

                mw.RunAnimation(ItemsList, new Thickness(0, 50, 0, 0));
            }
        }
        public async void PlayMv(MVData mVData)
        {
            mvt.Interval     = 1000;
            mvt.Tick        += Mvt_Tick;
            MVplaying        = true;
            Title            = mVData.name;
            MvPlay_Tb.Text   = mVData.name;
            MvPlay_Tb.Uid    = mVData.id;
            MvPlay_Desc.Text = await MusicLib.GetMVDesc(mVData.id);

            MvPlay_ME.Source = new Uri(await MusicLib.GetMVUrl(mVData.id));
            MvPlay_ME.Play();
            mvpath.Data = Geometry.Parse(mvpause);
            mvt.Start();
            //加载评论
            List <MusicPL> data = await MusicLib.GetMVPL(MvPlay_Tb.Uid);

            MVPlList.Children.Clear();
            foreach (var dt in data)
            {
                MVPlList.Children.Add(new PlControl(dt)
                {
                    Margin = new Thickness(10, 0, 0, 20)
                });
            }
            Activate();
            Topmost = false;
            double ps = ActualWidth / MvPlay_ME.NaturalVideoWidth;

            MV.Height = MvPlay_ME.NaturalVideoHeight * ps;
        }
Beispiel #5
0
        /// <summary>
        /// API调试台
        /// </summary>
        static async Task Main()
        {
            await Settings.LoadUSettings("2728578956");

            var _ = await MusicLib.GetSongListAboutSong("000MW82Z2j20g2");

            Console.WriteLine(_.Count);
            Console.ReadLine();
        }
Beispiel #6
0
        private void Mdb_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Gdpop.IsOpen = false;
            string name = (sender as MDButton).TName;
            string id   = ListData[name];

            string[] a = MusicLib.AddMusicToGD(music.MusicID, id);
            Toast.Send(a[1] + ": " + a[0]);
        }
Beispiel #7
0
        public void GetMissingSongTest()
        {
            MusicLib musicLib = new MusicLib();

            // Get a song that doesn't exist
            int  songId = 111;
            Song song   = musicLib.GetSong(songId);

            Assert.IsNull(song);
        }
Beispiel #8
0
        public void UpdateMissingSongTest()
        {
            MusicLib musicLib = new MusicLib();

            // Try to update a song with a bad ID
            int  songId    = 111;
            bool isUpdated = musicLib.UpdateSong(songId, defaultSong);

            Assert.IsFalse(isUpdated, "Update should NOT have worked; got back " + isUpdated);
        }
Beispiel #9
0
        public void DeleteMissingSongTest()
        {
            MusicLib musicLib = new MusicLib();

            // Delete a song that does not exist
            int  songId      = 111;
            bool songDeleted = musicLib.DeleteSong(songId);

            Assert.IsFalse(songDeleted, "Non-existing song should not have been deleted");
        }
Beispiel #10
0
        public void GetSongTest()
        {
            MusicLib musicLib = new MusicLib();

            // Add the default song and then retrieve it
            int  songId = musicLib.AddSong(defaultSong);
            Song song   = musicLib.GetSong(songId);

            Assert.AreEqual(defaultSong, song);
        }
 public MainWindow()
 {
     InitializeComponent();
     musicLib           = new MusicLib();
     musicPlayer        = new MusicPlayer();
     IsPlaylistSelected = false;
     SetupSongGrid();
     SetupButtonListeners();
     SetupPlaylistList();
 }
        private async void Mdb_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Gdpop.IsOpen = false;
            string name = (sender as ListBoxItem).Content.ToString();
            string id   = ListData[name];

            string[] a = await MusicLib.AddMusicToGDAsync(music.MusicID, id);

            Toast.Send(a[1] + ": " + a[0]);
        }
Beispiel #13
0
        private async void DeleteBtn_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (TwMessageBox.Show("确定要删除此歌曲吗?"))
            {
                int    index = He.MGData_Now.Data.IndexOf(music);
                string dirid = await MusicLib.GetGDdiridByNameAsync(He.MGData_Now.name);

                string Musicid = He.MGData_Now.ids[index];
                Mainwindow.DataItemsList.Items.RemoveAt(index);
                Toast.Send(MusicLib.DeleteMusicFromGD(Musicid, He.MGData_Now.id, dirid));
            }
        }
Beispiel #14
0
        private async void SongsBtn_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (SongsPage.Children.Count == 0)
            {
                var data = await MusicLib.GetSingerMusicByIdAsync(Data.mSinger.Mid);

                mview = new MusicListView(data, mw, NowPage.SingerItem);
                SongsPage.Children.Add(mview);
            }
            await Task.Delay(10);

            NSPage(SongsPage);
        }
        private async void DeleteBtn_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (TwMessageBox.Show("确定要删除此歌曲吗?"))
            {
                string dirid = await MusicLib.GetGDdiridByNameAsync(He.MGData_Now.name);

                string Musicid = He.MGData_Now.ids[index];
                Toast.Send(await MusicLib.DeleteMusicFromGDAsync(new string[1] {
                    Musicid
                }, dirid));
                Mainwindow.DataItemsList.Items.Remove(this);
                He.MGData_Now.Data.Remove(music);
            }
        }
Beispiel #16
0
        private async void Border_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (data.ispraise)
            {
                zp.Fill = new SolidColorBrush(Color.FromRgb(153, 153, 153)); ztb.Text = (int.Parse(data.like) - 1).ToString(); data.like = ztb.Text;
            }
            else
            {
                zp.SetResourceReference(Shape.FillProperty, "ThemeColor"); ztb.Text = (int.Parse(data.like) + 1).ToString(); data.like = ztb.Text;
            }
            await MusicLib.PraiseMusicPLAsync(Settings.USettings.Playing.MusicID, data);

            data.ispraise = !data.ispraise;
        }
Beispiel #17
0
        public async void LoadMv()
        {
            var data = await MusicLib.GetSingerMvList(Data.mSinger.Mid, MvIndex);

            foreach (var c in data)
            {
                MVItem m = new MVItem();
                m.Margin     = new Thickness(12, 0, 12, 20);
                m.MouseDown += M_MouseDown;
                MvItemsList.Children.Add(m);
                m.Data = c;
            }
            WidthUI(MvItemsList);
        }
Beispiel #18
0
        private async void MoreBtn_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (MoreText.Inlines.Count == 0)
            {
                var data = await MusicLib.GetSingerDesc(Data.mSinger.Mid);

                MoreText.Inlines.Add(new Run()
                {
                    Text = data.Desc
                });
                MoreText.Inlines.Add(new LineBreak());
                MoreText.Inlines.Add(new LineBreak());
                Run r1 = new Run()
                {
                    Text = "基本资料"
                };
                r1.SetResourceReference(ForegroundProperty, "PlayDLPage_Font_Most");
                MoreText.Inlines.Add(r1);
                MoreText.Inlines.Add(new LineBreak());
                foreach (var c in data.basic)
                {
                    MoreText.Inlines.Add(new Run()
                    {
                        Text = c.Key + ":" + c.Value
                    });
                    MoreText.Inlines.Add(new LineBreak());
                }
                MoreText.Inlines.Add(new LineBreak());
                foreach (var c in data.other)
                {
                    Run r2 = new Run()
                    {
                        Text = c.Key
                    };
                    r2.SetResourceReference(ForegroundProperty, "PlayDLPage_Font_Most");
                    MoreText.Inlines.Add(r2);
                    MoreText.Inlines.Add(new LineBreak());
                    MoreText.Inlines.Add(new Run()
                    {
                        Text = c.Value
                    });
                    MoreText.Inlines.Add(new LineBreak());
                    MoreText.Inlines.Add(new LineBreak());
                }
            }
            await Task.Delay(10);

            NSPage(MorePage);
        }
 public async void Download()
 {
     await Task.Run(async() =>
     {
         string Url = await MusicLib.GetUrlAsync(Id);
         Console.WriteLine(Path + "  " + Downloading + "\r\n" + Url);
         HttpWebRequest Myrq = (HttpWebRequest)WebRequest.Create(Url);
         Myrq.Accept         = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9";
         Myrq.Headers.Add("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6");
         Myrq.Headers.Add("Cache-Control", "max-age=0");
         Myrq.KeepAlive = true;
         Myrq.Headers.Add("Cookie", Settings.USettings.Cookie);
         Myrq.Host = "aqqmusic.tc.qq.com";
         Myrq.Headers.Add("Upgrade-Insecure-Requests", "1");
         Myrq.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.66 Safari/537.36 Edg/80.0.361.40";
         var myrp       = (HttpWebResponse)Myrq.GetResponse();
         Console.WriteLine(myrp.StatusCode.ToString());
         var totalBytes = myrp.ContentLength;
         GetSize(Getsize(totalBytes));
         Stream st = myrp.GetResponseStream();
         Stream so = new FileStream(Path, FileMode.Create);
         long totalDownloadedByte = 0;
         byte[] by = new byte[1048576];
         int osize = await st.ReadAsync(by, 0, (int)by.Length);
         while (osize > 0)
         {
             if (stop)
             {
                 break;
             }
             if (Downloading)
             {
                 totalDownloadedByte = osize + totalDownloadedByte;
                 await so.WriteAsync(by, 0, osize);
                 osize    = await st.ReadAsync(by, 0, (int)by.Length);
                 Progress = (int)((float)totalDownloadedByte / (float)totalBytes * 100);
                 ProgressChanged(Progress);
                 Console.WriteLine("downloading:" + Progress);
             }
         }
         st.Close();
         so.Close();
         myrp.Close();
         if (!stop)
         {
             Finished();
         }
     });
 }
Beispiel #20
0
        public void DeleteSongTest()
        {
            MusicLib musicLib = new MusicLib();

            // Delete a song that already exists
            int  songId      = 8;
            bool songDeleted = musicLib.DeleteSong(songId);

            Assert.IsTrue(songDeleted, "Song should have been deleted");

            // Verify the song is not in the library anymore
            Song s = musicLib.GetSong(songId);

            Assert.IsNull(s, "Returned song should be null because it doesn't exist");
        }
Beispiel #21
0
        public void AddSongTest()
        {
            MusicLib musicLib = new MusicLib();

            // ID auto-increments
            int expectedId = 9;
            int actualId   = musicLib.AddSong(defaultSong);

            Assert.AreEqual(expectedId, actualId, "ID of added song was unexpectedly " + actualId);

            // See if we can get back the song that was just added
            Song song = musicLib.GetSong(expectedId);

            Assert.AreEqual(defaultSong, song, "Got back unexpected song: " + song);
        }
Beispiel #22
0
        public void GetSongTest()
        {
            MusicLib musicLib = new MusicLib();

            // Add the default song and then retrieve it
            int  songId   = musicLib.AddSong(defaultSong);
            Song expected = defaultSong;
            Song actual   = musicLib.GetSong(songId);

            Assert.AreEqual(expected, actual);

            // Get a song that doesn't exist
            songId = 111;
            actual = musicLib.GetSong(songId);
            Assert.IsNull(actual);
        }
Beispiel #23
0
        private async void Load()
        {
            Radiodata = await MusicLib.GetRadioList();

            foreach (var list in Radiodata)
            {
                RbBox r = new RbBox();
                r.ContentText = list.Key;
                r.Margin      = new Thickness(20, 0, 0, 0);
                r.Checked    += RadioPageChecked;
                RadioIndexList.Children.Add(r);
            }
            RbBox first = RadioIndexList.Children[0] as RbBox;

            first.Check(true);
            RadioPageChecked(first);
        }
Beispiel #24
0
        public void UpdateSongTest()
        {
            MusicLib musicLib = new MusicLib();

            // Update a song's title
            int songId = musicLib.AddSong(defaultSong);

            defaultSong.Title = "Horrible Song";
            bool isUpdated = musicLib.UpdateSong(songId, defaultSong);

            Assert.IsTrue(isUpdated, "Update should have worked; got back " + isUpdated);

            // Make sure the song's title was really changed
            Song s = musicLib.GetSong(songId);

            Assert.AreEqual(defaultSong, s, "Title was not updated properly");
        }
Beispiel #25
0
        private async void GetGDList(string id, int osx = 1)
        {
            if (osx == 1)
            {
                FLGDItemsList.Opacity = 0;
            }
            FLGDPage_Tag.Uid = id;
            ixFLGD           = osx;
            mw.OpenLoading();
            var data = await mw.ml.GetFLGDAsync(id, sortId, osx);

            if (osx == 1)
            {
                FLGDItemsList.Children.Clear();
            }
            foreach (var d in data)
            {
                var k = new FLGDIndexItem(d.ID, d.Name, d.Photo, d.ListenCount)
                {
                    Margin = new Thickness(12, 0, 12, 20)
                };
                k.StarEvent += async(sx) =>
                {
                    await MusicLib.AddGDILikeAsync(sx.id);

                    Toast.Send("收藏成功");
                };
                k.ImMouseDown += mw.FxGDMouseDown;
                FLGDItemsList.Children.Add(k);
            }
            mw.WidthUI(FLGDItemsList);
            if (osx == 1)
            {
                FLGDPage_sv.BeginAnimation(UIHelper.ScrollViewerBehavior.VerticalOffsetProperty, new DoubleAnimation(0, TimeSpan.FromSeconds(0)));
            }
            mw.CloseLoading();
            if (osx == 1)
            {
                await Task.Delay(10);

                mw.RunAnimation(FLGDItemsList);
            }
        }
Beispiel #26
0
 private async void Border_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (data.ispraise)
     {
         zp.SetResourceReference(Shape.FillProperty, "PlayDLPage_Font_Low");
         ztb.Text  = (int.Parse(data.like) - 1).ToString();
         data.like = ztb.Text;
         Console.WriteLine(await MusicLib.PraiseMusicPLAsync(Settings.USettings.Playing.MusicID, data));
         data.ispraise = false;
     }
     else
     {
         zp.SetResourceReference(Shape.FillProperty, "ThemeColor");
         ztb.Text  = (int.Parse(data.like) + 1).ToString();
         data.like = ztb.Text;
         Console.WriteLine(await MusicLib.PraiseMusicPLAsync(Settings.USettings.Playing.MusicID, data));
         data.ispraise = true;
     }
 }
Beispiel #27
0
        private async void LoadAlbum()
        {
            var data = await MusicLib.GetSingerAlbumById(Data.mSinger.Mid, AlbumIndex);

            foreach (var d in data)
            {
                var k = new FLGDIndexItem(d.ID, d.Name, d.Photo, 0)
                {
                    Margin = new Thickness(12, 0, 12, 20)
                };
                k.StarEvent += (sx) =>
                {
                    MusicLib.AddGDILike(sx.id);
                    Toast.Send("收藏成功");
                };
                k.Width        = 200;
                k.ImMouseDown += K_ImMouseDown;
                AlbumItemsList.Children.Add(k);
            }
            WidthUI(AlbumItemsList);
        }
Beispiel #28
0
        public void DeleteSongTest()
        {
            MusicLib musicLib = new MusicLib();

            // Delete a song that already exists
            int  songId   = 8;
            bool expected = true;
            bool actual   = musicLib.DeleteSong(songId);

            Assert.AreEqual(expected, actual, "Delete should have worked but got back " + actual);

            // Verify the song is not in the library anymore
            Song s = musicLib.GetSong(songId);

            Assert.IsNull(s, "Returned song should be null because it doesn't exist");

            // Delete a song that doesn't exist
            songId   = 111;
            expected = false;
            actual   = musicLib.DeleteSong(songId);
            Assert.AreEqual(expected, actual, "Delete should NOT have worked but got back " + actual);
        }
Beispiel #29
0
        private async void GetSingerList(string index = "-100", string area = "-100", string sex = "-100", string genre = "-100", int cur_page = 1)
        {
            if (cur_page == 1)
            {
                SingerItemsList.Opacity = 0;
            }
            string sin = (80 * (cur_page - 1)).ToString();

            mw.OpenLoading();
            ixSingerList = cur_page;
            var data = await MusicLib.GetSingerListAsync(index, area, sex, genre, sin, cur_page);

            if (cur_page == 1)
            {
                SingerItemsList.Children.Clear();
            }
            foreach (var d in data)
            {
                var sinx = new SingerItem(d)
                {
                    Margin = new Thickness(12, 0, 12, 20)
                };
                sinx.MouseDown += mw.GetSinger;
                SingerItemsList.Children.Add(sinx);
            }
            mw.WidthUI(SingerItemsList);
            if (cur_page == 1)
            {
                SingerPage_sv.BeginAnimation(UIHelper.ScrollViewerBehavior.VerticalOffsetProperty, new DoubleAnimation(0, TimeSpan.FromSeconds(0)));
            }
            mw.CloseLoading();
            if (cur_page == 1)
            {
                await Task.Delay(10);

                mw.RunAnimation(SingerItemsList);
            }
        }
Beispiel #30
0
        public void TestSongIds()
        {
            MusicLib musicLib = new MusicLib();
            var      songIds  = new List <string>(musicLib.SongIds);

            // Make sure there are 7 IDs
            Assert.AreEqual(7, songIds.Count);

            // Make sure all IDs but 4 are present
            int idNum = 1;

            foreach (string id in songIds)
            {
                // There is no ID 4
                if (idNum == 4)
                {
                    idNum++;
                }

                Assert.AreEqual(idNum.ToString(), id);
                idNum++;
            }
        }