예제 #1
0
        private void tmrNow_Tick(object sender, EventArgs e)
        {
            try
            {
                if (axWmplayer.playState == WMPLib.WMPPlayState.wmppsPlaying)
                {
                    lblSinger.Text = "歌曲:" + axWmplayer.currentMedia.name;
                    lblTime.Text   = axWmplayer.Ctlcontrols.currentPositionString + "/" + axWmplayer.currentMedia.durationString;
                    tmrNow.Start();
                }
                if (axWmplayer.playState == WMPLib.WMPPlayState.wmppsStopped && axWmplayer.URL != "")
                {
                    PlayNext();
                }
                //int during = Convert.ToInt32(axWmplayer.currentMedia.durationString.Substring(0, 2)) * 60 + Convert.ToInt32(axWmplayer.currentMedia.durationString.Substring(3, 2));
                //double perLeft = during / (panel13.Width - picProg.Width);

                double perLeft = (panel13.Width - picProg.Width) / axWmplayer.currentMedia.duration;
                this.picProg.Left = (int)(this.axWmplayer.Ctlcontrols.currentPosition / perLeft);
                lblTime.Text      = axWmplayer.Ctlcontrols.currentPositionString + "/" + axWmplayer.currentMedia.durationString;
                if (lrcFrm != null)
                {
                    LrcConnections.DrawLrcRefresh(this.axWmplayer.Ctlcontrols.currentPositionString);
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
 private void 添加文件ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
         {
             axWmplayer.URL = openFileDialog1.FileNames[0];
             //lrcFrm.GetLrc(axWmplayer.URL);
             LrcConnections.GetLrc(axWmplayer.URL);
             isRun = true;
             axWmplayer.Ctlcontrols.play();
             lblSinger.Text = "歌曲:" + axWmplayer.currentMedia.name;
             lblTime.Text   = axWmplayer.Ctlcontrols.currentPositionString + "/" + axWmplayer.currentMedia.durationString;
             tmrNow.Start();
             lblSinger.Visible = true;
             lblTime.Visible   = true;
             for (int i = 0; i < openFileDialog1.FileNames.Length; i++)
             {
                 string path      = openFileDialog1.FileNames.GetValue(i).ToString();
                 int    temp      = path.Length;
                 int    lastIndex = path.LastIndexOf("\\") + 1;
                 strTemp.Add(path);
                 //strSong.Add(path.Substring(lastIndex, temp - lastIndex));
                 lbPlayerList.Items.Add(path.Substring(lastIndex, temp - lastIndex));
             }
             btnPlay.Image = Properties.Resources.stop;
         }
     }
     catch
     {
         return;
     }
     label1.Focus();
 }
예제 #3
0
 private void btnOpen_Click(object sender, EventArgs e)
 {
     openFileDialog1.Filter = "Lrc歌词|*.lrc;*.txt";
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         LrcConnections.LoadLrc(openFileDialog1.FileName, null);
     }
 }
예제 #4
0
 private void lbPlayerList_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     try
     {
         if (this.lbPlayerList.SelectedItems[0] != null)
         {
             axWmplayer.URL = strTemp[lbPlayerList.SelectedIndex];
             tmrNow.Start();
             lblSinger.Text    = "歌曲:" + axWmplayer.currentMedia.name;
             lblSinger.Visible = true;
             lblTime.Visible   = true;
             isRun             = true;
             LrcConnections.GetLrc(axWmplayer.URL);
         }
     }
     catch
     {
         return;
     }
 }
예제 #5
0
        private void Size2()//窗体最大值
        {
            int tempWidth = 0;

            if (UserHelper.url != null)
            {
                LrcConnections.GetLrc(UserHelper.url);
                this.lrcSortedList = LrcConnections.lrcSortedList;
                if (lrcSortedList.Count > 0)
                {
                    Graphics g = Graphics.FromHwnd(this.tsmiSetBgImage.Handle);
                    for (int i = 0; i <= lrcSortedList.Count - 1; i++)
                    {
                        tempWidth = (int)g.MeasureString(lrcList.ElementAt(i).Value, fontStyle).Width;
                        if (tempWidth > maxWidth)
                        {
                            maxWidth = tempWidth;
                        }
                    }
                    g.Dispose();
                    if (imgBack != null)
                    {
                        imgBack.Dispose();
                    }
                    if (imgLrc != null)
                    {
                        imgLrc.Dispose();
                    }
                    imgBack = new Bitmap(maxWidth, this.Height);
                    imgLrc  = new Bitmap(maxWidth, this.Height);
                    this.Refresh();
                }
                else
                {
                    Size1(new Size(100, 50));
                }
            }
        }
