Closed ameenmattar closed 6 years ago
same as https://github.com/kevinresol/react-native-sound-recorder/issues/8?
well no, #8 crashes at start()
but that doesn't make sense. setAudioSource only happens in start()
did you request for the permission at runtime?
@kevinresol Yes i have requested for the permission at runtime and added this permission to the AndroidManifest :
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Can you show the code for the run time permission request?
Here's my run time permission request code:
async function requestMicrophonePermission() {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
{
title: "Requesting Microphone Access",
message: "App needs permission to access to your microphone "
}
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log("You can use the microphone");
} else {
console.log("Microphone permission denied");
alert("Microphone permission denied");
}
} catch (err) {
console.warn(err);
}
}
but that doesn't make sense. setAudioSource only happens in start()
are you sure the crash happens at stop()
?
What is your android version and phone model btw?
Yes it seems to happen on stop(), and even if its on start() #8 didn't solve my problem because i have added the permission and nothing changed. The android version "27.0.3" The phone model : Samsung S8
Can you try <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
and request the permission at runtime too?
I have already include these too
_ANDROID_STUDIO :_
_JSCODE:
And here is the Code for Recording:
async _onMicroPress() {
await requestMicrophonePermission();
await requestStoragePermission();
SoundRecorder.start(SoundRecorder.PATH_CACHE + "/test.mp4").then(
function() {
console.log("started recording");
}
);
}
_onMicroRelease = () => {
SoundRecorder.stop().then(function(result) {
console.log("stopped recording, audio file saved at: ", result.path);
this.onSendFile(result.path, "test.mp4", "audio/mpeg");
});
};
To be honest I don't have any idea at the moment
Hey, Thanks for the support. I found a fix for this issue. basically its something related to the android only and the "MediaRecorder" class. PR #11
@ameenmattar can you try again with v1.3.1 (merged #11)?
I assume it is fixed
Thank you for this amazing library @kevinresol , but i am facing some problems: The app crashes when on SoundRecorder.stop() works fine on iOS but crashes on Android, i have included the android permission in the AndroidManifest as you mentioned :
<uses-permission android:name="android.permission.RECORD_AUDIO" />
And here is the code for SoundRecorder.stop():
The Error i get is described in the below image:
Thank you in advance