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.

Reference

Type

  1. (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

  1. Taro.startRecord({
  2. success: function (res) {
  3. const filePath = res.tempFilePath
  4. Taro.playVoice({ filePath })
  5. setTimeout(Taro.stopVoice, 5000)
  6. }
  7. })

Example 2

  1. Taro.startRecord(params).then(res => {
  2. const filePath = res.tempFilePath
  3. Taro.playVoice({ filePath })
  4. setTimeout(Taro.stopVoice, 5000)
  5. })

API Support

API WeChat Mini-Program H5 React Native
Taro.stopVoice ✔️