Android - Mediarecorder输出格式为base64

时间:2012-09-25 14:48:47

标签: android mediarecorder

我正在开发android中的录音机应用程序。我的目标是录制音频并将其发送到我的webservice方法。记录音频的代码片段如下所示。

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.

0 个答案:

没有答案