简体   繁体   中英

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

my code is working perfectly in android platform but in ios i get : unhandled Promise Rejection: Cannot read property 'startRecorder' of undefined error

i was looking for an audio recorder package for react-native, this package seems to be best solution, but it's not working in ios platform

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

Add these lines in Constructor and Enjoy

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

Use in hooks add these lines in UseEffect

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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