iphoneX真机测试下直接走:onError()
注意:不是 iphoneXR 也不是 IphoneXS 而是 iPhoneX
onError:errCode:-66681
报错operateRecorder:fail:start record fail 和 audioQueue start fail
请在官方文档上给出这些错误的原因,真的很难顶!!
附上代码:
const app = getApp()
// 录音配置
const recordOptions = {
duration: 60000,
numberOfChannels: 1,
sampleRate: 16000,
encodeBitRate: 96000,
format: 'mp3',
frameSize: 50,
audioSource:'auto' // 设置录音输入源 auto
}
Page({
data: {
recorderManager:{},
player:{},
recordList:[]
},
// 开始接触
touchstart(){
wx.vibrateShort({
type:'heavy',
})
this.data.recorderManager.start(recordOptions)
},
touchmove(e){
console.log(e)
},
touchend(e){
console.log(111)
this.data.recorderManager.stop()
},
touchcancel(){
},
disposeRecord(){
this.data.recorderManager.onStart(() => {
console.log('recorder start')
})
this.data.recorderManager.onPause(() => {
console.log('recorder pause')
})
this.data.recorderManager.onStop((res) => {
console.log('监听到录音结束')
console.log('recorder stop', res)
const { tempFilePath, duration } = res
console.log(tempFilePath,duration)
this.data.recordList.push(res)
this.setData({
recordList:this.data.recordList
})
})
this.data.recorderManager.onFrameRecorded((res) => {
const { frameBuffer } = res
console.log('frameBuffer.byteLength', frameBuffer.byteLength)
});
this.data.recorderManager.onError((res)=>{
console.log(res) // errcode -66681
// audioQueue start fail
wx.showToast({
icon:'info',
title: '录音失败'+res.errMsg,
duration: 1500
})
})
},
playOrPlause(e){
console.log(e)
this.data.player.stop()
this.data.player.src = e.target.dataset.item.tempFilePath
this.data.player.play()
},
disposeVoice(){
// play voice
this.data.player.onPlay(() => {
console.log('play voice')
wx.vibrateShort();
});
this.data.player.onStop(() => {
console.log('stop voice')
})
this.data.player.onEnded(() => {
console.log('end voice')
})
},
onLoad() {
this.data.recorderManager = wx.getRecorderManager()
this.disposeRecord()
this.data.player = wx.createInnerAudioContext()
this.disposeVoice()
},
})
可能是因为麦克风被占用了。。。
有人吗,官方呢