hyochan / react-native-audio-recorder-player

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

Facing issues in stopping the audio recording #585

Open SulthanNK opened 4 months ago

SulthanNK commented 4 months ago

Even though using the stopRecorder method. it shows 'already stopped' but keeps recording the audio

parthpanchalTAI commented 4 months ago

For stopping the recording, you can directly attempt to stop the recorder, remove the record back listener, and then update your state.

const onStopRecord = React.useCallback(async () => {
    try {
        const result = await audioRecorderPlayer.stopRecorder();
        audioRecorderPlayer.removeRecordBackListener();
        setIsRecording(false);
        console.log("Stopped recording:", result);
    } catch (error) {
        console.error("Error stopping the recording:", error);
    }
}, []);

found the solution here

Iamfavur commented 1 month ago

Even though using the stopRecorder method. it shows 'already stopped' but keeps recording the audio

faced the same issue but apparently, it was happening because you declared the audio player inside your component when it should have been outside, like this >>

import....

const audioRecorderPlayer = new AudioRecorderPlayer();

const App()=>{}