Open kchany opened 2 years ago
Facing same issue
Try the following while startig the record function,
if (Platform.OS === 'android') { try { const grants = await PermissionsAndroid.requestMultiple([ PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE, PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE, PermissionsAndroid.PERMISSIONS.RECORD_AUDIO, ]); console.log('write external stroage', grants); if ( grants['android.permission.WRITE_EXTERNAL_STORAGE'] === PermissionsAndroid.RESULTS.GRANTED && grants['android.permission.READ_EXTERNAL_STORAGE'] === PermissionsAndroid.RESULTS.GRANTED && grants['android.permission.RECORD_AUDIO'] === PermissionsAndroid.RESULTS.GRANTED ) { console.log('Permissions granted'); } else { console.log('All required permissions not granted'); return; } } catch (err) { console.warn(err); return; }
If you are Korean, please let me know your e-mail for more detailed explanation and I would like to communicate in Korean.
Version of react-native-audio-recorder-player
3.1.2
Version of React Native
2.0.1
Platforms you faced the error (IOS or Android or both?)
Android
Expected behavior
Upload recorded voice to server
Actual behavior
When you tap Voice Record, A notification asking to grant permission appears, and if you set allow, Error: Try again after adding permission. Error: recorder is null. The text appears.
After exiting the application and entering again and proceeding with recording, the voice recording is completed, and the recording path of Android is The log says "uri": "file:////data/user/0/com.baeuja/cache/sound.mp4".
And in the server, the mp4 file for the duration of the audio recording is stored, and the audio recording is not in progress, but it is an empty file.
In iOS, the desired function works normally.
As instructed in the manual, we have proceeded with all of the Android permission settings.
Steps to reproduce the behabior
Voice recording function.
const onStartRecord = async () => { console.log('-------------음성 녹음 시작-------------');
};
This is the part that stops voice recording and uploads it to the server. const onStopRecord = async () => { const DEFAULT_RECOREDED_FILE_NAME_iOS = 'sound.m4a'; const DEFAULT_RECOREDED_FILE_NAME_Android = 'sound.mp4'; const recoredUserVoice = await audioRecorderPlayer.stopRecorder(); audioRecorderPlayer.removeRecordBackListener(); if (recoredUserVoice === 'Already stopped') { alert('Please record your the great voice first 🙏'); console.log('Already stopped'); return; } setIsRecordingUserVoice(!isRecordingUserVoice); setIsMoreThanOneTimeRecord(true); console.log(recoredUserVoice); console.log('-------------음성 녹음 중지 완료------------');
};