Audio Capture

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. Create a new instance of android.content.ContentValues and put in some standard properties like title, timestamp, and the all important mime_type

3. Create a file path for the data to go to (you can use android.content.ContentResolver to create an entry in the Content database and get it to assign a path automatically which you can then use)

4. Set the audio source using MediaRecorder.setAudioSourceO. You will probably want to use

MediaRecorder.AudioSource.MIC

5. Set output file format using MediaRecorder.setOutputFormatO

6. Set the audio encoder using MediaRecorder.setAudioEncoderO

7. Call prepared on the MediaRecorder instance.

8. To start audio capture, call startO.

9. To stop audio capture, call stop).

10. When you are done with the MediaRecorder instance, call released on it.

0 0

Post a comment