【问题标题】:Recording sounds on android using MediaRecorder使用 MediaRecorder 在 android 上录制声音
【发布时间】:2012-04-01 17:19:31
【问题描述】:

我正在开发一个使用 AudioRecorder 类录制声音的 Android 应用程序 以下来自我的代码:

  public void start() throws IOException {
    String state = android.os.Environment.getExternalStorageState();
    if(!state.equals(android.os.Environment.MEDIA_MOUNTED))  {
        throw new IOException("SD Card is not mounted.  It is " + state + ".");
    }

    // make sure the directory we plan to store the recording in exists
    File directory = new File(path).getParentFile();
    if (!directory.exists() && !directory.mkdirs()) {
      throw new IOException("Path to file could not be created.");
    }
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
System.out.println("mashi");
recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setAudioEncodingBitRate(16);
recorder.setAudioSamplingRate(44100);
try {
    recorder.setOutputFile(path);
    System.out.println("ooutput");
} catch (IllegalStateException e) {
    e.printStackTrace();
}
recorder.prepare();
recorder.start();

}

录制的声音很慢很厚!! 有什么问题?

【问题讨论】:

    标签: android audio recorder


    【解决方案1】:

    将 recorder.setAudioSamplingRate(44100) 更改为 recorder.setAudioSamplingRate(8000);因为在模拟器中它需要 8000 采样率 不超过这个..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多