4***@qq.com
4***@qq.com
  • 发布:2020-10-14 18:07
  • 更新:2020-11-13 11:01
  • 阅读:1210

【报Bug】录音管理api小程序录音后上传服务器 mp3没声音

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: 10.14.6

HBuilderX类型: 正式

HBuilderX版本号: 2.8.13

第三方开发者工具版本号: 1.03.20

基础库版本号: 2.13.1

项目创建方式: HBuilderX

示例代码:
const recorderManager = uni.getRecorderManager();  
const innerAudioContext = uni.createInnerAudioContext();  
export default {  
    onLoad() {  

    },  
    mounted() {  
        this.onstart();  
        recorderManager.onStop(async (res)=> {  
            await this.$upload.upload({  
                type:'audio',  
                audioUrl:res.tempFilePath  
            })  
            .then(result=>{  
                this.voicePath = result[0].data.fullurl;  
                console.log(this.voicePath)  
            })  
        });  
    },  
    props:{  

    },  
    watch:{  
        second(newval){  
            if(newval === 0){  
                this.minute++  
            }  
        },  
        minute(newval){  
            if(newval === 6 && this.second === 0){  
                this.minute = 0;  
                this.Time++  
            }  
        }  
    },  
    data() {  
        return {  
            second:0,  
            minute:0,  
            Time:0,  
            opacity:1,  
            isStart:true,  
            timestart:null,  
            opacitystart:null,  
            isSuccess:false,  
            isPlay:false,  
            voicePath:''  
        };  
    },  
    methods:{  
        onSuccess(){  
            this.isSuccess = true;  
            this.endRecord()  
        },  
        close(){  
            this.$emit('close')  
        },  
        endRecord() {  
            console.log('录音结束');  
            recorderManager.stop();  
        },  
        playVoice() {  
            console.log('播放录音');  
            this.isPlay = true;  
            if (this.voicePath) {  
                innerAudioContext.src = this.voicePath;  
                innerAudioContext.obeyMuteSwitch = false;  
                console.log(innerAudioContext)  
                innerAudioContext.play();  
            }  
        },  
        startRecord() {  
            console.log('开始录音');  
            const options = {  
              sampleRate: 16000,//采样率  
              numberOfChannels: 1,//录音通道数  
              encodeBitRate: 96000,//编码码率  
              format: 'mp3',//音频格式,有效值 aac/mp3  
              frameSize: 50,//指定帧大小,单位 KB  
            }  
            recorderManager.start(options);  

        },  
        // 暂停录音方法  
        pause(){  
            console.log('暂停录音')  
            recorderManager.pause();  
        },  
        stopstart(){  
            clearInterval(this.timestart)  
            clearInterval(this.opacitystart)  
            this.opacity = 1;  
            this.isStart = false;  
            // 暂停  
            this.pause()  
        },  
        onstart(){  
            this.startRecord()  
            this.isStart = true;  
            this.timestart = setInterval(res=>{  
                if(this.second < 9){  
                    this.second++  
                }else{  
                    this.second = 0  
                }  
            },1000)  
            this.opacitystart = setInterval(res=>{  
                if(this.opacity == 1){  
                    this.opacity = 0;  
                }else{  
                    this.opacity = 1;  
                }  
            },500)  
        }  
    }  
}

操作步骤:

开启录音完成后 mp3格式直接上传至服务器 超链接服务器端的访问mp3

预期结果:

能正常播放声音

实际结果:

没声音

bug描述:

录音上传服务器后 访问 没声音 app端测试没问题

2020-10-14 18:07 负责人:无 分享
已邀请:
4***@qq.com

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

微信小程序录音 在mac和windows开发者工具中没有声音 是微信的坑
ios手机是开静音模式录音回放就会没有声音

  • 蒙多塞冬

    我遇到的问题是在 DevTools 模拟器里,有声音。

    iOS 手机有声音,但是设置 obeyMuteSwitch到 false 还是没有声音。

    2020-12-12 19:25

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