private void PlayNext(PlayerActions action)
 {
     if (action == PlayerActions.RandomPlay)
     {
         int randomIndex = rnd.Next(0, Client.FileList.Length);
         while (randomIndex == selectedMusicIndex)
         {
             randomIndex = rnd.Next(0, Client.FileList.Length);
         }
         selectedMusicIndex = randomIndex;
     }
     else if (action == PlayerActions.RePlay)
     {
         BassCore.Play(Client.FileList[selectedMusicIndex], volume_bar.Value);
         return;
     }
     else
     {
         if (Client.FileList.Length > (selectedMusicIndex + 1))
         {
             selectedMusicIndex += 1;
         }
         else if (Client.FileList.Length == 1)
         {
             BassCore.Play(Client.FileList[selectedMusicIndex], volume_bar.Value);
         }
         else if (selectedMusicIndex == (Client.FileList.Length - 1))
         {
             selectedMusicIndex = 0;
         }
     }
     BassCore.Play(Client.FileList[selectedMusicIndex], volume_bar.Value);
     prevSelectedMusicIndex = selectedMusicIndex;
     PlayerSet();
 }
Exemple #2
0
 /// <summary>
 /// Start playback
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnPlay_Click(object sender, RoutedEventArgs e)
 {
     if ((lstPlaylist.Items.Count != 0) && (lstPlaylist.SelectedIndex != -1))
     {
         DataVars.CurrentTrack     = lstPlaylist.SelectedIndex;
         dispatcherTimer.IsEnabled = true;
         BassInstance.SetStreamVolume(BassInstance.Stream, (int)sldVolume.Value);
         BassInstance.Play(MMList[lstPlaylist.SelectedIndex].File, BassInstance.Volume); //Using bass library to play with initial volume val
         lblStream.Content = TimeSpan.FromSeconds(BassInstance.GetStreamPos(BassInstance.Stream)).ToString();
         sldStream.Maximum = BassInstance.GetStreamTime(BassInstance.Stream);
         sldStream.Value   = BassInstance.GetStreamPos(BassInstance.Stream);
         UpdateEqParams(sender, null);
     }
 }
        private void Play(object sender)
        {
            if (!playing)
            {
                if (selectedMusicIndex == -1)
                {
                    music_Track_Bar.Enabled = false;
                    volume_bar.Enabled      = false;
                    volume_btn.Enabled      = false;
                    return;
                }

                ((Button)sender).Image = Properties.Resources.pause_white;
                if (Client == null)
                {
                    Client = new VKManager();
                }
                if (newPlaying)
                {
                    BassCore.Play(Client.FileList[selectedMusicIndex], BassCore.Volume);
                }
                else
                {
                    BassCore.Continue(BassCore.Stream);
                }
                PlayerSet();
            }
            else
            {
                ((Button)sender).Image = Properties.Resources.play_white;
                if (selectedMusicIndex == prevSelectedMusicIndex)
                {
                    BassCore.Pause();
                    PlayerDefaultSet(false);
                }
                else if (selectedMusicIndex != prevSelectedMusicIndex)
                {
                    BassCore.Stop();
                    PlayerDefaultSet(true);
                }
            }
            ((Button)sender).Refresh();
            prevSelectedMusicIndex = selectedMusicIndex;
        }