繁体   English   中英

react-native-audio-recorder-player:无法读取未定义的属性“startRecorder”

[英]react-native-audio-recorder-player: Cannot read property 'startRecorder' of undefined

我的代码在 android 平台上运行良好,但在 ios 中我得到: unhandled Promise Rejection: Cannot read property 'startRecorder' of undefined错误的unhandled Promise Rejection: Cannot read property 'startRecorder' of undefined

我正在寻找一个用于 react-native 的录音机包,这个包似乎是最好的解决方案,但它在 ios 平台上不起作用

  const audioRecorderPlayer = new AudioRecorderPlayer();
  class QuestionSection extends Component {
    async onRecordPressed() {
      if (await this.requestPermissions()) {
        console.warn('start');
        await audioRecorderPlayer.startRecorder();
    }
  }

在构造函数中添加这些行并享受

 this.audioRecorderPlayer = new AudioRecorderPlayer();
this.audioRecorderPlayer.setSubscriptionDuration(0.09);

在钩子中使用在 UseEffect 中添加这些行

audioRecorderPlayer = new AudioRecorderPlayer();
audioRecorderPlayer.setSubscriptionDuration(0.09);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM