nosnia-audio-recorder 0.8.8 → 0.9.0
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.
- package/android/src/main/java/com/nosniaaudiorecorder/NosniaAudioRecorderModule.kt +13 -6
- package/ios/NosniaAudioRecorder.mm +12 -0
- package/lib/module/index.js +23 -2
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +29 -7
|
@@ -43,6 +43,8 @@ class NosniaAudioRecorderModule(private val reactContext: ReactApplicationContex
|
|
|
43
43
|
val currentTime = System.currentTimeMillis()
|
|
44
44
|
val duration = currentTime - startTime - pausedDuration
|
|
45
45
|
|
|
46
|
+
android.util.Log.d("NosniaAudioRecorder", "Progress: duration=$duration, isRecording=true")
|
|
47
|
+
|
|
46
48
|
sendEvent("onRecordingProgress", Arguments.createMap().apply {
|
|
47
49
|
putDouble("duration", duration.toDouble())
|
|
48
50
|
putBoolean("isRecording", true)
|
|
@@ -50,19 +52,24 @@ class NosniaAudioRecorderModule(private val reactContext: ReactApplicationContex
|
|
|
50
52
|
|
|
51
53
|
progressHandler.postDelayed(this, 100) // Update every 100ms
|
|
52
54
|
} catch (e: Exception) {
|
|
55
|
+
android.util.Log.e("NosniaAudioRecorder", "Error in progress callback: ${e.message}", e)
|
|
53
56
|
// Continue despite errors
|
|
54
57
|
progressHandler.postDelayed(this, 100)
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
|
-
private fun sendEvent(eventName: String, params: WritableMap?) {
|
|
60
|
-
reactContext
|
|
61
|
-
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
62
|
-
.emit(eventName, params)
|
|
63
|
-
}
|
|
64
62
|
|
|
65
|
-
private fun
|
|
63
|
+
private fun sendEvent(eventName: String, params: WritableMap?) {
|
|
64
|
+
try {
|
|
65
|
+
reactContext
|
|
66
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
67
|
+
.emit(eventName, params)
|
|
68
|
+
} catch (e: Exception) {
|
|
69
|
+
android.util.Log.e("NosniaAudioRecorder", "Error sending event $eventName: ${e.message}", e)
|
|
70
|
+
}
|
|
71
|
+
} private fun startProgressUpdates() {
|
|
72
|
+
android.util.Log.d("NosniaAudioRecorder", "Starting progress updates")
|
|
66
73
|
startTime = System.currentTimeMillis()
|
|
67
74
|
pausedDuration = 0
|
|
68
75
|
// Send initial progress update immediately
|
|
@@ -34,10 +34,12 @@ RCT_EXPORT_MODULE(NosniaAudioRecorder)
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
- (void)startObserving {
|
|
37
|
+
NSLog(@"[NosniaAudioRecorder] startObserving called - listeners enabled");
|
|
37
38
|
_hasListeners = YES;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
- (void)stopObserving {
|
|
42
|
+
NSLog(@"[NosniaAudioRecorder] stopObserving called - listeners disabled");
|
|
41
43
|
_hasListeners = NO;
|
|
42
44
|
}
|
|
43
45
|
|
|
@@ -45,17 +47,27 @@ RCT_EXPORT_MODULE(NosniaAudioRecorder)
|
|
|
45
47
|
if (_progressTimer) {
|
|
46
48
|
[_progressTimer invalidate];
|
|
47
49
|
}
|
|
50
|
+
|
|
51
|
+
NSLog(@"[NosniaAudioRecorder] Starting progress timer");
|
|
48
52
|
|
|
49
53
|
_progressTimer = [NSTimer scheduledTimerWithTimeInterval:0.1
|
|
50
54
|
repeats:YES
|
|
51
55
|
block:^(NSTimer * _Nonnull timer) {
|
|
56
|
+
NSLog(@"[NosniaAudioRecorder] Progress timer fired - hasListeners: %d, audioRecorder: %@, isRecording: %d",
|
|
57
|
+
self->_hasListeners, self->_audioRecorder ? @"yes" : @"no", self->_isRecording);
|
|
58
|
+
|
|
52
59
|
if (self->_hasListeners && self->_audioRecorder && self->_isRecording) {
|
|
53
60
|
NSTimeInterval currentTime = self->_audioRecorder.currentTime;
|
|
61
|
+
NSLog(@"[NosniaAudioRecorder] Sending progress: duration=%f ms", currentTime * 1000);
|
|
62
|
+
|
|
54
63
|
[self sendEventWithName:@"onRecordingProgress"
|
|
55
64
|
body:@{
|
|
56
65
|
@"duration": @(currentTime * 1000),
|
|
57
66
|
@"isRecording": @(self->_audioRecorder.isRecording)
|
|
58
67
|
}];
|
|
68
|
+
} else {
|
|
69
|
+
NSLog(@"[NosniaAudioRecorder] Skipping event: hasListeners=%d, audioRecorder=%@, isRecording=%d",
|
|
70
|
+
self->_hasListeners, self->_audioRecorder ? @"yes" : @"no", self->_isRecording);
|
|
59
71
|
}
|
|
60
72
|
}];
|
|
61
73
|
}
|
package/lib/module/index.js
CHANGED
|
@@ -6,7 +6,14 @@ class AudioRecorder {
|
|
|
6
6
|
static instance = null;
|
|
7
7
|
progressListener = null;
|
|
8
8
|
constructor() {
|
|
9
|
-
|
|
9
|
+
console.log('[AudioRecorder] Initializing AudioRecorder');
|
|
10
|
+
const nativeModule = NativeModules.NosniaAudioRecorder;
|
|
11
|
+
console.log('[AudioRecorder] NativeModules.NosniaAudioRecorder:', nativeModule ? 'exists' : 'NOT FOUND');
|
|
12
|
+
if (!nativeModule) {
|
|
13
|
+
throw new Error('NosniaAudioRecorder native module not found');
|
|
14
|
+
}
|
|
15
|
+
this.eventEmitter = new NativeEventEmitter(nativeModule);
|
|
16
|
+
console.log('[AudioRecorder] NativeEventEmitter created');
|
|
10
17
|
}
|
|
11
18
|
static getInstance() {
|
|
12
19
|
if (!AudioRecorder.instance) {
|
|
@@ -21,12 +28,26 @@ class AudioRecorder {
|
|
|
21
28
|
* @returns Function to remove the listener
|
|
22
29
|
*/
|
|
23
30
|
addRecordingProgressListener(callback) {
|
|
31
|
+
// Log for debugging
|
|
32
|
+
console.log('[AudioRecorder] Adding recording progress listener');
|
|
33
|
+
|
|
24
34
|
// Remove existing listener if any
|
|
25
35
|
if (this.progressListener) {
|
|
36
|
+
console.log('[AudioRecorder] Removing existing listener');
|
|
26
37
|
this.progressListener.remove();
|
|
38
|
+
this.progressListener = null;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
this.progressListener = this.eventEmitter.addListener('onRecordingProgress', data => {
|
|
42
|
+
console.log('[AudioRecorder] Progress event received:', data);
|
|
43
|
+
callback(data);
|
|
44
|
+
});
|
|
45
|
+
console.log('[AudioRecorder] Listener added successfully');
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error('[AudioRecorder] Error adding listener:', error);
|
|
27
48
|
}
|
|
28
|
-
this.progressListener = this.eventEmitter.addListener('onRecordingProgress', data => callback(data));
|
|
29
49
|
return () => {
|
|
50
|
+
console.log('[AudioRecorder] Removing listener via cleanup function');
|
|
30
51
|
if (this.progressListener) {
|
|
31
52
|
this.progressListener.remove();
|
|
32
53
|
this.progressListener = null;
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","NativeModules","NativeModule","AudioRecorder","instance","progressListener","constructor","
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","NativeModules","NativeModule","AudioRecorder","instance","progressListener","constructor","console","log","nativeModule","NosniaAudioRecorder","Error","eventEmitter","getInstance","addRecordingProgressListener","callback","remove","addListener","data","error","removeRecordingProgressListener","requestPermission","requestAudioPermission","checkPermission","checkAudioPermission","startRecording","options","hasPermission","config","bitrate","channels","sampleRate","stopRecording","pauseRecording","resumeRecording","cancelRecording","getStatus","getRecorderStatus","NosniaAudioPlayer"],"sourceRoot":"..\\..\\src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAChE,OAAOC,YAAY,MAGZ,gCAA6B;AASpC,MAAMC,aAAa,CAAC;EAClB,OAAeC,QAAQ,GAAyB,IAAI;EAE5CC,gBAAgB,GAAQ,IAAI;EAE5BC,WAAWA,CAAA,EAAG;IACpBC,OAAO,CAACC,GAAG,CAAC,4CAA4C,CAAC;IAEzD,MA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CAAC,CAAC;IAC/C,CAAC,CAAC,OAAOlB,KAAK,EAAE;MACdZ,OAAO,CAACY,KAAK,CAAC,gCAAgC,EAAEA,KAAK,CAAC;MACtD,MAAMA,KAAK;IACb;EACF;AACF;AAEA,OAAO,MAAMT,mBAAmB,GAAGP,aAAa,CAACU,WAAW,CAAC,CAAC;;AAE9D;AACA,SACEyB,iBAAiB,QAKZ,kBAAe","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAqB,EACnB,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,6BAA6B,CAAC;AAErC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC;AAEhD,MAAM,MAAM,yBAAyB,GAAG,CAAC,IAAI,EAAE;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB,KAAK,IAAI,CAAC;AAEX,cAAM,aAAa;IACjB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA8B;IACrD,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,gBAAgB,CAAa;IAErC,OAAO;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAqB,EACnB,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,6BAA6B,CAAC;AAErC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC;AAEhD,MAAM,MAAM,yBAAyB,GAAG,CAAC,IAAI,EAAE;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB,KAAK,IAAI,CAAC;AAEX,cAAM,aAAa;IACjB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA8B;IACrD,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,gBAAgB,CAAa;IAErC,OAAO;IAcP,MAAM,CAAC,WAAW,IAAI,aAAa;IAOnC;;;;OAIG;IACH,4BAA4B,CAC1B,QAAQ,EAAE,yBAAyB,GAClC,MAAM,IAAI;IAiCb;;OAEG;IACH,+BAA+B,IAAI,IAAI;IAOvC;;;OAGG;IACG,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;IAS3C;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IASzC;;;;OAIG;IACG,cAAc,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAuB9D;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAStC;;;OAGG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IASrC;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAStC;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAStC;;;OAGG;IACG,SAAS,IAAI,OAAO,CAAC,cAAc,CAAC;CAQ3C;AAED,eAAO,MAAM,mBAAmB,eAA8B,CAAC;AAG/D,OAAO,EACL,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,GAC9B,MAAM,eAAe,CAAC"}
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -17,9 +17,17 @@ class AudioRecorder {
|
|
|
17
17
|
private progressListener: any = null;
|
|
18
18
|
|
|
19
19
|
private constructor() {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
console.log('[AudioRecorder] Initializing AudioRecorder');
|
|
21
|
+
|
|
22
|
+
const nativeModule = NativeModules.NosniaAudioRecorder;
|
|
23
|
+
console.log('[AudioRecorder] NativeModules.NosniaAudioRecorder:', nativeModule ? 'exists' : 'NOT FOUND');
|
|
24
|
+
|
|
25
|
+
if (!nativeModule) {
|
|
26
|
+
throw new Error('NosniaAudioRecorder native module not found');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
this.eventEmitter = new NativeEventEmitter(nativeModule);
|
|
30
|
+
console.log('[AudioRecorder] NativeEventEmitter created');
|
|
23
31
|
}
|
|
24
32
|
|
|
25
33
|
static getInstance(): AudioRecorder {
|
|
@@ -37,17 +45,31 @@ class AudioRecorder {
|
|
|
37
45
|
addRecordingProgressListener(
|
|
38
46
|
callback: RecordingProgressCallback
|
|
39
47
|
): () => void {
|
|
48
|
+
// Log for debugging
|
|
49
|
+
console.log('[AudioRecorder] Adding recording progress listener');
|
|
50
|
+
|
|
40
51
|
// Remove existing listener if any
|
|
41
52
|
if (this.progressListener) {
|
|
53
|
+
console.log('[AudioRecorder] Removing existing listener');
|
|
42
54
|
this.progressListener.remove();
|
|
55
|
+
this.progressListener = null;
|
|
43
56
|
}
|
|
44
57
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
58
|
+
try {
|
|
59
|
+
this.progressListener = this.eventEmitter.addListener(
|
|
60
|
+
'onRecordingProgress',
|
|
61
|
+
(data: any) => {
|
|
62
|
+
console.log('[AudioRecorder] Progress event received:', data);
|
|
63
|
+
callback(data);
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
console.log('[AudioRecorder] Listener added successfully');
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.error('[AudioRecorder] Error adding listener:', error);
|
|
69
|
+
}
|
|
49
70
|
|
|
50
71
|
return () => {
|
|
72
|
+
console.log('[AudioRecorder] Removing listener via cleanup function');
|
|
51
73
|
if (this.progressListener) {
|
|
52
74
|
this.progressListener.remove();
|
|
53
75
|
this.progressListener = null;
|