如何录制的音频在Android和它保存在数据库? [英] How to record a audio in Android and save it in Database?
本文介绍了如何录制的音频在Android和它保存在数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
喜
我想提出一个Android应用程序,用于记录音频5-10秒,并存储在数据库中。
对于录音我按照此 http://xhampa.pastebin.com/Yr2hie6q
但它不能正常工作。该怎么办 ?
我无法记录在我的G1手机的音频。
任何建议欢迎。
But it is not working properly. What to do ? I can not record the Audio on my G1 mobile. Any suggestion welcome.
推荐答案
有关您的录音,试试这个code:
For your audio recording, try this code:
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卡找到你的文件。
You can find your file on your sdcard.
有关您进一步的问题,填写免费张贴。
For your further question, fill free to post them.
这篇关于如何录制的音频在Android和它保存在数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文