Пример #1
0
 private void btnplay_Click(object sender, EventArgs e)
 {
     if (o == null)
     {
         if (lbtracks.Items.Count > 0)
         {
             Play(lbtracks.Items[0].ToString());
             btnplay.Text = "Pause";
         }
         else
         {
             Infobox.Show("Error", "No tracks to play! Please add a track to the playlist.");
         }
     }
     else if (o.PlaybackState == NAudio.Wave.PlaybackState.Paused)
     {
         o.Resume();
         btnplay.Text = "Pause";
     }
     else if (o.PlaybackState == NAudio.Wave.PlaybackState.Playing)
     {
         o.Pause();
         btnplay.Text = "Play";
     }
 }
Пример #2
0
 void PlaySongFunc()
 {
     if (!IsPlaying)
     {
         Play      = "Pause";
         IsPlaying = !IsPlaying;
         if (songList != null && songList.Length != 0)
         {
             if (!IsPlayed)
             {
                 string[] temp = songList[PlayingIndex].Name.Split('-');
                 SingerName       = temp[0];
                 SongName         = temp[1];
                 mp3FileReader    = new NAudio.Wave.Mp3FileReader(songList[PlayingIndex].FullName);
                 PlayingTotalTime = mp3FileReader.TotalTime.ToString().Substring(0, 8);
                 wo.Init(mp3FileReader);
                 getCurrrentTime_th.Start();
                 wo.Play();
                 IsPlayed = true;
             }
             else
             {
                 wo.Resume();
                 if (getCurrrentTime_th != null && (getCurrrentTime_th.ThreadState & ThreadState.Suspended) == ThreadState.Suspended)
                 {
                     getCurrrentTime_th.Resume();
                 }
             }
         }
     }
     else
     {
         Play      = "Play";
         IsPlaying = !IsPlaying;
         if (getCurrrentTime_th != null && (getCurrrentTime_th.ThreadState & ThreadState.Running) == ThreadState.Running)
         {
             getCurrrentTime_th.Suspend();
         }
         wo.Pause();
     }
 }