예제 #6
0
 private void playOrPause()
 {
     if (isRun == true && axWmplayer.URL != "")
     {
         axWmplayer.Ctlcontrols.pause();
         isRun = false;
         tmrNow.Stop();
         btnPlay.Image = Properties.Resources.playmouseover;
         label1.Focus();
     }
     else if (isRun == false && axWmplayer.URL != "")
     {
         axWmplayer.Ctlcontrols.play();
         LrcConnections.GetLrc(axWmplayer.URL);
         isRun = true;
         tmrNow.Start();
         btnPlay.Image = Properties.Resources.stopmouseover;
         label1.Focus();
     }
     lblSinger.Visible = true;
     lblTime.Visible   = true;
     label1.Focus();
 }
예제 #7
0
        public void PlayNext()
        {
            UserHelper.currentLrcIndex = 0;
            try
            {
                if (axWmplayer.URL != "")
                {
                    if (playState == 2)//全部循环
                    {
                        for (int i = 0; i < strTemp.Count; i++)
                        {
                            if (strTemp[i].Equals(axWmplayer.URL))
                            {
                                if (i == strTemp.Count - 1)
                                {
                                    lbPlayerList.SelectedIndex = 0;
                                    axWmplayer.URL             = strTemp[0];
                                    break;
                                }
                                else
                                {
                                    axWmplayer.URL             = strTemp[i + 1];
                                    lbPlayerList.SelectedIndex = i + 1;
                                    break;
                                }
                            }
                        }
                        tmrNow.Start();
                        lblSinger.Text    = "歌曲:" + axWmplayer.currentMedia.name;
                        lblSinger.Visible = true;
                        lblTime.Visible   = true;
                    }
                    else if (playState == 0)//顺序播放
                    {
                        for (int i = 0; i < strTemp.Count; i++)
                        {
                            if (strTemp[i].Equals(axWmplayer.URL))
                            {
                                if (i == strTemp.Count - 1)
                                {
                                    lbPlayerList.SelectedIndex = i;
                                    return;
                                }
                                else
                                {
                                    axWmplayer.URL             = strTemp[i + 1];
                                    lbPlayerList.SelectedIndex = i + 1;
                                    break;
                                }
                            }
                        }
                        tmrNow.Start();
                        lblSinger.Text    = "歌曲:" + axWmplayer.currentMedia.name;
                        lblSinger.Visible = true;
                        lblTime.Visible   = true;
                    }
                    else if (playState == 1)//随机播放
                    {
                        Random random = new Random();
                        int    i      = random.Next(strTemp.Count);
                        axWmplayer.URL             = strTemp[i];
                        lbPlayerList.SelectedIndex = i;

                        tmrNow.Start();
                        lblSinger.Text    = "歌曲:" + axWmplayer.currentMedia.name;
                        lblSinger.Visible = true;
                        lblTime.Visible   = true;
                    }
                    else if (playState == 3)//单曲循环
                    {
                        for (int i = 0; i < strTemp.Count; i++)
                        {
                            if (strTemp[i].Equals(axWmplayer.URL))
                            {
                                axWmplayer.URL             = strTemp[i];
                                lbPlayerList.SelectedIndex = i;
                                break;
                            }
                        }
                        tmrNow.Start();
                        lblSinger.Text    = "歌曲:" + axWmplayer.currentMedia.name;
                        lblSinger.Visible = true;
                        lblTime.Visible   = true;
                    }
                }
            }
            catch
            {
                //return;
            }
            //lrcFrm.GetLrc(axWmplayer.URL);
            LrcConnections.GetLrc(axWmplayer.URL);
        }
