Overview
AMRAudioRecorder’s main feature is the ability to pause and resume audio recording. Android’s native MediaRecorder doesn’t support this functionality, so AMRAudioRecorder implements it by recording multiple segments and merging them intelligently.The library was specifically created to solve this limitation: “Android does not support pause and resume when recording AMR audio, so we implement it to provide pause and resume function.”
How it works
When you pause and resume recording, AMRAudioRecorder:- Creates separate files: Each recording segment is saved as a separate AMR file
- Merges on stop: When you call
stop(), the library merges all segments into a single file - Skips headers: AMR files have a 6-byte header that must only appear once in the final file
Pause recording
To pause an active recording:- The current MediaRecorder is stopped and released
- The current segment is saved
isRecording()returnsfalse
Resume recording
To resume a paused recording:- A new MediaRecorder instance is created
- A new segment file is started
isRecording()returnstrue- The
singleFileflag is set tofalse, indicating merge will be needed
Complete pause/resume example
This example from the sample app shows a toggle button for pause/resume:Multiple pause/resume cycles
You can pause and resume as many times as needed:stop(), all segments are automatically merged into a single AMR file.
File merging behavior
Single segment
If you never pause (call
start() then stop() directly), no merging occurs. The library returns the original file path.Performance considerations
The merge operation:- Uses a 512-byte buffer for efficient file I/O
- Runs synchronously when you call
stop() - Deletes intermediate segment files automatically
- May take longer with many pause/resume cycles
Consider the number of pause/resume cycles for very long recordings, as each cycle creates a new file that must be merged.