小程序
小游戏
企业微信
微信支付
扫描小程序码分享
iphoneX录音失败直接走onError,参数res的errCode:-66681
然后报错operateRecorder:fail:start record fail和audioQueue start fail
代码片段:https://developers.weixin.qq.com/s/qxZGUvmQ7Hnr
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
同问
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
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 }) }) }, playOrPause(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() }, })
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
同问
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 }) }) }, playOrPause(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() }, })