hyochan / react-native-audio-recorder-player

react-native native module for audio recorder and player.
MIT License
728 stars 215 forks source link

startRecorder has already been called occur after stop fail. #640

Open jibo001 opened 2 weeks ago

jibo001 commented 2 weeks ago

Please fill the template to help you out. Also, please try the Example project compare before submiting the issue when you have certain issue with your project setup.

"react-native-audio-recorder-player": "^3.6.12",

"react-native": "0.73.7",

android

when i press button fast will throw the error

const onStartRecord = useCallback(async () => { if (!audioRecorderPlayer) return setVoiceId('') try { audioRecorderPlayer.stopPlayer() audioRecorderPlayer.stopRecorder() audioRecorderPlayer.removePlayBackListener() audioRecorderPlayer.removeRecordBackListener() } catch (e: any) { ChatError.error('onStartRecord stopRecords', e.message) } finally { const audioSet: AudioSet = { AudioEncoderAndroid: AudioEncoderAndroidType.AAC, AudioSourceAndroid: AudioSourceAndroidType.MIC, AVEncoderAudioQualityKeyIOS: AVEncoderAudioQualityIOSType.high, AVNumberOfChannelsKeyIOS: 2, AVFormatIDKeyIOS: AVEncodingOption.aac, OutputFormatAndroid: OutputFormatAndroidType.AAC_ADTS, } try { Vibration.vibrate() await audioRecorderPlayer.startRecorder( path, audioSet, ) setModalVisible(true) audioRecorderPlayer.addRecordBackListener((e: RecordBackType) => { const _remain = Math.floor(MAX_DURATION - e.currentPosition / 1000) if (_remain <= NOTICE_DURATION && _remain >= 0) { if (_remain === 0) { onStopRecord() } setRemainSeconds(_remain) } duration.current = e.currentPosition }) } catch (e: any) { audioRecorderPlayer.stopRecorder() ChatError.error('onStartRecord', e.message) } } }, [audioRecorderPlayer])

jibo001 commented 2 weeks ago

the error occur afeter stopRecorder throw stop fail.

jibo001 commented 2 weeks ago

recode less than 1 seconds will throw stop fail