hyochan / react-native-audio-recorder-player

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

audioRecorderPlayer.stopRecorder() not functioning properly #604

Closed Iamfavur closed 1 month ago

Iamfavur commented 1 month 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.

Version of react-native-audio-recorder-player = 3.6.7

Version of React Native = 0.73.0

Platforms you faced the error (IOS or Android or both?) = both

Expected behavior = should have stopped the recording

Actual behavior = it showed that the recording has stopped but it kept on recording in the background

Steps to reproduce the behavior

Iamfavur commented 1 month 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.

Version of react-native-audio-recorder-player = 3.6.7

Version of React Native = 0.73.0

Platforms you faced the error (IOS or Android or both?) = both

Expected behavior = should have stopped the recording

Actual behavior = it showed that the recording has stopped but it kept on recording in the background

Steps to reproduce the behavior

i have solved it i manage to solve it by going to the "react-native-audio-recorder-player" folder in my dependencies folder (node_modules for npm) and locating the index.ts file in it, then i looked for the stopRecorder function and made the following changes

BEFORE stopRecorder = async (): Promise => { if (this._isRecording) { this._isRecording = false; this._hasPausedRecord = false;

  return RNAudioRecorderPlayer.stopRecorder();
}

return 'Already stopped';  

};

AFTER stopRecorder = async (): Promise => { if (this._isRecording) { this._isRecording = false; this._hasPausedRecord = false;

  return RNAudioRecorderPlayer.stopRecorder();
}

return RNAudioRecorderPlayer.stopRecorder(); 

};

i replaced the "return 'Already stopped'; " with the " return RNAudioRecorderPlayer.stopRecorder(); " so now it works properly. NOTE: this wont cause any error for my project cause i am also rendering it with a condition. so from the above i think it was not working properly initially because the "this._isRecording" was false so it couldn't return the RNAudioRecorderPlayer.stopRecorder(), and it should have been true for the .. so i think they need to look into it.

Iamfavur commented 1 month ago

Update!!!! i now realize where the main issue itself is coming from. i should have defined the constant of audio player outside the component. like this >>

import.... const audioRecorderPlayer = new AudioRecorderPlayer();

const App()=>{}