예제 #8
0
        private void MainFrm_Load(object sender, EventArgs e)
        {
            //RegistryKey key;
            //RegistryKey subkey;
            try
            {
                //if (this.args[0].Length != 0)
                //{
                //    string path = this.args[0];
                //    int temp = path.Length;
                //    int lastIndex = path.LastIndexOf("\\") + 1;
                //    strTemp.Add(path);
                //    lbPlayerList.Items.Add(path.Substring(lastIndex, temp - lastIndex));
                //    isRun = true;
                //    axWmplayer.URL = path;
                //    axWmplayer.Ctlcontrols.play();
                //    tmrNow.Start();
                //    lblSinger.Text = "歌曲:" + axWmplayer.currentMedia.name;
                //    lblTime.Text = axWmplayer.Ctlcontrols.currentPositionString + "/" + axWmplayer.currentMedia.durationString;
                //    lblSinger.Visible = true;
                //    lblTime.Visible = true;
                //}
                //string expath = Application.ExecutablePath;
                //key = Registry.ClassesRoot.CreateSubKey("QQMusic." + "mp3" + "");
                //key.SetValue("", "QQMusic-" + "mp3" + "");
                //key = key.CreateSubKey("DefaultIcon");
                //key.SetValue("", expath + "," + 0);
                //key = Registry.ClassesRoot.CreateSubKey("QQMusic." + "mp3" + "");
                ////
                //key = key.CreateSubKey("shell");
                //subkey = key;

                //key = subkey.CreateSubKey("Enqueue");
                //key.SetValue("", "添加到QQMusic播放列表(&Q)");
                //key = key.CreateSubKey("command");
                //key.SetValue("", '"' + expath + '"' + "/ADD" + '"' + "%1" + '"');

                //key = subkey;
                //key = key.CreateSubKey("open");
                //key = key.CreateSubKey("command");
                //key.SetValue("", '"' + expath + '"' + '"' + " %1" + '"');


                picSound.Left = Convert.ToInt32(Config.GetValue("sound"));
                axWmplayer.settings.volume = Convert.ToInt32(Config.GetValue("sound"));;


                string playlist = Application.StartupPath + @"\configure\playlist";
                if (File.Exists(playlist))
                {
                    FileStream      fsplaylist = new FileStream(playlist, FileMode.Open);
                    BinaryFormatter bfplaylist = new BinaryFormatter();
                    strTemp = (List <string>)(bfplaylist.Deserialize(fsplaylist));
                    fsplaylist.Close();
                    for (int i = 0; i < strTemp.Count; i++)
                    {
                        string path      = strTemp[i];
                        int    temp      = path.Length;
                        int    lastIndex = path.LastIndexOf("\\") + 1;
                        lbPlayerList.Items.Add(path.Substring(lastIndex, temp - lastIndex));
                    }
                    int a = new Random().Next(strTemp.Count);
                    axWmplayer.URL             = strTemp[a];
                    lbPlayerList.SelectedIndex = a;
                }
                lrcFrm = new LrcFrm(this.axWmplayer, this.tmrNow);
                //lrcFrm.mainFrm = this;
                lrcFrm.Show();
                LrcConnections.GetLrc(axWmplayer.URL);


                playState = Convert.ToInt32(Config.GetValue("playState"));

                lblSinger.Visible = false;
                lblTime.Visible   = false;

                if (playState == 0)
                {
                    tsmiPlayOrder.Checked = true;
                    tsmiPlayRand.Checked  = false;
                    tsmiPlayAll.Checked   = false;
                    tsmiPlayOne.Checked   = false;
                }
                else if (playState == 1)
                {
                    tsmiPlayOrder.Checked = false;
                    tsmiPlayRand.Checked  = true;
                    tsmiPlayAll.Checked   = false;
                    tsmiPlayOne.Checked   = false;
                }
                else if (playState == 2)
                {
                    tsmiPlayOrder.Checked = false;
                    tsmiPlayRand.Checked  = false;
                    tsmiPlayAll.Checked   = true;
                    tsmiPlayOne.Checked   = false;
                }
                else if (playState == 3)
                {
                    tsmiPlayOrder.Checked = false;
                    tsmiPlayRand.Checked  = false;
                    tsmiPlayAll.Checked   = false;
                    tsmiPlayOne.Checked   = true;
                }
            }
            catch
            {
                return;
            }
        }