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

时间:2019-08-24 00:21:10

标签: ios react-native audio

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

我一直在寻找本机的录音机软件包,这个软件包似乎是最好的解决方案,但是它不适用于ios平台

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

1 个答案:

答案 0 :(得分:0)

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

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

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

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