我试图在我的应用程序中录制声音,然后将其存储在 res 文件夹中。我做的更少:
private MediaRecorder recorder;
static final String OUTPUT_FILE = "/MediaPlayer/res/raw/recordoutput.3gpp"; //MediaPlayer is the java class and raw is the folder that I would like to put my recorded voice in
private void beginRecording() throws Exception{
killMediaRecorder(); //I implemented this function to kill the existing recorder
File outFile = new File(OUTPUT_FILE);
if(outFile.exists())
{
outFile.delete();
}
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(OUTPUT_FILE);
recorder.prepare();
recorder.start();
}
显现:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
但是在我运行模拟器后,原始文件中没有创建文件,有人可以帮忙吗?