Ejemplo n.º 1
0
 /// <summary>
 /// Plays previous song in the playlist.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Previous_Click(object sender, EventArgs e)
 {
     try
     {
         if (!_shuffle)
         {
             int _tmpIndex = _currentSongPLaylistIndex;
             if (_currentSongPLaylistIndex <= 0 && _repeatFolder)
             {
                 _currentSongPLaylistIndex = PlayList.Items.Count;
             }
             PlayList.SetSelected(_tmpIndex, false);
             PlayList.SetSelected(--_currentSongPLaylistIndex, true);
         }
         else
         {
             Shuffling();
         }
         this.Play_Click(sender, e);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Retrieves the folder.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FolderSongs_Click(object sender, EventArgs e)
        {
            PlayList.Items.Clear();
            string path = string.Empty;

            if (FolderSong.ShowDialog() == DialogResult.OK)
            {
                path = FolderSong.SelectedPath;
            }

            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            _mp3PlayList.PathFolder = path;
            IList <string> list = _mp3PlayList.Read;

            for (int i = 0; i < list.Count; i++)
            {
                PlayList.Items.Add(list[i]);
            }

            try
            {
                PlayList.SetSelected(_currentSongPLaylistIndex, true);
                this.Play_Click(sender, e);
            }
            catch (ArgumentOutOfRangeException)
            {
                MessageBox.Show("You don't have any songs in this folder.", "Files hasn't been found.",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This method shuffles songs then sets to playlist.
        /// </summary>
        private void Shuffling()
        {
            PlayList.SetSelected(_currentSongPLaylistIndex, false);

            int _playListLength = PlayList.Items.Count;

            Random _rand = new Random();

            _currentSongPLaylistIndex = _rand.Next(_playListLength);

            //It rerolls if an song is the same as the last song.
            while (_lastSong == _currentSongPLaylistIndex)
            {
                _currentSongPLaylistIndex = _rand.Next(_playListLength);
            }

            PlayList.SetSelected(_currentSongPLaylistIndex, true);
        }