录音无法启动,之前测试都没有问题,求大神指教
发布于 7 年前 作者 juanguo 19746 次浏览 来自 问答

//实现一个计时的录音

blueplay: function () {

var that = this;

var ms = ‘modalvoice.m’

var ss = ‘modalvoice.s’

that.setData({

time: 1,

[ms]: 0,

[ss]: 0,

})

this.recorderManager = wx.getRecorderManager();

this.recorderManager.onStart(function () {

// 录音开始的回调处理

var interval= setInterval(function () {

var time = that.data.time;

console.log(time)

if (time === 2) {

clearInterval(interval);

}else{

var m = that.data.modalvoice.m

var s = that.data.modalvoice.s

var ms = ‘modalvoice.m’

var ss = ‘modalvoice.s’

if(s!==60){

console.log(m);

that.setData({

[ms]: m,

[ss]: s+1

})

}else{

that.setData({

[ms]: m+1,

[ss]: 0,

})

}

}

}, 1000);

});

this.recorderManager.onStop(function (res) {

// 停止录音之后,把录取到的音频放在res.tempFilePath

var obj = {

bindtap: “middleplay”,

src: ‘…/…/image/blue.png’,

index: res.tempFilePath

};

that.data.middle.push(obj)

var middle = that.data.middle;

that.setData({

middle: middle

});

var time = that.data.time;

console.log(time)

});

const options = {

sampleRate: 44100,

numberOfChannels: 1,

encodeBitRate: 192000,

format: ‘mp3’,

frameSize: 50

}

this.recorderManager.start(options);

//modal

var hide = that.data.hidden;

that.setData({

hidden:false

})

},

2 回复

麻烦给个相关的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html),我们定位下问题

onError结果是:

operateRecorder:fail auth deny

回到顶部