Skip to content
This repository was archived by the owner on Aug 21, 2020. It is now read-only.
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
24 changes: 14 additions & 10 deletions android/src/main/java/com/rnim/rn/audio/AudioRecorderManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class AudioRecorderManager extends ReactContextBaseJavaModule {
private boolean isPaused = false;
private Timer timer;
private StopWatch stopWatch;

private boolean isPauseResumeCapable = false;
private Method pauseMethod = null;
private Method resumeMethod = null;
Expand All @@ -65,7 +65,7 @@ public AudioRecorderManager(ReactApplicationContext reactContext) {
super(reactContext);
this.context = reactContext;
stopWatch = new StopWatch();

isPauseResumeCapable = Build.VERSION.SDK_INT > Build.VERSION_CODES.M;
if (isPauseResumeCapable) {
try {
Expand Down Expand Up @@ -187,14 +187,18 @@ public void startRecording(Promise promise){
logAndRejectPromise(promise, "INVALID_STATE", "Please call stopRecording before starting recording");
return;
}
recorder.start();
try {
recorder.start();

stopWatch.reset();
stopWatch.start();
isRecording = true;
isPaused = false;
startTimer();
promise.resolve(currentOutputFile);
stopWatch.reset();
stopWatch.start();
isRecording = true;
isPaused = false;
startTimer();
promise.resolve(currentOutputFile);
} catch(Exception e) {
logAndRejectPromise(promise, "INVALID_STATE", "There was an error using your microphone");
}
}

@ReactMethod
Expand Down Expand Up @@ -270,7 +274,7 @@ public void resumeRecording(Promise promise) {
return;
}
}

isPaused = false;
promise.resolve(null);
}
Expand Down