Custom Audio Capture
Of course, using an intent to trigger the sound recorder isn't the only way we can capture audio. The Android SDK includes a MediaRecorder
class, which we can leverage to build our own audio recording functionality. Doing so enables a lot more flexibility, such as controlling the length of time audio is recorded for.
The MediaRecorder
class is used for both audio and video capture. After constructing a MediaRecorder
object, to capture audio, the setAudioEncoder
and setAudioSource
methods must be called. If these methods are not called, audio will not be recorded. (The same goes for video. If setVideoEncoder
and setVideoSource
methods are not called, video will not be recorded. We won't be dealing with video in this chapter; ...
Get Pro Android Media: Developing Graphics, Music, Video, and Rich Media Apps for Smartphones and Tablets now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.