kevinresol / react-native-sound-recorder

Simplest Sound Recorder for React Native
MIT License
119 stars 36 forks source link

Sometimes Android crash on stop #36

Open kayzenkayzen opened 4 years ago

kayzenkayzen commented 4 years ago

Sometimes crash when stop recording with this error:

Fatal Exception: java.lang.NumberFormatException Invalid int: "null" com.kevinresol.react_native_sound_recorder.RNSoundRecorderModule.stop


For some reason, we are receiving null as duration, so parseInt expect an integer but receive null then crashes

int duration = Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));

kevinresol commented 4 years ago

That's weird, does the audio file actually exist?

kayzenkayzen commented 4 years ago

I suppose yes, since it only happens in some cases, anyway, I think that maybe it may have failed in start and I am also calling the stop in some case

Do you think that may be the problem? Are you sure that if the start was correct, the stop should never return that error?

kevinresol commented 4 years ago

Sorry for the late reply, but I recommend inserting some code on java side to ensure the file exists before grabbing its duration.