gpt4 book ai didi

ios - react native 录音机播放器 : Cannot read property 'startRecorder' of undefined

转载 作者:行者123 更新时间:2023-12-05 07:20:03 26 4
gpt4 key购买 nike

我的代码在 android 平台上运行完美,但在 ios 中我得到: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);

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

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

关于ios - react native 录音机播放器 : Cannot read property 'startRecorder' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57634239/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com