private void ConvertAndSave(SpotifyWav spotifyWav)
 {
     if (spotifyWav != null && (spotifyWav.Duration > TimeSpan.FromSeconds(30) || !_skipCommertials))
     {
         TrackRecorded?.Invoke(this, new SpotifyTrackRecorded(spotifyWav));
         Mp3Converter.ConvertToMp3(spotifyWav.WavFile.FullName, _bitrate, Mp3Tag.Parse(spotifyWav.Song));
     }
     else
     {
         try
         {
             spotifyWav?.WavFile.Delete( );
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
         }
     }
 }
예제 #2
0
        public SpotifyWav Stop( )
        {
            if (_waveIn == null || _writer == null)
            {
                return(null);
            }

            _stopwatch.Stop();
            _waveIn.StopRecording();
            _waveIn.DataAvailable -= OnDataAvailable;

            var result = new SpotifyWav(_stopwatch.Elapsed, new FileInfo(_writer.Filename), _currentSong);

            _waveIn.Dispose();
            _writer.Close();
            _writer.Dispose();

            _currentSong = null;
            _waveIn      = null;
            _writer      = null;

            return(result);
        }
 public SpotifyTrackRecorded(SpotifyWav spotifyWav)
 {
     Song = spotifyWav?.Song;
     File = spotifyWav;
 }