private void PlayUrlCommandExecute()
        {
            NeteaseMusicAPI api       = new NeteaseMusicAPI();
            var             apiresult = api.Search(MusicName);
            var             songList  = "";

            foreach (var song in apiresult.Result.Songs)
            {
                songList += string.Format("{0} - {1} ({2})\r\n,", song.Name, song.Ar[0].Name, api.GetSongsUrl(new long[] { song.Id }).Data[0].Url);
            }
        }
        public void Init()
        {
            var count   = 0;
            var api     = new NeteaseMusicAPI();
            var request = api.Search(SearchName);

            playList.Clear();
            foreach (var song in request.Result.Songs)
            {
                count++;
                if (count < 20)
                {
                    playList.Add(new MusicInfo(api.GetSongsUrl(new long[] { song.Id }).Data[0].Url, song.Name, song.Ar[0].Name));
                }
            }
        }
Example #3
0
        static public string MusicJson(string musicid)
        {
            var api    = new NeteaseMusicAPI();
            var apires = api.Search(musicid.ToString(), 1);
            IList <Music_info> muscis = new List <Music_info>();
            var       art             = new ArtistResult();
            musicplay music           = new musicplay();

            i++;
            music.id          = i;
            music.song        = apires.Result.Songs[0].Name;
            music.singer.name = apires.Result.Songs[0].Ar[0].Name;
            music.time        = apires.Result.Songs[0].PublishTime.ToString();
            music.words       = api.Lyric(apires.Result.Songs[0].Id).Lrc.Lyric;
            music.src         = api.GetSongsUrl(new long[] { apires.Result.Songs[0].Id }).Data[0].Url;
            music.img         = apires.Result.Songs[0].Al.PicUrl;
            music.album       = apires.Result.Songs[0].Al.Name;
            var    a      = api.Lyric(apires.Result.Songs[0].Id);
            string output = JsonConvert.SerializeObject(music);

            return(output);
        }
Example #4
0
        public static List <Music_info> Search(string musicname, int i = 10)
        {
            var api    = new NeteaseMusicAPI();
            var apires = api.Search(musicname, i);
            var name   = "";
            List <Music_info> musics = new List <Music_info>();

            name = apires.Result.Songs[0].Ar[0].Name;
            foreach (var song in apires.Result.Songs)
            {
                Music_info music = new Music_info();
                music.music_name   = string.Format("{0}", song.Name);
                music.music_alname = song.Ar[0].Name;
                music.musci_url    = api.GetSongsUrl(new long[] { song.Id }).Data[0].Url;
                music.music_picurl = song.Al.PicUrl;
                music.album        = song.Al.Name;
                music.id           = song.Id;
                music.albumid      = song.Al.Id;
                musics.Add(music);
            }
            return(musics);
        }
Example #5
0
        /// <summary>
        /// 获取网易云音乐的歌曲Id集合,并返回到SercherResultList集合中
        /// </summary>
        /// <param name="SercherKeys">通过歌曲名在网络上搜索Id</param>
        /// <param name="Id">如果已经拥有歌曲ID</param>
        /// <returns></returns>
        private void GetMusicIds(string SercherKeys, string Id = null)
        {
            var CloudMusicApi = new NeteaseMusicAPI();
            var res           = CloudMusicApi.Search(SercherKeys, type: NeteaseMusicAPI.SearchType.Song).Result;

            if (res.Songs == null)
            {
                return;
            }
            var songs = res.Songs.Select(x => {
                return(new NetCloudLrcInfoz
                {
                    Artist = string.Join(",", x.Ar.Select(y => y.Name)),
                    Id = x.Id.ToString(),
                    Title = x.Name,
                    LrcUri = GetLrcUri(x.Id.ToString())
                });
            });

            foreach (var i in songs)
            {
                SercherResultList.Add(i);
            }
        }