uniapp使用第三方插件

950 阅读1分钟

最近项目调研语音测评方案,使用到了腾讯云智聆口语评测,官方提供了插件,如果你也有类似的需求,在uniapp中使用步骤参考如下:

修改manifest.json文件

"mp-weixin": { 
        /* 微信小程序特有相关 */
	"appid": "",
	"setting": {
            "urlCheck": false
	},
	"usingComponents": true,
        "plugins": {
          "tencentSpoken": {
            "version": "1.1.1",
            "provider": "wxe5a00a1780c8eb95"
          }
        }
  },

页面代码如下

const spokenPlugin = requirePlugin("tencentSpoken")
let spokenPluginManager = null

export default {
    methods: {
        // 点击开始录音
        startRecord() {
            spokenPluginManager.start({
                content: 'about'
            })
        }
    },
    onLoad() {
        spokenPluginManager = spokenPlugin.getSoeRecorderManager({
            secretId: '',
            secretKey: ''
        })
    }
}

扫码关注