RecorderManager.start
JS
RecorderManager.start(Object options)Starts recording
Asynchronous operation; the onStart callback fires after recording successfully starts.
Parameters
- Object options: recording configuration parameters; see the table below for details
options Properties:
| Property | Value Type | Default | Required | Description |
|---|---|---|---|---|
| duration | number | 60000 | No | Maximum recording duration, in ms. Maximum value 600000 (10 minutes); values above the limit are automatically clamped. Recording stops automatically and triggers onStop when duration is reached |
| sampleRate | number | 8000 | No | Sample rate (Hz), valid values: 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 |
| numberOfChannels | number | 2 | No | Number of recording channels, valid values: 1 (mono), 2 (stereo). Invalid values are automatically corrected to 2 |
| encodeBitRate | number | 48000 | No | Encoding bit rate (bps), only effective when format is "aac" or "mp3". The valid range depends on sampleRate; see the constraints table below |
| format | string | "aac" | No | Encoding format, valid values: "aac", "mp3", "wav", "PCM" |
| frameSize | number | No | Specifies the frame size, in KB. When set, triggers the onFrameRecorded callback; if not set or set to 0, it is not triggered | |
| audioSource | string | "auto" | No | Audio input source, valid values: "auto", "buildInMic", "headsetMic", "mic", "camcorder", "voiceCommunication", "voiceRecognition". Invalid values are automatically corrected to "auto" |
sampleRate and encodeBitRate Constraints:
| sampleRate (Hz) | encodeBitRate valid range (bps) |
|---|---|
| 8000 | 16000 ~ 48000 |
| 11025 | 16000 ~ 48000 |
| 12000 | 24000 ~ 64000 |
| 16000 | 24000 ~ 96000 |
| 22050 | 32000 ~ 128000 |
| 24000 | 32000 ~ 128000 |
| 32000 | 48000 ~ 192000 |
| 44100 | 64000 ~ 320000 |
| 48000 | 64000 ~ 320000 |
When sampleRate is not in the valid values list, or encodeBitRate is outside the valid range for the corresponding sample rate, start will fail and trigger onError. When format is "wav" or "PCM", the encodeBitRate parameter is meaningless (the bit rate is determined directly by sample rate, channel count, and bit depth); in this case the parameter is ignored and not validated.
format Description:
| format value | Output file extension | Description |
|---|---|---|
| "aac" | .aac | AAC encoding, ADTS container |
| "mp3" | .mp3 | MP3 encoding |
| "wav" | .wav | WAV container + raw PCM data, larger file |
| "PCM" | .pcm | Raw PCM data, no file header, larger file |
