Hello guys… Hope you’re doing great? I’m trying to record an audio on my app but I keep getting this error: _expo.Audio.setAudioModeAsync is not a function… can anyone tell me what am I doing wrong?
here’s the code:
_recordAudio = async () => { Audio.setIsEnabledAsync(true); Audio.setAudioModeAsync({ allowsRecordingIOS: true, interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_DO_NOT_MIX, playsInSilentLockedModeIOS: false, shouldDuckAndroid: true, interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DO_NOT_MIX, }); this._askForAudioPermission(); this._onRecordPressed(); }
_askForAudioPermission = async () => {
const response = await Permissions.askAsync(Permissions.AUDIO_RECORDING);
this.setState({
haveRecordingPermissions: response.status === ‘granted’,
});
console.log(“PERMISSION:”, JSON.stringify(this.state.haveRecordingPermissions));
};
_onRecordPressed = () => {
if (this.state.isRecording) {
this._stopRecordingAndEnablePlayback();
} else {
this._stopPlaybackAndBeginRecording();
}
};
async _stopPlaybackAndBeginRecording() {
this.setState({
isLoading: true,
});
if (this.sound !== null) {
await this.sound.unloadAsync();
this.sound.setCallback(null);
this.sound = null;
}
if (this.recording !== null) {
this.recording.setCallback(null);
this.recording = null;
}
const recording = new Audio.Recording(); await recording.prepareToRecordAsync(); recording.setCallback(this._updateScreenForRecordingStatus);
this.recording = recording; await this.recording.startAsync(); // Will call callback to update the screen. this.setState({ isLoading: false, });
}