使用录音的onStop来获取录音文件回调地址,在小程序无法获取到,但是在app上能获取

- 发布:2019-05-09 09:12
- 更新:2019-05-09 12:51
- 阅读:1728
【报Bug】录音功能的onStop在小程序上获取不到录音文件回调地址

和平台无关,代码写的有问题,应在录音前监听onStop,不是在录制结束后监听,参考hello uni-app
onStopRecordTap() {
soundRecords.stop();
this.isRecord = 2;
soundRecords.onStop(res => {
clearTimeout(timer);
this.$http.qiniu.upload(
res.tempFilePath,
res => {
this.voicePath = res.imageURL;
this.$forceUpdate();
uni.hideLoading();
},
error => {
this.toast("当前录音保存不成功,请重试");
}
);
console.log('res: ' + JSON.stringify(res));
});
}
-
1***@qq.com (作者)
mounted(){
soundRecords.onStop(res => {
clearTimeout(timer);
if(res.tempFilePath){
console.log("这里打印:"+res.tempFilePath)
this.$http.qiniu.upload(
res.tempFilePath,
res => {
this.voicePath = res.imageURL;
this.$forceUpdate();
uni.hideLoading();
},
error => {
this.toast("当前录音保存不成功,请重试");
}
);
}else{
console.log("这里测试是否为空");
}
console.log('res: ' + JSON.stringify(res));
});
innerAudioContext.onEnded(() => {
this.isRecord = 2;
this.iconPath = '../../static/record/startplay@3x.png';
// this.timing = `0分0秒`;
});
},
我现在把这坨代码,放在mounted了,小程序上点击stop(), 没有执行 onStop的回调事件
2019-05-09 14:35
-
1***@qq.com (作者)
我把这个页面都发过来,下面
2019-05-09 11:45