private void PlayButton_Click(object sender, EventArgs e)
 {
     if (PlayingMeth == 2)
     {
         PlayAudioDirectory(Files);
     }
     else if (PlayingMeth == 1)
     {
         try
         {
             audio = new AudioFileReader(FilePath);
             fade  = new FadeInOutSampleProvider(audio, true);
             fade.BeginFadeIn(FadeLenght);
             var waveOutDevice = new WaveOutEvent();
             waveOutDevice.Init(fade);
             waveOutDevice.Play();
             IsPlaying   = true;
             timer.Tick += new EventHandler(Timer_Tick);
             timer.Start();
             TimeTrackbar.MaximumValue = Convert.ToInt32(audio.Length / 1000);
             TagControl.GetCover(FilePath, CoverPicture);
             TitleLabel.Text      = TagControl.GetName(FilePath);
             audio.Volume         = 0.5f;
             VolumeTrackbar.Value = 50;
             PlayingMeth          = 1;
         }
         catch { FilePath = null; }
     }
     audio.Position = _position;
 }
 private void PlayAudioDirectory(string[] path)
 {
     if (IsPlaying)
     {
         StopAudio();
     }
     //if (Path.GetExtension(path[FileNum]) == ".mp3" || Path.GetExtension(path[FileNum]) == ".wav")
     try
     {
         audio = new AudioFileReader(path[FileNum]);
         fade  = new FadeInOutSampleProvider(audio, true);
         fade.BeginFadeIn(FadeLenght);
         var waveOutDevice = new WaveOutEvent();
         waveOutDevice.Init(fade);
         waveOutDevice.Play();
         IsPlaying   = true;
         timer.Tick += new EventHandler(Timer_Tick);
         timer.Start();
         TimeTrackbar.MaximumValue = Convert.ToInt32(audio.Length / 1000);
         TagControl.GetCover(path[FileNum], CoverPicture);
         TitleLabel.Text      = TagControl.GetName(path[FileNum]);
         audio.Volume         = 0.5f;
         VolumeTrackbar.Value = 50;
         PlayingMeth          = 2;
         _fadeMade            = false;
         FilePath             = path[FileNum];
     }
     catch
     {
         FileNum++;
         PlayAudioDirectory(Files);
     }
 }
        private void PlaySingleButton_Click(object sender, EventArgs e)
        {
            #region Select file
            // Create an instance of the open file dialog box.
            OpenFileDialog w = new OpenFileDialog
            {
                Filter      = "Your favorite songs (*.mp3)|*.mp3|(*.wav)|*.wav|All files (*.*)|*.*",
                FilterIndex = 1,
                Multiselect = false
            };
            // Call the ShowDialog method to show the dialog box.
            bool?userClickedOK = Convert.ToBoolean(w.ShowDialog());
            if (userClickedOK == true)
            {
                // Open the selected file to read.
                string fileStream = w.FileName;

                FilePath = fileStream;
            }
            #endregion
            #region Play File
            if (IsPlaying)
            {
                StopAudio();
            }
            try
            {
                audio = new AudioFileReader(FilePath);
                fade  = new FadeInOutSampleProvider(audio, true);
                fade.BeginFadeIn(FadeLenght);
                var waveOutDevice = new WaveOutEvent();
                waveOutDevice.Init(fade);
                waveOutDevice.Play();
                IsPlaying   = true;
                timer.Tick += new EventHandler(Timer_Tick);
                timer.Start();
                TimeTrackbar.MaximumValue = Convert.ToInt32(audio.Length / 1000);
                TagControl.GetCover(FilePath, CoverPicture);
                TitleLabel.Text      = TagControl.GetName(FilePath);
                audio.Volume         = 0.5f;
                VolumeTrackbar.Value = 50;
                PlayingMeth          = 1;
                UpdateTags();
            }
            catch { FilePath = null; }
            #endregion
        }
 private void PlayAudio()
 {
     try
     {
         audio = new AudioFileReader(FilePath);
         fade  = new FadeInOutSampleProvider(audio, true);
         fade.BeginFadeIn(FadeLenght);
         var waveOutDevice = new WaveOutEvent();
         waveOutDevice.Init(fade);
         waveOutDevice.Play();
         IsPlaying   = true;
         timer.Tick += new EventHandler(Timer_Tick);
         timer.Start();
         TimeTrackbar.MaximumValue = Convert.ToInt32(audio.Length / 1000);
         TagControl.GetCover(FilePath, CoverPicture);
         TitleLabel.Text      = TagControl.GetName(FilePath);
         audio.Volume         = 0.5f;
         VolumeTrackbar.Value = 50;
         PlayingMeth          = 1;
     }
     catch { FilePath = null; }
 }