在我的应用程序中我有音频部分,我有一个 recordBtn ,它将录制音频和一个 playRecordedAudioBtn ,它将播放刚录制的音频,我还有一个 playTrackBtn 将播放曲目(音乐音频)。
当我点击 recordBtn 和 playTrackBtn 时,录制的音频必须包含我录制的内容并跟踪歌曲但是它没有录制我想要的内容并在logcat中发出消息< / p>
11-16 04:40:24.060:WARN / AudioFlinger(90):RecordThread:缓冲区溢出
我录制的音频代码如下:
new Thread(recordingThread).start(); // called thread from onCreate
private Runnable recordingThread = new Runnable() {
@Override
public void run() {
try {
startRecording();
} catch (Exception e) {
Log.d("error:", "" + e.getMessage());
}
}
};
public void startRecording() throws IOException {
String state = android.os.Environment.getExternalStorageState();
if (!state.equals(android.os.Environment.MEDIA_MOUNTED)) {
Toast.makeText(MainActivity.this,
"SD Card is not mounted. It is " + state + ".",
Toast.LENGTH_SHORT).show();
} else {
String dirPath = Environment.getExternalStorageDirectory()
.getAbsolutePath();
songTakePath = dirPath + "/SongWriters_Pad/"
+ title_view.getText().toString() + "-Take-" + count
+ ".wav";
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setAudioEncodingBitRate(16);
recorder.setAudioSamplingRate(44100);
recorder.setOutputFile(songTakePath);
try {
recorder.prepare();
} catch (Exception e) {
e.printStackTrace();
}
recorder.start();
}}
请提供任何指导和一些代码段。 感谢..