嗨,我正在制作一个Android应用程序录制音频5-10秒,并存储在数据库中。对于音频记录,我遵循以下http://xhampa.pastebin.com/Yr2hie6q
但它不能正常工作。该怎么办呢?我无法在我的G1手机上录制音频。欢迎任何建议。
发布于 2012-01-23 23:48:37
对于您的音频录制,请尝试以下代码:
MediaRecorder recorder;
public void startRecording() throws IOException
{
SimpleDateFormat timeStampFormat = new SimpleDateFormat(
"yyyy-MM-dd-HH.mm.ss");
String fileName = "audio_" + timeStampFormat.format(new Date())
+ ".mp4";
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile("/sdcard/"+fileName);
recorder.prepare();
recorder.start();
}
protected void stopRecording() {
recorder.stop();
recorder.release();
}你可以在你的SD卡上找到你的文件。
https://stackoverflow.com/questions/4430794
复制相似问题