我试图在我的应用程序中录制声音,然后将其存储在res文件夹中。我还做了更少如下:如何将记录文件存储在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" />
但之后,我跑模拟器没有原始内创建的文件,能有人帮助?
非常感谢! –
欢迎您! –
大声笑...这正是我想说的。我想你不明白哈哈。好吧。 –