收藏
回答

wx.getRecorderManager() 开始录音,开发者工具没有反应,查授权也开启了?

const recorderManager = wx.getRecorderManager()
onReadyfunction () {
    console.log(recorderManager)
    recorderManager.onStart(() => { //开始录音回调
      console.log('recorder start')
    })
    recorderManager.onStop((res) => { // 结束录音回调
      console.log('recorder stop', res)
      wx.hideToast()
      const { tempFilePath } = res
    })
    wx.getSetting({
      success:res=>{
        console.log(res)
        wx.authorize({
          scope'scope.record',
          success:res=>{
            console.log(res)
          }
        })
      }
    })
  },

// 开始录制语音
  longPressStart(){
    this.setData({
      voice:true
    })
    wx.showToast({
      title'开始录制语音...',
      duration:60000,
      icon:'none'
    })
    recorderManager.start({
      sampleRate44100,
      numberOfChannels1,
      encodeBitRate192000,
      frameSize50,
      format:'mp3'
    })
  },
  // 结束录制语音
  longPressEnd(){
    this.setData({
      voice:false
    })
    wx.hideToast()
    recorderManager.stop()
  },
回答关注问题邀请回答
收藏

3 个回答

登录 后发表内容
问题标签