开发者

implementing a recorder in android

I am developing an android application which involves playing, recording, and saving video to the SD card. I'm using the recorder class.

But the when I click the record button, the recording doesn't start.

Here 开发者_StackOverflowis the code I tried:

MediaRecorder recorder = new MediaRecorder();
 recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
 recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
 recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
 recorder.setOutputFile(PATH_NAME);
 recorder.prepare();
 recorder.start();   // Recording is now started
 ...
 recorder.stop();
 recorder.reset();   // You can reuse the object by going back to setAudioSource() step
 recorder.release(); // Now the object cannot be reused


Check this link

Hope it can help you.

Do not forgot to set permission for recording audio

<uses-permission android:name="android.permission.RECORD_AUDIO"></uses-permission>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