Example #1
0
        private void WaveIn_RecordingStopped(object sender, StoppedEventArgs e)
        {
            if (_writer != null)
            {
                _writer.Flush();
                _writer.Dispose();
                _waveIn.Dispose();
            }

            if (CountSeconds >= _userSettings.MinimumRecordedLengthSeconds)
            {
                if (!_userSettings.MediaFormat.Equals(MediaFormat.Mp3))
                {
                    return;
                }

                var mp3TagsInfo = new MediaTags.MP3Tags()
                {
                    Track = _track,
                    OrderNumberInMediaTagEnabled = _userSettings.OrderNumberInMediaTagEnabled,
                    Count       = _userSettings.OrderNumber,
                    CurrentFile = _currentFile
                };

                Task.Run(mp3TagsInfo.SaveMediaTags);

                return;
            }

            _form.WriteIntoConsole(string.Format(FrmEspionSpotify.Rm.GetString($"logDeletingTooShort") ?? $"{0}{1}", _fileManager.BuildFileName(_userSettings.OutputPath, false), _userSettings.MinimumRecordedLengthSeconds));

            _fileManager.DeleteFile(_currentFile);
        }
Example #2
0
        private async Task UpdateOutputFileBasedOnMediaFormat()
        {
            switch (_userSettings.MediaFormat)
            {
            case MediaFormat.Mp3:
                var mp3TagsInfo = new MediaTags.MP3Tags()
                {
                    Track = _track,
                    OrderNumberInMediaTagEnabled = _userSettings.OrderNumberInMediaTagEnabled,
                    Count       = _userSettings.OrderNumber,
                    CurrentFile = _currentOutputFile.ToString()
                };
                await mp3TagsInfo.SaveMediaTags();

                return;

            default:
                return;
            }
        }
Example #3
0
        private async Task UpdateOutputFileBasedOnMediaFormat()
        {
            switch (_userSettings.MediaFormat)
            {
            case MediaFormat.Wav:
                _fileManager.Rename(_currentOutputFile.ToPendingFileString(), _currentOutputFile.ToString());
                return;

            case MediaFormat.Mp3:
                using (var reader = new WaveFileReader(_currentOutputFile.ToPendingFileString()))
                {
                    using (var mp3writer = new LameMP3FileWriter(_currentOutputFile.ToTranscodingToMP3String(), _waveIn.WaveFormat, _userSettings.Bitrate))
                    {
                        await reader.CopyToAsync(mp3writer);

                        if (mp3writer != null)
                        {
                            await mp3writer.FlushAsync();
                        }
                    }
                }

                _fileManager.DeleteFile(_currentOutputFile.ToPendingFileString());
                _fileManager.Rename(_currentOutputFile.ToTranscodingToMP3String(), _currentOutputFile.ToString());

                var mp3TagsInfo = new MediaTags.MP3Tags()
                {
                    Track = _track,
                    OrderNumberInMediaTagEnabled = _userSettings.OrderNumberInMediaTagEnabled,
                    Count       = _userSettings.OrderNumber,
                    CurrentFile = _currentOutputFile.ToString()
                };
                await mp3TagsInfo.SaveMediaTags();

                return;

            default:
                return;
            }
        }
Example #4
0
        private void WaveIn_RecordingStopped(object sender, StoppedEventArgs e)
        {
            if (_writer != null)
            {
                _writer.Flush();
                _writer.Dispose();
                _waveIn.Dispose();
            }

            if (CountSeconds < _userSettings.MinimumRecordedLengthSeconds)
            {
                _form.WriteIntoConsole(string.Format(FrmEspionSpotify.Rm.GetString($"logDeleting") ?? $"{0}{1}", _fileManager.GetFileName(_currentFile), _userSettings.MinimumRecordedLengthSeconds));
                _fileManager.DeleteFile(_currentFilePending);
                return;
            }

            var timeSpan = new TimeSpan(TICKS_PER_SECOND * CountSeconds);
            var length   = string.Format("{0}:{1:00}", (int)timeSpan.TotalMinutes, timeSpan.Seconds);

            _form.WriteIntoConsole(string.Format(FrmEspionSpotify.Rm.GetString($"logRecorded") ?? $"{0}{1}", _track.ToString(), length));

            _fileManager.Rename(_currentFilePending, _currentFile);

            if (!_userSettings.MediaFormat.Equals(MediaFormat.Mp3))
            {
                return;
            }

            var mp3TagsInfo = new MediaTags.MP3Tags()
            {
                Track = _track,
                OrderNumberInMediaTagEnabled = _userSettings.OrderNumberInMediaTagEnabled,
                Count       = _userSettings.OrderNumber,
                CurrentFile = _currentFile
            };

            Task.Run(mp3TagsInfo.SaveMediaTags);
        }