Open Erenner opened 2 years ago
Same problem
We have the same problem. Did you find any solution to fix this? Some more information: This seems to happen if the recorder is directly stopped after starting the recording, i.e. not holding the recording button.
Could you try adding requestLegacyExternalStorage = "true"
on AndroidManifest.xml
?
Related to https://github.com/react-native-cameraroll/react-native-cameraroll/issues/192#issuecomment-679122972
Could you try adding
requestLegacyExternalStorage = "true"
onAndroidManifest.xml
?Related to react-native-cameraroll/react-native-cameraroll#192 (comment)
I tried but it didn't work
same issue
We worked around this now with keeping track of the recording time and using a timeout to stop the recording if too little time has passed (<100ms). Something like this:
const minRecordingTime = 100
const [recordingTime, setRecordingTime] = useState<number>(0)
const onStopRecording = async (): Promise<void> => {
audioRecorderPlayer.removeRecordBackListener()
if (recordingTime < minRecordingTime) {
// If the button is just tapped and the recording is stopped to fast, an error is thrown from which it is not possible to recover
// https://github.com/hyochan/react-native-audio-recorder-player/issues/490
setTimeout(() => {
audioRecorderPlayer.stopRecorder().catch(reportError)
}, minRecordingTime)
return
}
try {
const recordingPath = await audioRecorderPlayer.stopRecorder()
if (recordingPath.includes('file://')) {
onAudioRecorded(recordingPath)
}
} catch (e) {
// do something with errors
}
}
const onStartRecording = async (): Promise<void> => {
if (recordingTime !== 0) {
return
}
try {
await audioRecorderPlayer.startRecorder(undefined, undefined, true)
audioRecorderPlayer.addRecordBackListener(async e => {
setRecordingTime(e.currentPosition)
if (e.currentPosition > maxRecordingTime) {
await onStopRecording()
}
})
} catch (error) {
// do something with errors
}
return (
<RecordIcon
onPressIn={onStartRecording}
onPressOut={onStopRecording}
isPressed={isPressed}
testID='record-audio-button'>
<MicrophoneIcon width={theme.spacingsPlain.xxl} height={theme.spacingsPlain.xxl} />
</RecordIcon>
)
Error: stop failed. at Object.promiseMethodWrapper [as stopRecorder] (NativeModules.js:106:51) at AudioRecorderPlayer.<anonymous> (index.ts:290:36) at Generator.next (<anonymous>) at asyncGeneratorStep (asyncToGenerator.js:3:16) at _next (asyncToGenerator.js:25:9) at asyncToGenerator.js:32:7 at tryCallTwo (core.js:45:5) at doResolve (core.js:200:13) at new Promise (core.js:66:3) at AudioRecorderPlayer.stopRecorder (asyncToGenerator.js:21:12)
Version of react-native-audio-recorder-player
^3.5.1"
Version of React Native
68
Platforms you faced the error (IOS or Android or both?)
Android on mac 1
Expected behavior
Actual behavior
Steps to reproduce the behabior