May 18, 2021 WeChat Mini Program Development Document
Starting with base library 1.6.0, this interface is no 10th stop maintenance, please use wx.createInnerAudioContext instead
Start playing the voice. Only one voice file is allowed to play at the same time, and if the previous voice file is not finished, the previous voice playback is interrupted.
Property | Type | The default | Required | Description | The lowest version |
---|---|---|---|---|---|
filePath | string | Is | File path for voice files that need to be played (local path) | ||
duration | number | 60 | Whether | Specify the recording time, reach the specified recording length and automatically stop recording in seconds | 1.6.0 |
success | function | Whether | The interface calls a successful callback function | ||
fail | function | Whether | The interface calls the failed callback function | ||
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
wx.startRecord({
success (res) {
const tempFilePath = res.tempFilePath
wx.playVoice({
filePath: tempFilePath,
complete () { }
})
}
})