收藏
回答

录音报错start record fail和audioQueue start fail

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug wx.getRecorderManager 微信iOS客户端 7.0.21 2.14.4

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()
    
  },
})


回答关注问题邀请回答
收藏

2 个回答

  • 月
    2021-06-28

    可能是因为麦克风被占用了。。。

    2021-06-28
    有用
    回复
  • Xuan
    Xuan
    2021-01-23

    有人吗,官方呢

    2021-01-23
    有用
    回复
登录 后发表内容
问题标签