为什么同声传译onStop事件不触发?
发布于 5 年前 作者 chaoyi 8822 次浏览 来自 官方Issues

const plugin = requirePlugin("WechatSI");

let manager = plugin.getRecordRecognitionManager();


// Events

const INPUT_COMPLETE = "inputComplete"


// io/voice.js

Component({

 /**

  * Component properties

  */

 properties: {

   lang: {

     type: String,

     value: 'zh_CN'

   }

 },


 created: function() {

   console.log('created')


   let that = this

   manager.onStart = function(res) {

     console.log("manager.Start", res)

     that.triggerEvent(INPUT_COMPLETE, 'start')

   }


   // 识别结束事件

   manager.onStop = function(res) {

     console.log("manager.onStop")

   }


   manager.onError = function(res) {

     console.log('manager.onError')

   }

 },


 /**

  * Component initial data

  */

 data: {


 },


 /**

  * Component methods

  */

 methods: {

   recordStart() {

     let lang = this.properties.lang

     manager.start({

       lang,

     })

   },


   recordEnd() {

     console.log('recordEnd')

     manager.stop()

   }

 }

})



自定义了一个语音输入的组件,在开发工具中测试时发现可以看到“recordEnd”消息,不能看到"manager.onStop"信息。这里我还遗漏了某些设置吗?如果没有。manager.onStop为什么不触发呢?

4 回复

同问,我为什么也不执行onStart()方法

你的现在解决了吗?

回到顶部