private void StopRecording() { string filePath = string.Empty; string song = string.Empty; Mp3Tag songTag = Mp3Tag.EmptyTag(); int duration = 0; if (soundCardRecorder != null) { addToLog("Recording stopped"); soundCardRecorder.Stop(); filePath = soundCardRecorder.FilePath; song = soundCardRecorder.SongTag.ToString(); songTag = soundCardRecorder.SongTag; duration = soundCardRecorder.Duration; addToLog("Duration: " + duration + " (Limit: " + thresholdTextBox.Value + ")"); soundCardRecorder.Dispose(); soundCardRecorder = null; if (duration < (int)thresholdTextBox.Value && thresholdCheckBox.Checked) { File.Delete(filePath); addToLog("Recording too short; deleting file..."); } else { if (!string.IsNullOrEmpty(filePath)) { addToLog("Recorded file: " + filePath); encodingLabel.Text = song; PostProcessing(filePath, songTag); } } } }
private void OnLoad(object sender, EventArgs eventArgs) { // Load the main browser mainBrowser = new ChromiumWebBrowser("https://www.deezer.com/") { BrowserSettings = new BrowserSettings() { Plugins = CefState.Enabled } }; this.splitContainer1.Panel2.Controls.Add(mainBrowser); // Load the timer only when loading is finished mainBrowser.LoadingStateChanged += OnLoadingStateChanged; //load the available devices LoadWasapiDevicesCombo(); //load the different bitrates LoadBitrateCombo(); //Load user settings LoadUserSettings(); //set the change event if filePath is songLabel.Text = string.Empty; encodingLabel.Text = string.Empty; folderDialog = new FolderBrowserDialog { SelectedPath = outputFolderTextBox.Text }; versionLabel.Text = string.Format("Version {0}", Application.ProductVersion); ChangeApplicationState(_currentApplicationState); // instantiate the sound recorder once in an attempt to reduce lag the first time used try { soundCardRecorder = new SoundCardRecorder((MMDevice)deviceListBox.SelectedItem, CreateOutputFile("deleteme", "wav"), Mp3Tag.EmptyTag()); soundCardRecorder.Dispose(); soundCardRecorder = null; if (File.Exists(CreateOutputFile("deleteme", "wav"))) { File.Delete(CreateOutputFile("deleteme", "wav")); } } catch (Exception ex) { addToLog("Error: " + ex.Message); } }