Skip to content

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:

PropertyValue TypeDefaultRequiredDescription
durationnumber60000NoMaximum 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
sampleRatenumber8000NoSample rate (Hz), valid values: 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000
numberOfChannelsnumber2NoNumber of recording channels, valid values: 1 (mono), 2 (stereo). Invalid values are automatically corrected to 2
encodeBitRatenumber48000NoEncoding bit rate (bps), only effective when format is "aac" or "mp3". The valid range depends on sampleRate; see the constraints table below
formatstring"aac"NoEncoding format, valid values: "aac", "mp3", "wav", "PCM"
frameSizenumberNoSpecifies the frame size, in KB. When set, triggers the onFrameRecorded callback; if not set or set to 0, it is not triggered
audioSourcestring"auto"NoAudio 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)
800016000 ~ 48000
1102516000 ~ 48000
1200024000 ~ 64000
1600024000 ~ 96000
2205032000 ~ 128000
2400032000 ~ 128000
3200048000 ~ 192000
4410064000 ~ 320000
4800064000 ~ 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 valueOutput file extensionDescription
"aac".aacAAC encoding, ADTS container
"mp3".mp3MP3 encoding
"wav".wavWAV container + raw PCM data, larger file
"PCM".pcmRaw PCM data, no file header, larger file