录音api“anthorize no response”
发布于 5 年前 作者 yang90 431 次浏览 来自 问答

弹框显示:

operateRecorder:fail anthorize no response

而且弹框不断不间断闪现,导致除了关闭小程序按钮,其他任何页面功能都使用不了,只能退出;

<----------------js代码------->

function setRecordManager(current, callBack = function() {}) {

if (!wx.getRecorderManager) {

wx.showModal({

title: ‘无法启动’,

content: ‘您的微信版本过低,请升级微信客户端’,

showCancel: false,

})

return false;

}

if (!that.recorderManager) {

that.recorderManager = wx.getRecorderManager();

}

that.recorderManager.onStop(function(res) {

that.globalMedaiPlaying = false;

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

var userReadList = that.data.userReadList;

userReadList[current][“Path”] = res.tempFilePath;

that.setData({

aleardyRecordFlag: 0,

recordAudioCurrent: “null”,

userReadList: userReadList,

});

canSubmit();

score(current)

setUserReadAudio(current, res.tempFilePath);

});

that.recorderManager.onStart(() => {

var userReadList = that.data.userReadList;

userReadList[current] = {};

that.setData({

userReadList: userReadList,

});

console.log(userReadList);

});

//错误回调

that.recorderManager.onError((res) => {

that.globalMedaiPlaying = false;

that.recorderManager.stop();

that.setData({

recordingAudioCurrent: “”,

});

wx.showModal({

title: ‘录音失败’,

content: res.errMsg,

showCancel: false,

})

})

callBack();

}

function startRecordAudio(current) {

that.composeAudioData = {};

if (that.globalMedaiPlaying) {

stopAllAudio();

}

that.globalMedaiPlaying = true;

setRecordManager(current, function() {

const duration = 60000;

const recordOptions = {

duration: duration, //指定录音的时长,单位 ms

sampleRate: 16000, //采样率

numberOfChannels: 1, //录音通道数

encodeBitRate: 96000, //编码码率

format: ‘mp3’, //音频格式,有效值 aac/mp3

frameSize: 50, //指定帧大小,单位 KB

}

that.recorderManager.start(recordOptions);

that.recordStartTime = new Date().getTime()

that.setData({

recordAudioCurrent: current,

});

});

}

1 回复

麻烦提供出现问题的机型和微信版本,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

回到顶部