Exemple #1
0
        /// <summary>
        /// 定时器回调函数
        /// </summary>
        void timer_Tick(object sender, object e)
        {
            time      = player.Position;
            t.AllTime = (int)time.TotalSeconds;
            t.Seconds = time.Seconds;
            t.Minutes = time.Minutes;
            if (playNum != -1 && lrcOpen == true)
            {
                lrc.ShowLrc(t.Minutes, t.Seconds, txtb1, lrc1);
            }
            if (t.AllTime == sdMusic.Maximum && t.AllTime != 0)
            {
                cb = goPlay.一首;

                playMusic(cb);
                time      = player.Position;
                t.AllTime = (int)time.TotalSeconds;
                t.Seconds = time.Seconds;
                t.Minutes = time.Minutes;
            }
        }
Exemple #2
0
 public void playMusic(goPlay cb)
 {
     if (cb == goPlay.一首)
     {
         if (count <= 0)
         {
             return;
         }
         if (p == playMode.循环播放)
         {
             if (playNum < count - 1)
             {
                 playNum++;
             }
             else if (playNum >= count - 1)
             {
                 playNum = 0;
             }
         }
         else if (p == playMode.随机播放)
         {
             num++;
             if (randomNum.Count == 0)
             {
                 madePlayNum();
             }
             if (num == count)
             {
                 randomNum.Clear();
             }
             playNum = randomNum[num];
         }
         cb = goPlay.正常播放;
     }
     else if (cb == goPlay.一首)
     {
         if (count <= 0)
         {
             return;
         }
         if (p == playMode.循环播放)
         {
             if (playNum > 0)
             {
                 playNum--;
             }
             else if (playNum <= 0)
             {
                 playNum = count - 1;
             }
         }
         else if (p == playMode.随机播放)
         {
             num--;
             if (randomNum.Count == 0)
             {
                 madePlayNum();
             }
             if (playNum == count)
             {
                 randomNum.Clear();
             }
             playNum = randomNum[num];
         }
         cb = goPlay.正常播放;
     }
     //程序在播放歌曲,按钮处于暂停样式,按下后执行暂停播放
     else if ((buttonState == 1) && (playState == 0) && cb == goPlay.继续暂停)
     {
         //播放状态playState -1:停止 0:播放 1:暂停    buttonState按钮状态 0:播放 1:暂停
         buttonState = 0;
         playState   = 1;
         //程序暂停放歌,按钮处于播放样式
         cb           = goPlay.继续暂停;
         btPlay.Style = (Style)this.FindResource("ButtonStylePlay");
         player.Pause();
     }
     //程序在暂停播放,按钮处于播放样式,按下后继续播放.这里else不要漏掉
     else if ((buttonState == 0) && (playState == 1) && cb == goPlay.继续暂停)
     {
         buttonState  = 1;
         playState    = 0;
         btPlay.Style = (Style)this.FindResource("ButtonStylePause");
         cb           = goPlay.继续暂停;
         player.Play();
     }
     //通过列表双击播放
     else if (cb == goPlay.双击列表)
     {
         playNum = (int)musicList.SelectedIndex;
         if (playNum == -1)
         {
             return;
         }
         cb = goPlay.正常播放;
     }
     if (cb == goPlay.正常播放)
     {
         if (p == playMode.单曲循环)
         {
             player.Play();
         }
         player.Close();
         buttonState = 1;
         playState   = 0;
         player.Open(new Uri(music[playNum].musicPath, UriKind.Relative));
         btPlay.Style = (Style)this.FindResource("ButtonStylePause");
         player.Play();
         Lrc.Clear(txtb1, lrc1);
         Lrc.musicName = music[playNum].musicName;
         lrc.LoadLrc(lrc1);
         cb = goPlay.继续暂停;
     }
     musicList.SelectedIndex = playNum;
     musicList.ScrollIntoView(musicList.SelectedItem);
 }
Exemple #3
0
 private void musicList_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     cb = goPlay.双击列表;
     playMusic(cb);
 }
Exemple #4
0
 private void btBack_Click(object sender, RoutedEventArgs e)
 {
     cb = goPlay.一首;
     playMusic(cb);
 }
