react-native-audio-recorder-player icon indicating copy to clipboard operation
react-native-audio-recorder-player copied to clipboard

startRecorder has already been called occur after stop fail.

Open jibo001 opened this issue 1 year ago • 3 comments

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 avatar Nov 06 '24 07:11 jibo001