Skip to content
This repository has been archived by the owner on Aug 21, 2020. It is now read-only.

Fix for Android 8.1 - release MediaRecorder when stop fails. #309

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public void checkAuthorizationStatus(Promise promise) {
public void prepareRecordingAtPath(String recordingPath, ReadableMap recordingSettings, Promise promise) {
if (isRecording){
logAndRejectPromise(promise, "INVALID_STATE", "Please call stopRecording before starting recording");
return;
}
File destFile = new File(recordingPath);
if (destFile.getParentFile() != null) {
Expand Down Expand Up @@ -223,6 +224,9 @@ public void stopRecording(Promise promise){
stopWatch.stop();
}
catch (final RuntimeException e) {
try {
recorder.release();
} catch (final Exception e2) { }
// https://developer.android.com/reference/android/media/MediaRecorder.html#stop()
logAndRejectPromise(promise, "RUNTIME_EXCEPTION", "No valid audio data received. You may be using a device that can't record audio.");
return;
Expand Down