Exemple #5
0
        /// <summary>
        /// 定时器回调函数
        /// </summary>
        void timer_Tick(object sender, object e)
        {
            time = player.Position;
            t.AllTime =(int) time.TotalSeconds;
            t.Seconds = time.Seconds;
            t.Minutes = time.Minutes;
            if (playNum != -1 && lrcOpen==true)
            {
                lrc.ShowLrc(t.Minutes, t.Seconds,txtb1,lrc1);
            }
            if (t.AllTime == sdMusic.Maximum &&t.AllTime!=0)
            {
                cb = goPlay.下一首;

                playMusic(cb);
                time = player.Position;
                t.AllTime = (int)time.TotalSeconds;
                t.Seconds = time.Seconds;
                t.Minutes = time.Minutes;
            }
        }
Exemple #6
0
 private void musicList_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     cb = goPlay.双击列表;
     playMusic(cb);
 }
Exemple #7
0
 private void btPlay_Click(object sender, RoutedEventArgs e)
 {
     if(playState!=-1)cb = goPlay.继续暂停;
     if(playState==-1) cb = goPlay.双击列表;
     playMusic(cb);
 }
Exemple #8
0
 private void btNext_Click(object sender, RoutedEventArgs e)
 {
     cb = goPlay.下一首;
     playMusic(cb);
 }
Exemple #9
0
 public void playMusic(goPlay cb)
 {
     if (cb == goPlay.下一首)
     {
         if (count<=0) return;
         if (p == playMode.循环播放)
         {
             if (playNum < count - 1) playNum++;
             else if (playNum >= count - 1) playNum = 0;
         }
         else if (p == playMode.随机播放)
         {
             num++;
             if (randomNum.Count == 0) madePlayNum();
             if (num == count) randomNum.Clear();
             playNum = randomNum[num];
         }
         cb = goPlay.正常播放;
     }
     else if (cb == goPlay.上一首)
     {
         if (count<=0) return;
         if (p==playMode.循环播放)
         {
             if (playNum > 0) playNum--;
             else if (playNum <= 0) playNum = count - 1;
         }
         else if (p == playMode.随机播放)
         {
             num--;
             if (randomNum.Count == 0) madePlayNum();
             if (playNum == count) randomNum.Clear();
             playNum = randomNum[num];
         }
         cb = goPlay.正常播放;
     }
     //程序在播放歌曲,按钮处于暂停样式,按下后执行暂停播放
     else if ((buttonState == 1) && (playState == 0) && cb == goPlay.继续暂停)
     {
         //播放状态playState -1:停止 0:播放 1:暂停    buttonState按钮状态 0:播放 1:暂停
         buttonState = 0;
         playState = 1;
         //程序暂停放歌,按钮处于播放样式
         cb = goPlay.继续暂停;
         btPlay.Style = (Style)this.FindResource("ButtonStylePlay");
         player.Pause();
     }
     //程序在暂停播放,按钮处于播放样式,按下后继续播放.这里else不要漏掉
     else if ((buttonState == 0) && (playState == 1) && cb == goPlay.继续暂停)
     {
         buttonState = 1;
         playState = 0;
         btPlay.Style = (Style)this.FindResource("ButtonStylePause");
         cb = goPlay.继续暂停;
         player.Play();
     }
     //通过列表双击播放
     else if (cb == goPlay.双击列表)
     {
         playNum = (int)musicList.SelectedIndex;
         if (playNum == -1) return;
         cb = goPlay.正常播放;
     }
     if (cb == goPlay.正常播放)
     {
         if (p == playMode.单曲循环) player.Play();
         player.Close();
         buttonState = 1;
         playState = 0;
         player.Open(new Uri(music[playNum].musicPath, UriKind.Relative));
         btPlay.Style = (Style)this.FindResource("ButtonStylePause");
         player.Play();
         Lrc.Clear(txtb1,lrc1);
         Lrc.musicName = music[playNum].musicName;
         lrc.LoadLrc(lrc1);
         cb = goPlay.继续暂停;
     }
         musicList.SelectedIndex = playNum;
         musicList.ScrollIntoView(musicList.SelectedItem);
 }