예제 #1
0
 private void ListBoxPlayList_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (ListBoxPlayList.SelectedIndex != -1 && ListBoxPlayList.SelectedIndex != HyPlayList.NowPlaying)
     {
         HyPlayList.SongMoveTo(ListBoxPlayList.SelectedIndex);
     }
 }
예제 #2
0
        public static async void LoadNextFM()
        {
            var(isOk, json) = await Common.ncapi.RequestAsync(CloudMusicApiProviders.PersonalFm);

            if (isOk)
            {
                var    song   = json["data"][0];
                NCSong NCSong = new NCSong()
                {
                    Album = new NCAlbum()
                    {
                        cover = song["album"]["picUrl"].ToString(),
                        id    = song["album"]["id"].ToString(),
                        name  = song["album"]["name"].ToString()
                    },
                    sid                  = song["id"].ToString(),
                    songname             = song["name"].ToString(),
                    Artist               = new List <NCArtist>(),
                    LengthInMilliseconds = double.Parse(song["duration"].ToString())
                };
                song["artists"].ToList().ForEach(t =>
                {
                    NCSong.Artist.Add(new NCArtist()
                    {
                        id   = t["id"].ToString(),
                        name = t["name"].ToString()
                    });
                });
                HyPlayList.RemoveAllSong();
                _ = await HyPlayList.AppendNCSong(NCSong);

                HyPlayList.SongAppendDone();
                HyPlayList.SongMoveTo(0);
            }
        }
예제 #3
0
        private void ButtonPlayAll_OnClick(object sender, RoutedEventArgs e)
        {
            Task.Run((() =>
            {
                Common.Invoke((async() =>
                {
                    HyPlayList.RemoveAllSong();
                    (bool isok, JObject json) = await Common.ncapi.RequestAsync(CloudMusicApiProviders.SongUrl,
                                                                                new Dictionary <string, object>()
                    {
                        { "id", string.Join(',', songs.Select(t => t.sid)) }, { "br", Common.Setting.audioRate }
                    });
                    if (isok)
                    {
                        List <JToken> arr = json["data"].ToList();
                        for (int i = 0; i < songs.Count; i++)
                        {
                            JToken token = arr.Find(jt => jt["id"].ToString() == songs[i].sid);
                            if (!token.HasValues)
                            {
                                continue;
                            }

                            NCSong ncSong = songs[i];

                            string tag = "";
                            if (token["type"].ToString().ToLowerInvariant() == "flac")
                            {
                                tag = "SQ";
                            }
                            else
                            {
                                tag = (token["br"].ToObject <int>() / 1000).ToString() + "k";
                            }
                            NCPlayItem ncp = new NCPlayItem()
                            {
                                tag = tag,
                                Album = ncSong.Album,
                                Artist = ncSong.Artist,
                                subext = token["type"].ToString(),
                                sid = ncSong.sid,
                                songname = ncSong.songname,
                                url = token["url"].ToString(),
                                LengthInMilliseconds = ncSong.LengthInMilliseconds,
                                size = token["size"].ToString(),
                                md5 = token["md5"].ToString()
                            };
                            HyPlayList.AppendNCPlayItem(ncp);
                        }
                        HyPlayList.SongAppendDone();

                        HyPlayList.SongMoveTo(0);
                    }
                }));
            }));
        }
예제 #4
0
        public async Task <bool> AppendMe()
        {
            if (!CanPlay)
            {
                return(false);
            }

            await HyPlayList.AppendNCSong(ncsong);

            HyPlayList.SongAppendDone();
            //此处可以进行优化
            HyPlayList.SongMoveTo(HyPlayList.List.FindIndex(t => t.NcPlayItem.sid == ncsong.sid));
            return(true);
        }
예제 #5
0
        private async void TestFile()
        {
            FileOpenPicker fop = new FileOpenPicker();

            fop.FileTypeFilter.Add(".flac");
            fop.FileTypeFilter.Add(".mp3");


            System.Collections.Generic.IReadOnlyList <Windows.Storage.StorageFile> files = await fop.PickMultipleFilesAsync();

            HyPlayList.RemoveAllSong();
            foreach (Windows.Storage.StorageFile file in files)
            {
                await HyPlayList.AppendFile(file);
            }
            HyPlayList.SongAppendDone();
            HyPlayList.SongMoveTo(0);
        }
예제 #6
0
        private async void ButtonHeartBeat_OnClick(object sender, RoutedEventArgs e)
        {
            HyPlayList.RemoveAllSong();
            (bool isOk, JObject jsona) = await Common.ncapi.RequestAsync(CloudMusicApiProviders.PlaymodeIntelligenceList,
                                                                         new Dictionary <string, object>() { { "pid", playList.plid }, { "id", intelsong } });

            if (isOk)
            {
                List <NCSong> Songs = new List <NCSong>();
                foreach (JToken token in jsona["data"])
                {
                    NCSong ncSong = new NCSong()
                    {
                        Album = new NCAlbum()
                        {
                            cover = token["songInfo"]["al"]["picUrl"].ToString(),
                            id    = token["songInfo"]["al"]["id"].ToString(),
                            name  = token["songInfo"]["al"]["name"].ToString()
                        },
                        Artist = new List <NCArtist>(),
                        LengthInMilliseconds = double.Parse(token["songInfo"]["dt"].ToString()),
                        sid      = token["songInfo"]["id"].ToString(),
                        songname = token["songInfo"]["name"].ToString()
                    };
                    token["songInfo"]["ar"].ToList().ForEach(t =>
                    {
                        ncSong.Artist.Add(new NCArtist()
                        {
                            id   = t["id"].ToString(),
                            name = t["name"].ToString()
                        });
                    });
                    Songs.Add(ncSong);
                }

                (bool isok, JObject json) = await Common.ncapi.RequestAsync(CloudMusicApiProviders.SongUrl,
                                                                            new Dictionary <string, object>() { { "id", string.Join(",", Songs.Select(t => t.sid)) }, { "br", Common.Setting.audioRate } });

                ;
                if (isok)
                {
                    List <JToken> arr = json["data"].ToList();
                    for (int i = 0; i < Songs.Count; i++)
                    {
                        JToken token = arr.Find(jt => jt["id"].ToString() == Songs[i].sid);
                        if (!token.HasValues)
                        {
                            continue;
                        }

                        NCSong ncSong = Songs[i];

                        string tag = "";
                        if (token["type"].ToString().ToLowerInvariant() == "flac")
                        {
                            tag = "SQ";
                        }
                        else
                        {
                            tag = (token["br"].ToObject <int>() / 1000).ToString() + "k";
                        }

                        NCPlayItem ncp = new NCPlayItem()
                        {
                            tag                  = tag,
                            Album                = ncSong.Album,
                            Artist               = ncSong.Artist,
                            subext               = token["type"].ToString(),
                            sid                  = ncSong.sid,
                            songname             = ncSong.songname,
                            url                  = token["url"].ToString(),
                            LengthInMilliseconds = ncSong.LengthInMilliseconds,
                            size                 = token["size"].ToString(),
                            md5                  = token["md5"].ToString()
                        };
                        HyPlayList.AppendNCPlayItem(ncp);
                    }

                    HyPlayList.SongAppendDone();

                    HyPlayList.SongMoveTo(0);
                }
            }
        }