Skip to main content
Version: Next

Taro.stopVoice(option)

Stops the playback of a voice file.

Note: As of base library 1.6.0, this API is not maintained. Use Taro.createInnerAudioContext instead.

Reference

Type

(option?: Option) => void

Parameters

Option

PropertyTypeRequiredDescription
complete(res: any) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
fail(res: any) => voidNoThe callback function for a failed API call
success(res: Result) => voidNoThe callback function for a successful API call

Sample Code

Example 1

Taro.startRecord({
success: function (res) {
const filePath = res.tempFilePath
Taro.playVoice({ filePath })

setTimeout(Taro.stopVoice, 5000)
}
})

Example 2

Taro.startRecord(params).then(res => {
const filePath = res.tempFilePath
Taro.playVoice({ filePath })

setTimeout(Taro.stopVoice, 5000)
})

API Support

APIWeChat Mini-ProgramH5React Native
Taro.stopVoice✔️