Ejemplo n.º 1
0
 public void Play(songInfo s)
 {
     /*
     WMPLib.IWMPPlaylist playlist = null;
     playlist = axWindowsMediaPlayer1.playlistCollection.newPlaylist("playlist");
     playlist.appendItem(axWindowsMediaPlayer1.newMedia(s.getSongURL()));
     axWindowsMediaPlayer1.currentPlaylist = playlist;
     axWindowsMediaPlayer1.Ctlcontrols.currentItem = playlist.Item[0];
     */
     axWindowsMediaPlayer1.URL = s.getSongURL();
 }
Ejemplo n.º 2
0
        public void addSong(songInfo i)
        {
            ListViewItem l = new ListViewItem();
            l.Text = " ";
            l.SubItems.Add(i.getSongName());
            l.SubItems.Add(i.getBy());
            listView1.Items.Add(l);

            playlist.Enqueue(i);
            if (listView1.Items.IndexOf(l) == 0)
            {
                listView1.Items[0].Text = "√";
                p.Play(i);
                playlist.Dequeue();
            }
        }
Ejemplo n.º 3
0
        //接受弹幕 估计是整个程序的核心了吧
        private void Class1_ReceivedDanmaku(object sender, BilibiliDM_PluginFramework.ReceivedDanmakuArgs e)
        {
            string d_txt = e.Danmaku.CommentText;
            string d_by = e.Danmaku.CommentUser;

            if (d_txt == null) return;
            if (d_txt.Substring(0, 2) == "点歌")
            {
                string id = d_txt.Substring(3);
                songInfo newsong = new songInfo(id, d_by);
                if (!newsong.err)
                {
                    l_frmSongList.addSong(newsong);
                }
                else
                {
                    AddDM(d_by + "输入的歌曲id:" + id + "有误!");
                }
            }
            if (d_txt.Substring(0, 2) == "歌单")
            {
                //原有歌曲数量
                int oldnum = l_frmSongList.getSongNum();

                if (e.Danmaku.isAdmin == true)
                {
                    string id = d_txt.Substring(3);

                    string url = "http://music.163.com/api/playlist/detail?id=" + id;
                    WebClient w = new WebClient();
                    Stream sc = w.OpenRead(url);
                    StreamReader sr = new StreamReader(sc, Encoding.UTF8);
                    string json = sr.ReadToEnd();
                    sr.Close();
                    sc.Close();

                    Newtonsoft.Json.Linq.JObject jo = Newtonsoft.Json.Linq.JObject.Parse(json);
                    int i = 0;

                    while (i < jo["result"]["tracks"].Count())
                    {
                        string name = jo["result"]["tracks"][i]["name"].ToString();
                        string m_url = jo["result"]["tracks"][i]["mp3Url"].ToString();
                        long last = Convert.ToInt32(jo["result"]["tracks"][i]["duration"]);
                        songInfo newsong = new songInfo(id, name, last, m_url, d_by);

                        l_frmSongList.addSong(newsong);

                        i++;
                    }
                    #region

                    /*
                    json = json.Substring(json.IndexOf("popularity") + 10);

                    while (json.IndexOf("mp3Url") != -1 && json.IndexOf("popularity") != -1)
                    {
                        songInfo newsong = new songInfo(id, json, d_by);
                        if (!newsong.err)
                        {
                            l_frmSongList.addSong(newsong);
                            json = json.Substring(json.IndexOf("popularity") + 10);
                        }
                        else
                        {
                            AddDM(d_by + "输入的歌单id:" + id + "有误!");
                            break;
                        }
                    }

                    //补充处理
                    l_frmSongList.addSong(new songInfo(id, json, d_by));

                    //l_frmSongList.delSong(oldnum+1);
                    */
                    #endregion
                }
                else
                {
                    AddDM("只有房管才能点歌单!");
                }
            }
            //throw new NotImplementedException();
        }
Ejemplo n.º 4
0
        //管理插件
        public override void Admin()
        {
            string d_txt = Input.InputBox.ShowInputBox("请输入需要发送的弹幕!", string.Empty);
            string d_by = "DS";

            if (d_txt.Substring(0, 2) == "点歌")
            {
                d_by = d_by + " - 单曲";
                string id = d_txt.Substring(3);
                songInfo newsong = new songInfo(id, d_by);
                if (!newsong.err)
                {
                    l_frmSongList.addSong(newsong);
                }
                else
                {
                    AddDM(d_by + "输入的歌曲id:" + id + "有误!");
                }
            }
            if (d_txt.Substring(0, 2) == "歌单")
            {
                d_by = d_by + " - 歌单";

                string id = d_txt.Substring(3);
                string url = "http://music.163.com/api/playlist/detail?id=" + id;
                WebClient w = new WebClient();
                Stream sc = w.OpenRead(url);
                StreamReader sr = new StreamReader(sc, Encoding.UTF8);
                string json = sr.ReadToEnd();
                sr.Close();
                sc.Close();

                Newtonsoft.Json.Linq.JObject jo = Newtonsoft.Json.Linq.JObject.Parse(json);
                int i = 0;

                while (i < jo["result"]["tracks"].Count())
                {
                    string name = jo["result"]["tracks"][i]["name"].ToString();
                    string m_url = jo["result"]["tracks"][i]["mp3Url"].ToString();
                    long last = Convert.ToInt32(jo["result"]["tracks"][i]["duration"]);
                    songInfo newsong = new songInfo(id, name, last, m_url, d_by);
                    l_frmSongList.addSong(newsong);
                    i++;
                }
            }
            else
            {
                AddDM(d_txt);
            }
            base.Admin();
        }