This API is used via wx.startRecord(Object object).
Attribute | Type | Default value | Required | Description |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Attribute | Type | Description |
tempFilePath | string | Temporary path of audio recording file (local path) |
wx.startRecord({success (res) {const tempFilePath = res.tempFilePath}})setTimeout(function () {wx.stopRecord() // Stop audio recording}, 10000)
This API is used via wx.stopRecord(Object object).
Attribute | Type | Default value | Required | Description |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
wx.startRecord({success (res) {const tempFilePath = res.tempFilePath}})setTimeout(function () {wx.stopRecord() // Stop audio recording}, 10000)
This API is used via RecorderManager wx.getRecorderManager().
This method is used via RecorderManager.onError(function listener).
Attribute | Type | Description |
errMsg | string | Error Message |
This method is used via RecorderManager.onFrameRecorded(function listener).
Attribute | Type | Description |
frameBuffer | ArrayBuffer | Audio recording shard data |
isLastFrame | boolean | Is the current frame the last one before the normal end of the audio recording? |
This method is used via RecorderManager.onInterruptionBegin(function listener).
This method is used via RecorderManager.onInterruptionEnd(function listener).
This method is used via RecorderManager.onPause(function listener).
This method is used via RecorderManager.onResume(function listener).
This method is used via RecorderManager.start(Object object).
This method is used via RecorderManager.onStop(function listener).
Attribute | Type | Description |
tempFilePath | string | Temporary path of audio recording file (local path) |
duration | number | Total audio recording duration, in milliseconds. |
fileSize | number | Audio recording file size, in bytes. |
This method is used via RecorderManager.pause().
This method is used via RecorderManager.resume().
This method is used via RecorderManager.start(Object object).
Attribute | Type | Default value | Required | Description |
duration | number | 60000 | No | The duration of the audio recording, measured in milliseconds (ms), with a maximum value of 600,000 (equivalent to 10 minutes). |
sampleRate | number | 80000 | No | Sampling rate (not supported on PC) |
numberOfChannels | number | 2 | No | Number of audio recording channels |
encodeBitRate | number | 48000 | No | Encoding bitrate, with valid values provided in the table below. |
format | string | aac | No | Audio Format |
frameSize | number | - | No | Specify the frame size in kilobytes (KB). Upon passing in the frameSize, the content of the files recorded to the specified frame size will be called back. If not specified, no callback will occur. Currently, only mp3 and pcm formats are supported. |
audioSource | string | auto | No | Specify the audio input source for audio recording. |
Legal value | Description |
1 | 1 channel |
2 | 2 channel |
Legal value | Description |
mp3 | mp3 |
aac | aac |
wav | wav |
PCM | pcm |
Legal value | Description |
auto | Automatically set up, the default use of cell phone microphone, plug in the headset automatically switch to use the headset microphone, all platforms applicable |
buildInMic | Cellular microphone, iOS only |
headsetMic | Wired headset microphone, iOS only |
mic | Microphone (phone microphone when headset is not plugged in, headset microphone when headset is plugged in), Android only |
camcorder | Same as mic for recording audio and video content, Android only |
voice_communication | Same as mic, for real-time communication, Android only |
voice_recognition | Same as mic, for speech recognition, Android only |
Sampling rate. | Encoding bitrate |
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 |
This method is used via RecorderManager.stop().
Was this page helpful?