您好 我正在制作一个Android应用程序,用于录制音频5-10秒并将其存储在数据库中。 对于录音,请按照http://xhampa.pastebin.com/Yr2hie6q
进行操作但它无法正常工作。该怎么办 ? 我无法在G1手机上录制音频。 任何建议都欢迎。
答案 0 :(得分:1)
对于录音,请尝试以下代码:
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卡上找到您的文件。