我正在android中开发录音机应用程序。我的目标是录制音频并将其发送到我的网络服务方法。录制音频的代码片段如下。
private MediaRecorder mRecorder = null;
private static String mFileName = Environment.getExternalStorageDirectory().getAbsolutePath() + "/audiorecordtest.3gp";
private void startRecording() {
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
mRecorder.prepare();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
mRecorder.start();
}
private void stopRecording() {
mRecorder.stop();
mRecorder.release();
mRecorder = null;
}
在上面的代码中,输出文件存储在“mFileName”路径中。现在我得到输出并将其存储到指定的“ExternalStorageDirectory”路径中。但我不想将输出文件存储到“ExternalStorageDirectory”中。我想将输出转换为 base64 字符串。谁能帮我做到这一点?
Objective:
1) I don't want to store the output in local.
2) Convert the output into base64 string.