Exemple #1
0
        private void button_Click(object sender, EventArgs e)
        {
            Button b = sender as Button;

            if (b.Tag == null || b.Tag.ToString() == "")
            {
                return;
            }
            willSong++;
            label2.Text = "已点:" + willSong + "首";
            //Thread.Sleep(1000);
            string songName = b.Tag.ToString();

            songList.Add(songName);
            if (songList.Count == 1)
            {
                //if (songList.First() == "null")
                //{
                //    //Thread.Sleep(1000);

                //    songList.Remove(songList.First());
                //    willSong--;
                //    label2.Text = "已点:" + willSong + "首";
                //    haveSong++;
                //    label1.Text = "已唱:" + haveSong + "首";
                //}
                //else {
                //this.Hide();  //调用Form1的Hide()方法隐藏Form1窗口
                form2             = new BOFANG(); //生成一个Form2对象
                form2.FormClosed += Form2_FormClosed;
                //form2.label1.Text = "100分";
                axWindowsMediaPlayer1 = form2.axWindowsMediaPlayer1;
                axWindowsMediaPlayer1.PlayStateChange += new AxWMPLib._WMPOCXEvents_PlayStateChangeEventHandler(this.axWindowsMediaPlayer1_PlayStateChange);
                form2.Show();  //将Form2窗体显示为模式对话框。
                axWindowsMediaPlayer1.URL = @"F:\新建文件夹\KTV---Manager\FACE\Resources\" + songList.First();
                //axWindowsMediaPlayer1.currentPlaylist.appendItem();
                //form2.axWindowsMediaPlayer1.playlistCollection.getAll().Item(0);
                try
                {
                    form2.axWindowsMediaPlayer1.Ctlcontrols.play();
                    //axWindowsMediaPlayer1.fullScreen = true;
                }
                catch (System.Runtime.InteropServices.COMException) { }

                //}
            }
            //string SongName= sender.ToString();
            //Console.WriteLine(songName);
        }
Exemple #2
0
        /// <summary>
        /// 当一首歌播放完之后
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void axWindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
        {
            string status = axWindowsMediaPlayer1.status.ToString();

            if (status == "已停止")
            {
                form2.Close();

                form2 = new BOFANG();
                form2.Show();
                socer();
            }
            //    axWindowsMediaPlayer1.URL = @"E:\KTV\KTV---Manager\KTV---Manager\FACE\Resources\杨幂-爱的供养.mp3";
            if (status == "已完成")
            {
                if (songList.Count > 1)
                {
                    //songList.Remove(songList.First());
                    //if (songList.First() != null)
                    //{

                    //label4.Text = "您的分数为:" + rand.Next(90, 100);
                    //axWindowsMediaPlayer1.Controls.Add(label4);

                    axWindowsMediaPlayer1.URL = @"F:\新建文件夹\KTV---Manager\FACE\Resources\" + songList.First();
                    //}
                    //else {
                    //    haveSong++;
                    //    label1.Text = "已唱:" + haveSong + "首";
                    //    willSong--;
                    //    label2.Text = "已点:" + willSong + "首";
                    //}
                }
                else if (songList.Count == 1)
                {
                    //label4.Text = "您的分数为:" ;
                    //panel1.Controls.Add(label4);
                    //songList.Remove(songList.First());
                }
                //haveSong++;
                label1.Text = "已唱:" + haveSong + "首";
                //if (willSong > 0)
                //{ willSong--; }
                label2.Text = "已点:" + willSong + "首";
                //Delay(2000);
                //label4.Text = "您的分数为:" + rand.Next(90, 100);
                //panel1.Controls.Add(label4);
            }
            else if (status == "准备就绪")
            {
                try
                {
                    axWindowsMediaPlayer1.Ctlcontrols.play();
                }
                catch (System.Runtime.InteropServices.COMException) { }
            }
            //ListBox list = new ListBox();
            //list.Width = 100;
            //list.Height = 100;
            //axWindowsMediaPlayer1.Ctlcontrols.play();
        }