nosnia-audio-recorder 0.8.7 → 0.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -35,19 +35,27 @@ class NosniaAudioRecorderModule(private val reactContext: ReactApplicationContex
|
|
|
35
35
|
private val progressHandler = Handler(Looper.getMainLooper())
|
|
36
36
|
private val progressRunnable = object : Runnable {
|
|
37
37
|
override fun run() {
|
|
38
|
-
if (isRecording && !isPaused) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
if (isRecording && !isPaused && mediaRecorder != null) {
|
|
39
|
+
try {
|
|
40
|
+
// Use actual MediaRecorder max amplitude for duration tracking
|
|
41
|
+
// Android MediaRecorder doesn't expose duration while recording,
|
|
42
|
+
// so we calculate elapsed time from start
|
|
43
|
+
val currentTime = System.currentTimeMillis()
|
|
44
|
+
val duration = currentTime - startTime - pausedDuration
|
|
45
|
+
|
|
46
|
+
sendEvent("onRecordingProgress", Arguments.createMap().apply {
|
|
47
|
+
putDouble("duration", duration.toDouble())
|
|
48
|
+
putBoolean("isRecording", true)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
progressHandler.postDelayed(this, 100) // Update every 100ms
|
|
52
|
+
} catch (e: Exception) {
|
|
53
|
+
// Continue despite errors
|
|
54
|
+
progressHandler.postDelayed(this, 100)
|
|
55
|
+
}
|
|
48
56
|
}
|
|
49
57
|
}
|
|
50
|
-
|
|
58
|
+
}
|
|
51
59
|
private fun sendEvent(eventName: String, params: WritableMap?) {
|
|
52
60
|
reactContext
|
|
53
61
|
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
@@ -57,6 +65,7 @@ class NosniaAudioRecorderModule(private val reactContext: ReactApplicationContex
|
|
|
57
65
|
private fun startProgressUpdates() {
|
|
58
66
|
startTime = System.currentTimeMillis()
|
|
59
67
|
pausedDuration = 0
|
|
68
|
+
// Send initial progress update immediately
|
|
60
69
|
progressHandler.post(progressRunnable)
|
|
61
70
|
}
|
|
62
71
|
|
package/package.json
CHANGED