收藏
回答

iphoneX录音失败operateRecorder:fail:start record fail?

iphoneX录音失败直接走onError,参数res的errCode:-66681

然后报错operateRecorder:fail:start record fail和audioQueue start fail

代码片段:https://developers.weixin.qq.com/s/qxZGUvmQ7Hnr

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

2 个回答

  • 哦哦哦
    哦哦哦
    2021-08-19

    同问

    2021-08-19
    有用
    回复
  • 溪雨安
    溪雨安
    2021-01-21
    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()
        
      },
    })
    
    
    
    2021-01-21
    有用
    回复 2
    • 溪雨安
      溪雨安
      2021-01-21
      有没有小伙伴能帮忙邀请一下官方看看,谢谢
      2021-01-21
      回复
    • 溪雨安
      溪雨安
      2021-01-25回复溪雨安
      .
      2021-01-25
      回复
登录 后发表内容
问题标签