Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jibo001 opened this issue Nov 6, 2024 · 2 comments
Open

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

jibo001 opened this issue Nov 6, 2024 · 2 comments

Comments

@jibo001
Copy link

jibo001 commented Nov 6, 2024

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
Copy link
Author

jibo001 commented Nov 7, 2024

the error occur afeter stopRecorder throw stop fail.

@jibo001
Copy link
Author

jibo001 commented Nov 7, 2024

recode less than 1 seconds will throw stop fail

@jibo001 jibo001 changed the title startRecorder has already been called. startRecorder has already been called occur after stop fail. Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant