How to use the recording feature in WeDa
Requires the use of RecorderManager (the globally unique audio recording manager) in WeChat Mini Program development.
Recording Process
- The user enters the page and loads the RecorderManager instance for audio recording.
- Start recording
- After recording is completed, stop the recording.
- Retrieve the temporary recording file via RecorderManager.onStop()
- Upload the temporary file to the cloud server via wx.uploadFile
- Convert cloud service file id to https URL
- The page displays the recording file for user playback.
Sample code
const recorderManager = wx.getRecorderManager()
recorderManager.onStart(() => {// Listen for the start of recording
console.log('recorder start')
})
recorderManager.onPause(() => {// Listen for the pause of recording
console.log('recorder pause')
})
recorderManager.onStop((res) => {// Listen for the stop of recording
console.log('recorder stop', res)
const { tempFilePath } = res
})
recorderManager.onFrameRecorded((res) => {
const { frameBuffer } = res
console.log('frameBuffer.byteLength', frameBuffer.byteLength)
})
const options = {//Recording configuration
duration: 10000,
sampleRate: 44100,
numberOfChannels: 1,
encodeBitRate: 192000,
format: 'aac',
frameSize: 50
}
recorderManager.start(options) // Start recording
recorderManager.pause()//Pause recording
recorderManager.stop()//Stop/end recording
For more information, refer to: Implementing the Recording Feature in WeDa Applications Globally Unique Recording Manager
Similar Issues
- How to implement the recording feature in WeDa?
- How to use the WeChat Mini Program's RecorderManager for audio recording?
- What is the workflow for the recording feature in WeDa?
- How to start and stop recording in WeDa?
- How to upload the file after recording in WeDa?
- How to convert the recording file into a playable link in WeDa?
- What are the sample codes for the recording feature in WeDa?
- How to configure parameters for the recording feature in WeDa?
- How to pause and resume recording in WeDa?
- Where can I find the related documentation for the recording feature in WeDa?