title: Taro.stopVoice(option)

sidebar_label: stopVoice

结束播放语音。 注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 Taro.createInnerAudioContext 接口

支持情况:stopVoice - 图1 stopVoice - 图2 stopVoice - 图3

参考文档

类型

  1. (option?: Option) => void

参数

参数 类型
option Option

Option

参数 类型 必填 说明
complete (res: TaroGeneral.CallbackResult) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.CallbackResult) => void 接口调用失败的回调函数
success (res: TaroGeneral.CallbackResult) => void 接口调用成功的回调函数

示例代码

示例 1

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

示例 2

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