1***@qq.com
1***@qq.com
  • 发布:2019-05-09 09:12
  • 更新:2019-05-09 12:51
  • 阅读:1728

【报Bug】录音功能的onStop在小程序上获取不到录音文件回调地址

分类:uni-app

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

2019-05-09 09:12 负责人:无 分享
已邀请:
DCloud_uni-ad_HDX

DCloud_uni-ad_HDX

试试HBuilderX 1.9.5 alpha版,测试没有问题

提供下你的代码,我们分析下

  • 1***@qq.com (作者)

    我把这个页面都发过来,下面

    2019-05-09 11:45

1***@qq.com

1***@qq.com (作者)

我把这个页面都发过来,

DCloud_uni-ad_HDX

DCloud_uni-ad_HDX

和平台无关,代码写的有问题,应在录音前监听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 14:40

该问题目前已经被锁定, 无法添加新回复