我的代码在 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/