目前我正在使用MediaRecorder API進行錄音。以下是所使用的代碼片斷:連續媒體錄製分成不同大小的文件
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setOutputFile(filepath);
mRecorder.setMaxFileSize(5000);
try {
mRecorder.prepare();
mRecorder.start();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
使用上述代碼,我已經測試,它能夠記錄的音頻文件,其值爲5KB的尺寸,並隨後在記錄停止。
我想要做的是有連續記錄,直到我把下面的代碼將被保存爲文件爲5Kb:
mRecorder.stop();
mRecorder.reset();
mRecorder.release();
這可能嗎?目前,一旦達到5Kb,錄音就完全停止。
在此先感謝。
雅...這是可能的 –
任何想法如何?我嘗試使用MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED,但無法使其工作。 – aandroidtest
爲什麼你把最大文件大小?你只想得到5 kb的文件 –