sourceFileButton_Click(object sender, System.EventArgs e) { // Show Open File dialog OpenFileDialog openFile = new OpenFileDialog(); openFile.Filter = "MP3 (*.mp3)|*.mp3|WAV (*.wav)|" + "*.wav|All Files (*.*)|*.*"; openFile.FileName = ""; openFile.CheckFileExists = true; openFile.CheckPathExists = true; if (openFile.ShowDialog() != DialogResult.OK) { return; } // Set input file formation try { inputFileFormat = audioConverter.CheckSoundFormat(openFile.FileName); } catch (Exception ex) { ShowExceptionMsg(ex); return; } sourceFileLabel.Text = inputFile = openFile.FileName; }
/* * 选择转换源文件 */ protected void sourceFileButton_Click(object sender, EventArgs e) { // 打开文件选择窗口 OpenFileDialog openFile = new OpenFileDialog(); openFile.Filter = "MP3 (*.mp3)|*.mp3|" + "WAV (*.wav)|*.wav"; openFile.FileName = ""; openFile.CheckFileExists = true; openFile.CheckPathExists = true; if (openFile.ShowDialog() != DialogResult.OK) { return; } // 设置输入文件格式 try { inputFileFormat = audioConverter.CheckSoundFormat(openFile.FileName); } catch (Exception ex) { ShowExceptionMsg(ex); return; } sourceFileLabel.Text = inputFile = openFile.FileName; }
private void ConvertOpcije_Load(object sender, EventArgs e) { Naziv.Text = roditelj.vratiIme(roditelj.aktuelnaPjesma); if (roditelj.formatPjesme == "mp3") { inputFileFormat = Aumpel.soundFormat.MP3; mp3.Enabled = false; wav.Checked = true; outputFileFormat = Aumpel.soundFormat.WAV; } else if (roditelj.formatPjesme == "wav") { inputFileFormat = Aumpel.soundFormat.WAV; wav.Enabled = false; mp3.Checked = true; outputFileFormat = Aumpel.soundFormat.MP3; } else { wav.Enabled = false; mp3.Enabled = false; Konvertuj.Enabled = false; } }
convertButton_Click(object sender, System.EventArgs e) { // Set conversion type switch ((string)comboBox1.SelectedItem) { case "WAV": outputFileFormat = Aumpel.soundFormat.WAV; break; case "MP3": outputFileFormat = Aumpel.soundFormat.MP3; break; case "AU": outputFileFormat = Aumpel.soundFormat.AU; break; case "AIFF": outputFileFormat = Aumpel.soundFormat.AIFF; break; default: MessageBox.Show("You must select a type to convert to.", "Error", MessageBoxButtons.OK); return; } // Convert to MP3 if ((int)outputFileFormat == (int)Aumpel.soundFormat.MP3) { try { Aumpel.Reporter defaultCallback = new Aumpel.Reporter(ReportStatus); audioConverter.Convert(inputFile, (int)inputFileFormat, outputFile, (int)outputFileFormat, defaultCallback); progressBar1.Value = 0; destFileLabel.Text = outputFile = ""; sourceFileLabel.Text = inputFile = ""; MessageBox.Show("Conversion finished.", "Done.", MessageBoxButtons.OK); } catch (Exception ex) { ShowExceptionMsg(ex); return; } } // From MP3 (using named pipe): else if ((int)inputFileFormat == (int)Aumpel.soundFormat.MP3) { try { MadlldlibWrapper.Callback defaultCallback = new MadlldlibWrapper.Callback(ReportStatusMad); // Determine file size FileInfo fi = new FileInfo(inputFile); soundFileSize = (int)fi.Length; audioConverter.Convert(inputFile, outputFile, outputFileFormat, defaultCallback); progressBar1.Value = 0; destFileLabel.Text = outputFile = ""; sourceFileLabel.Text = inputFile = ""; MessageBox.Show("Conversion finished.", "Done.", MessageBoxButtons.OK); } catch (Exception ex) { ShowExceptionMsg(ex); return; } } // Non-MP3 soundfile conversion: else { try { Aumpel.Reporter defaultCallback = new Aumpel.Reporter(ReportStatus); audioConverter.Convert(inputFile, (int)inputFileFormat, outputFile, (int)(outputFileFormat | Aumpel.soundFormat.PCM_16), defaultCallback); progressBar1.Value = 0; destFileLabel.Text = outputFile = ""; sourceFileLabel.Text = inputFile = ""; MessageBox.Show("Conversion finished.", "Done.", MessageBoxButtons.OK); } catch (Exception ex) { ShowExceptionMsg(ex); return; } } }
// Event handlers hence protected void sourceFileButton_Click(object sender, System.EventArgs e) { // Show Open File dialog OpenFileDialog openFile = new OpenFileDialog(); openFile.Filter = "MP3 (*.mp3)|*.mp3|WAV (*.wav)|" + "*.wav|All Files (*.*)|*.*"; openFile.FileName = "" ; openFile.CheckFileExists = true; openFile.CheckPathExists = true; if ( openFile.ShowDialog() != DialogResult.OK ) return; // Set input file formation try { inputFileFormat = audioConverter.CheckSoundFormat(openFile.FileName); } catch(Exception ex) { ShowExceptionMsg(ex); return; } sourceFileLabel.Text = inputFile = openFile.FileName; }
protected void convertButton_Click(object sender, System.EventArgs e) { // Set conversion type switch((string)comboBox1.SelectedItem) { case "WAV": outputFileFormat = Aumpel.soundFormat.WAV; break; case "MP3": outputFileFormat = Aumpel.soundFormat.MP3; break; case "AU": outputFileFormat = Aumpel.soundFormat.AU; break; case "AIFF": outputFileFormat = Aumpel.soundFormat.AIFF; break; default: MessageBox.Show("You must select a type to convert to.", "Error", MessageBoxButtons.OK); return; } // Convert to MP3 if ( (int)outputFileFormat == (int)Aumpel.soundFormat.MP3 ) { try { Aumpel.Reporter defaultCallback = new Aumpel.Reporter(ReportStatus); audioConverter.Convert(inputFile, (int)inputFileFormat, outputFile, (int)outputFileFormat, defaultCallback); progressBar1.Value = 0; destFileLabel.Text = outputFile = ""; sourceFileLabel.Text = inputFile = ""; MessageBox.Show("Conversion finished.", "Done.", MessageBoxButtons.OK); } catch (Exception ex) { ShowExceptionMsg(ex); return; } } // From MP3 (using named pipe): else if ( (int)inputFileFormat == (int)Aumpel.soundFormat.MP3 ) { try { MadlldlibWrapper.Callback defaultCallback = new MadlldlibWrapper.Callback(ReportStatusMad); // Determine file size FileInfo fi = new FileInfo(inputFile); soundFileSize = (int)fi.Length; audioConverter.Convert(inputFile, outputFile, outputFileFormat, defaultCallback); progressBar1.Value = 0; destFileLabel.Text = outputFile = ""; sourceFileLabel.Text = inputFile = ""; MessageBox.Show("Conversion finished.", "Done.", MessageBoxButtons.OK); } catch (Exception ex) { ShowExceptionMsg(ex); return; } } // Non-MP3 soundfile conversion: else { try { Aumpel.Reporter defaultCallback = new Aumpel.Reporter(ReportStatus); audioConverter.Convert(inputFile, (int)inputFileFormat, outputFile, (int)(outputFileFormat | Aumpel.soundFormat.PCM_16), defaultCallback); progressBar1.Value = 0; destFileLabel.Text = outputFile = ""; sourceFileLabel.Text = inputFile = ""; MessageBox.Show("Conversion finished.", "Done.", MessageBoxButtons.OK); } catch (Exception ex) { ShowExceptionMsg(ex); return; } } }
private void convertButton_Click(object sender, EventArgs e) { // 设置转换格式 switch (formatBox.SelectedItem.ToString()) { case "WAV": outputFileFormat = Aumpel.soundFormat.WAV; break; case "MP3": outputFileFormat = Aumpel.soundFormat.MP3; break; case "AU": outputFileFormat = Aumpel.soundFormat.AU; break; case "AIFF": outputFileFormat = Aumpel.soundFormat.AIFF; break; default: MessageBox.Show("You must select a valid type to convert to.", "Error", MessageBoxButtons.OK); return; } // 转换为MP3(Aumpel库) if ((int)outputFileFormat == (int)Aumpel.soundFormat.MP3) { try { Aumpel.Reporter defaultCallback = new Aumpel.Reporter(ReportStatus); audioConverter.Convert(inputFile, (int)inputFileFormat, outputFile, (int)outputFileFormat, defaultCallback); convertProgressBar.Value = 0; destFileLabel.Text = outputFile = ""; sourceFileLabel.Text = inputFile = ""; MessageBox.Show("Conversion finished.", "Done", MessageBoxButtons.OK); } catch (Exception ex) { ShowExceptionMsg(ex); return; } } // MP3转换为其他(Madlldlib库) else if ((int)inputFileFormat == (int)Aumpel.soundFormat.MP3) { try { MadlldlibWrapper.Callback defaultCallback = new MadlldlibWrapper.Callback(ReportStatusMad); // 确定文件大小 FileInfo f = new FileInfo(inputFile); soundFileSize = (int)f.Length; audioConverter.Convert(inputFile, outputFile, outputFileFormat, defaultCallback); convertProgressBar.Value = 0; destFileLabel.Text = outputFile = ""; sourceFileLabel.Text = inputFile = ""; MessageBox.Show("Conversion finifshed.", "Done.", MessageBoxButtons.OK); } catch (Exception ex) { ShowExceptionMsg(ex); return; } } // 源文件非MP3的转换 else { try { Aumpel.Reporter defaultCallback = new Aumpel.Reporter(ReportStatus); audioConverter.Convert(inputFile, (int)inputFileFormat, outputFile, (int)(outputFileFormat | Aumpel.soundFormat.PCM_16), defaultCallback); convertProgressBar.Value = 0; destFileLabel.Text = outputFile = ""; sourceFileLabel.Text = inputFile = ""; MessageBox.Show("Conversion finished.", "Done.", MessageBoxButtons.OK); } catch (Exception ex) { ShowExceptionMsg(ex); return; } } }