验证成功或失败时语音播报,不需要暂停开始等操作,播报完成即可。
主要工作是需要有音频文件以及按照文档音频播放 API 使用说明 | 小程序说明在优酷中上传音频。要注意src不是音频全路径,而是v_show/id_
之后的音频码。
playAudio(type) {
if (type === '通过') {
this.innerAudioContext.src = 'DIxNg==';
} else {
this.innerAudioContext.src = 'DUwOA==';
}
this.innerAudioContext.autoplay = true;
this.innerAudioContext.loop = false;
this.innerAudioContext.obeyMuteSwitch = false;
this.innerAudioContext.onPlay(() => {
console.log("innerAudioContext onPlay 开始播放")
});
this.innerAudioContext.onError(() => {
console.log("innerAudioContext onError 前景音频播放错误事件")
});
}