//konvertovanje private void Konvertovanje() { if ((int)outputFileFormat == (int)Aumpel.soundFormat.MP3) { try { Aumpel.Reporter defaultCallback = new Aumpel.Reporter(ReportStatus); FileInfo fi = new FileInfo(roditelj.aktuelnaPjesma); soundFileSize = (int)fi.Length; SaveFileDialog saveFile = new SaveFileDialog(); saveFile.Filter = "MP3 (*.mp3)|*.mp3"; if (saveFile.ShowDialog() == DialogResult.OK) { audioConverter.Convert(roditelj.aktuelnaPjesma, (int)inputFileFormat, saveFile.FileName, (int)outputFileFormat, defaultCallback); SetControlPropertyValue(progressBar1, "value", 0); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); return; } } else if ((int)inputFileFormat == (int)Aumpel.soundFormat.MP3) { try { MadlldlibWrapper.Callback defaultCallback = new MadlldlibWrapper.Callback(ReportStatusMad); FileInfo fi = new FileInfo(roditelj.aktuelnaPjesma); soundFileSize = (int)fi.Length; SaveFileDialog saveFile = new SaveFileDialog(); saveFile.Filter = "WAV (*.wav)|*.wav"; if (saveFile.ShowDialog() == DialogResult.OK) { audioConverter.Convert(roditelj.aktuelnaPjesma, saveFile.FileName, outputFileFormat, defaultCallback); SetControlPropertyValue(progressBar1, "value", 0); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); return; } } }
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; } } }
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; } } }