Skip to main content
Version: Next

RecorderManager

The globally unique recording manager.

Reference

Methods

onError

Listens on the recording error event.

Reference

(callback: OnErrorCallback) => void
PropertyTypeDescription
callbackOnErrorCallbackThe callback function for the recording error event.

API Support

APIWeChat Mini-ProgramH5React Native
RecorderManager.onError✔️✔️

onFrameRecorded

Listens on the event that the file with specified frame size has been recorded. This event is called back if frameSize is set.

Reference

(callback: OnFrameRecordedCallback) => void
PropertyTypeDescription
callbackOnFrameRecordedCallbackThe callback function for the event that the file with specified frame size has been recorded

API Support

APIWeChat Mini-ProgramH5React Native
RecorderManager.onFrameRecorded✔️

onInterruptionBegin

Listens on the event that recording interruption starts due to system occupation. This event is triggered by the following scenarios: WeChat voice chat and WeChat video chat. After this event is triggered, the recording is paused. The pause event is triggered after this event.

Reference

(callback: (res: CallbackResult) => void) => void
PropertyTypeDescription
callback(res: CallbackResult) => voidThe callback function for the event that recording interruption starts due to system occupation.

API Support

APIWeChat Mini-ProgramH5React Native
RecorderManager.onInterruptionBegin✔️

onInterruptionEnd

Listens on the event that recording interruption ends. After the interruptionBegin event is received, all recording in the Mini Program is paused. After this event is received, recording can be started again.

Reference

(callback: (res: CallbackResult) => void) => void
PropertyTypeDescription
callback(res: CallbackResult) => voidThe callback function for the event that recording interruption ends.

API Support

APIWeChat Mini-ProgramH5React Native
RecorderManager.onInterruptionEnd✔️

onPause

Listens on the event that recording pauses.

Reference

(callback: (res: CallbackResult) => void) => void
PropertyTypeDescription
callback(res: CallbackResult) => voidThe callback function for the event that recording pauses.

API Support

APIWeChat Mini-ProgramH5React Native
RecorderManager.onPause✔️✔️

onResume

Listens on the event that recording resumes.

Reference

(callback: (res: CallbackResult) => void) => void
PropertyTypeDescription
callback(res: CallbackResult) => voidThe callback function for the event that recording resumes.

API Support

APIWeChat Mini-ProgramH5React Native
RecorderManager.onResume✔️✔️

onStart

Listens on the event that recording starts.

Reference

(callback: (res: CallbackResult) => void) => void
PropertyTypeDescription
callback(res: CallbackResult) => voidThe callback function for the event that recording starts.

API Support

APIWeChat Mini-ProgramH5React Native
RecorderManager.onStart✔️✔️

onStop

Listens on the event that recording ends.

Reference

(callback: OnStopCallback) => void
PropertyTypeDescription
callbackOnStopCallbackThe callback function for the event that recording ends.

API Support

APIWeChat Mini-ProgramH5React Native
RecorderManager.onStop✔️✔️

pause

Pauses recording

Reference

() => void

API Support

APIWeChat Mini-ProgramH5React Native
RecorderManager.pause✔️✔️

resume

Resumes recording

Reference

() => void

API Support

APIWeChat Mini-ProgramH5React Native
RecorderManager.resume✔️✔️

start

Starts recording

Reference

(option: StartOption) => void
PropertyType
optionStartOption

API Support

APIWeChat Mini-ProgramH5React Native
RecorderManager.start✔️✔️

stop

Stops recording

Reference

() => void

API Support

APIWeChat Mini-ProgramH5React Native
RecorderManager.stop✔️✔️

Parameters

OnErrorCallback

The callback function for the recording error event.

(result: OnErrorCallbackResult) => void
PropertyType
resultOnErrorCallbackResult

OnErrorCallbackResult

PropertyTypeDescription
errMsgstring错误信息

OnFrameRecordedCallback

The callback function for the event that the file with specified frame size has been recorded

(result: OnFrameRecordedCallbackResult) => void
PropertyType
resultOnFrameRecordedCallbackResult

OnFrameRecordedCallbackResult

PropertyTypeDescription
frameBufferArrayBufferRecording frame data
isLastFramebooleanWhether the current frame is the last frame before the end of recording

OnStopCallback

The callback function for the event that recording ends.

(result: OnStopCallbackResult) => void
PropertyType
resultOnStopCallbackResult

OnStopCallbackResult

PropertyTypeDescription
durationnumberThe duration of recording (in sec)
fileSizenumberThe size of a recording file (in bytes)
tempFilePathstringThe temporary path to recording files

StartOption

PropertyTypeRequiredDescription
audioSource"auto" | "buildInMic" | "headsetMic" | "mic" | "camcorder" | "voice_communication" | "voice_recognition"NoSpecifies the audio source for recording. Available audio sources can be obtained via Taro.getAvailableAudioSources().
durationnumberNoRecording duration (in ms). The maximum value is 600,000 (10 minutes).
encodeBitRatenumberNoEncoding bitrate. Valid values are shown in the following table.
format"mp3" | "aac"NoAudio format
frameSizenumberNoSpecifies the frame size (in KB). If this field is specified, the recorded file will be called back whenever reaching the specified frame size. If it is not specified, the recorded file will not be called back. Only MP3 format is supported.
numberOfChannels1 | 2NoNumber of recording channels
sampleRate8000 | 11025 | 12000 | 16000 | 22050 | 24000 | 32000 | 44100 | 48000NoSampling rate

audioSource

Valid values of object.audioSource

PropertyDescription
autoAutomatic setup. The mobile microphone is used by default. The headset microphone is automatically adopted when the headset is plugged in. This setup applies to all platforms.
buildInMicMobile microphone for iOS only
headsetMicHeadset microphone for iOS only
micMicrophone (if the headset is not plugged in, the mobile microphone is used; otherwise, the headset microphone is used) for Android only
camcorderSame as mic. Suitable for audio and video recording. For Android only.
voice_communicationSame as mic. Suitable for real-time communication. For Android only.
voice_recognitionSame as mic. Suitable for speech recognition. For Android only.

format

Valid values of object.format

PropertyDescription
mp3MP3 format
aacAAC format

numberOfChannels

Valid values of object.numberOfChannels

PropertyDescription
11 channel
22 channels

sampleRate

Valid values of object.sampleRate

PropertyDescriptionEncoding code rate
80008000 Hz sample rate16000 ~ 48000
1102511025 Hz sample rate16000 ~ 48000
1200012000 Hz sample rate24000 ~ 64000
1600016000 Hz sample rate24000 ~ 96000
2205022050 Hz sample rate32000 ~ 128000
2400024000 Hz sample rate32000 ~ 128000
3200032000 Hz sample rate48000 ~ 192000
4410044100 Hz sample rate64000 ~ 320000
4800048000 Hz sample rate64000 ~ 320000

API Support

APIWeChat Mini-ProgramH5React Native
RecorderManager.onError✔️✔️
RecorderManager.onFrameRecorded✔️
RecorderManager.onInterruptionBegin✔️
RecorderManager.onInterruptionEnd✔️
RecorderManager.onPause✔️✔️
RecorderManager.onResume✔️✔️
RecorderManager.onStart✔️✔️
RecorderManager.onStop✔️✔️
RecorderManager.pause✔️✔️
RecorderManager.resume✔️✔️
RecorderManager.start✔️✔️
RecorderManager.stop✔️✔️