簡體   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