Skip to content

Commit 142855e

Browse files
mschudtujas-m-simformsolutions
authored andcommitted
return null,-1 to prevent indefinite wait for stop call
1 parent a078074 commit 142855e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

android/src/main/kotlin/com/simform/audio_waveforms/AudioRecorder.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,25 @@ class AudioRecorder : PluginRegistry.RequestPermissionsResultListener {
6666

6767
fun stopRecording(result: MethodChannel.Result, recorder: MediaRecorder?, path: String) {
6868
try {
69-
var duration: String
69+
val audioInfoArrayList = ArrayList<String?>()
7070

7171
try {
7272
recorder?.stop()
73-
duration = getDuration(path)
73+
74+
val duration = getDuration(path)
75+
audioInfoArrayList.add(path)
76+
audioInfoArrayList.add(duration)
7477
} catch (e: RuntimeException) {
7578
// Stop was called immediately after start which causes stop() call to fail.
76-
duration = "-1"
79+
audioInfoArrayList.add(null)
80+
audioInfoArrayList.add("-1")
7781
}
7882

7983
recorder?.apply {
8084
reset()
8185
release()
8286
}
83-
val audioInfoArrayList = ArrayList<String>()
84-
audioInfoArrayList.add(path)
85-
audioInfoArrayList.add(duration)
87+
8688
result.success(audioInfoArrayList)
8789
} catch (e: IllegalStateException) {
8890
Log.e(LOG_TAG, "Failed to stop recording")

0 commit comments

Comments
 (0)