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>
精彩评论