title: Taro.stopVoice(option)
sidebar_label: stopVoice
Stops the playback of a voice file.
Note: As of base library 1.6.0, this API is not maintained. Use Taro.createInnerAudioContext instead.
Type
(option?: Option) => void
Parameters
Option
| Property | Type | Required | Description |
|---|---|---|---|
| complete | (res: any) => void |
No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
| fail | (res: any) => void |
No | The callback function for a failed API call |
| success | (res: Result) => void |
No | The callback function for a successful API call |
Sample Code
Example 1
Taro.startRecord({success: function (res) {const filePath = res.tempFilePathTaro.playVoice({ filePath })setTimeout(Taro.stopVoice, 5000)}})
Example 2
Taro.startRecord(params).then(res => {const filePath = res.tempFilePathTaro.playVoice({ filePath })setTimeout(Taro.stopVoice, 5000)})
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| Taro.stopVoice | ✔️ |
