我的代码在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();
}
}
答案 0 :(得分:0)
在构造函数中添加这些行并享受
this.audioRecorderPlayer = new AudioRecorderPlayer();
this.audioRecorderPlayer.setSubscriptionDuration(0.09);
在钩子中使用在 UseEffect 中添加这些行
audioRecorderPlayer = new AudioRecorderPlayer();
audioRecorderPlayer.setSubscriptionDuration(0.09);