Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to record sound by using inbuilt microphone in android

I need to record sound by using mobile's own microphone... How to do it?

like image 546
coderslay Avatar asked Dec 10 '22 08:12

coderslay


1 Answers

It's explained here

Audio capture from the device is a bit more complicated than audio/video playback, but still fairly simple:

  1. Create a new instance of android.media.MediaRecorder using new
  2. Set the audio source using MediaRecorder.setAudioSource(). You will probably want to use MediaRecorder.AudioSource.MIC
  3. Set output file format using MediaRecorder.setOutputFormat()
  4. Set output file name using MediaRecorder.setOutputFile()
  5. Set the audio encoder using MediaRecorder.setAudioEncoder()
  6. Call MediaRecorder.prepare() on the MediaRecorder instance.
  7. To start audio capture, call MediaRecorder.start().
  8. To stop audio capture, call MediaRecorder.stop().
  9. When you are done with the MediaRecorder instance, call MediaRecorder.release() on it. Calling MediaRecorder.release() is always recommended to free the resource immediately.
like image 88
rochdev Avatar answered Dec 28 '22 08:12

rochdev