我尝试构建一个有录音功能的应用程序。我希望用户能够选择录音质量,其中一个选项是 AAC 录音。我正在使用下面的代码,但我在设置 audioSamplingRate 时不断出错。有什么想法吗?
mediaRecorder = new MediaRecorder();
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediaRecorder.setAudioSamplingRate(96000);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
和错误
04-29 10:32:17.477: E/MediaRecorder(18750): setParameters(audio-param-sampling-rate=96000) failed: -22
04-29 10:32:17.477: E/com.test.com.AudioRecorder(18750): setParameter failed.
04-29 10:32:17.477: E/com.test.com.AudioRecorder(18750): prepare() method called on illegal state