kevinresol/react-native-sound-recorder

Sometimes Android crash on stop

kayzenkayzen opened this issue · 3 comments

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));

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

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?

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