Audio not recording completely or unable to record audio
Describe the bug Audio recording on iOS is not working as expected — the recorded audio is either incomplete, very short, or missing entirely.
To Reproduce Steps to reproduce the behavior:
- Set up the recorder with mode "live"
- Check permission
- Record audio for 20-30 s.
- Get the audio path and send it to the server. The actual recording size is 1-2 seconds only
Expected behavior It should record complete audio.
Smartphone (please complete the following information):
- Device: [iPhone 7]
- OS: [iOS15.8.4 ]
Reproducable code
const {checkHasAudioRecorderPermission, getAudioRecorderPermission} =
useAudioPermission();
const [recorderState, setRecorderState] = useState(RecorderState.stopped);
const startRecord = () => {
recordRef.current
?.startRecord({
updateFrequency: UpdateFrequency.high,
})
.then(() => {})
.catch(() => {});
};
const handleRecorderAction = useCallback(async () => {
if (recorderState === RecorderState.stopped) {
let hasPermission = await checkHasAudioRecorderPermission();
if (hasPermission === PermissionStatus.granted) {
startRecord();
} else if (hasPermission === PermissionStatus.undetermined) {
const permissionStatus = await getAudioRecorderPermission();
if (permissionStatus === PermissionStatus.granted) {
startRecord();
}
} else {
Linking.openSettings();
}
} else {
recordRef.current?.stopRecord().then(path => {
let type = mime.lookup(path.replace('file://', ''));
console.log('path', path);
onSendRecording({mime: type, path});
});
}
}, [
checkHasAudioRecorderPermission,
getAudioRecorderPermission,
onSendRecording,
recorderState,
]);
<Waveform
mode="live"
containerStyle={[AppStyle.fill]}
ref={recordRef}
candleSpace={2}
candleWidth={4}
waveColor={Colors.primary500}
onRecorderStateChange={setRecorderState}
/>
We haven’t encountered this issue on our end, but we’ll double-check for any potential problems. In the meantime, could you please confirm whether this behavior occurs across all devices and iOS versions, or only on the ones you mentioned in your comment?
I have the same problem and it appears only on real devices. I tested it on: iPad 3rd (18.5), iPhone 16 (18.5) On simulators it's working great.
Are you using react-native-video? In my case it interfered with audio recording. Downgrading to 6.10.2 resolved the problem.