在使用手机运行测试的时候一点事没有,打包后recorderManager.onStop(function(res) { })就监听不到了,不执行,代码使用的是官方的案例
const recorderManager = uni.getRecorderManager();
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true;
export default {
data() {
return {
text: 'uni-app',
voicePath: ''
}
},
onLoad() {
let self = this;
recorderManager.onStop(function (res) {
console.log('recorder stop' + JSON.stringify(res));
self.voicePath = res.tempFilePath;
});
},
methods: {
startRecord() {
console.log('开始录音');
recorderManager.start();
},
endRecord() {
console.log('录音结束');
recorderManager.stop();
},
playVoice() {
console.log('播放录音');
if (this.voicePath) {
innerAudioContext.src = this.voicePath;
innerAudioContext.play();
}
}
}
}
请问怎么回事啊?求助 谢谢
2 个回复
DCloud_uni-ad_HDX
FullStack - 【插件开发】【专治疑难杂症】【ios上架、马甲包、白包、过审、已成功上架过几百个】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=22130】【非诚勿扰】QQ:543610866
录音支持暂停、继续(ios、andorid):https://ext.dcloud.net.cn/plugin?id=5849