nosnia-audio-recorder 0.9.8 → 0.9.9
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/ios/NosniaAudioRecorder.mm +10 -19
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#import "NosniaAudioRecorder.h"
|
|
2
2
|
#import <AVFoundation/AVFoundation.h>
|
|
3
|
-
#import <QuartzCore/QuartzCore.h>
|
|
4
3
|
#import <React/RCTBridgeModule.h>
|
|
5
4
|
#import <React/RCTEventEmitter.h>
|
|
6
5
|
#import <React/RCTLog.h>
|
|
@@ -18,7 +17,8 @@
|
|
|
18
17
|
BOOL _isRecording;
|
|
19
18
|
NSTimer *_progressTimer;
|
|
20
19
|
BOOL _hasListeners;
|
|
21
|
-
|
|
20
|
+
NSTimeInterval _recordingStartTime;
|
|
21
|
+
NSTimeInterval _pausedDuration;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
RCT_EXPORT_MODULE(NosniaAudioRecorder)
|
|
@@ -62,34 +62,28 @@ RCT_EXPORT_MODULE(NosniaAudioRecorder)
|
|
|
62
62
|
|
|
63
63
|
// Send initial duration event immediately (should be very close to 0)
|
|
64
64
|
if (_audioRecorder && _isRecording) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
elapsedSeconds, durationMs, _hasListeners);
|
|
65
|
+
double durationMs = 0.0;
|
|
66
|
+
NSLog(@"[NosniaAudioRecorder] Sending initial progress: duration=%f ms (hasListeners=%d)",
|
|
67
|
+
durationMs, _hasListeners);
|
|
69
68
|
|
|
70
69
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
71
|
-
NSLog(@"[NosniaAudioRecorder] About to send initial event on main thread");
|
|
72
70
|
[self sendEventWithName:@"onRecordingProgress"
|
|
73
71
|
body:@{
|
|
74
72
|
@"duration": @(durationMs),
|
|
75
73
|
@"isRecording": @(self->_audioRecorder.isRecording)
|
|
76
74
|
}];
|
|
77
|
-
NSLog(@"[NosniaAudioRecorder] Initial event sent (hasListeners=%d)", self->_hasListeners);
|
|
78
75
|
});
|
|
79
76
|
}
|
|
80
77
|
|
|
81
78
|
_progressTimer = [NSTimer scheduledTimerWithTimeInterval:0.1
|
|
82
79
|
repeats:YES
|
|
83
80
|
block:^(NSTimer * _Nonnull timer) {
|
|
84
|
-
NSLog(@"[NosniaAudioRecorder] Progress timer fired - hasListeners: %d, audioRecorder: %@, isRecording: %d",
|
|
85
|
-
self->_hasListeners, self->_audioRecorder ? @"yes" : @"no", self->_isRecording);
|
|
86
|
-
|
|
87
81
|
if (self->_audioRecorder && self->_isRecording) {
|
|
88
|
-
//
|
|
89
|
-
|
|
82
|
+
// Calculate elapsed time from recording start using NSDate
|
|
83
|
+
NSTimeInterval elapsedSeconds = [[NSDate date] timeIntervalSinceReferenceDate] - self->_recordingStartTime;
|
|
90
84
|
double durationMs = elapsedSeconds * 1000;
|
|
91
|
-
|
|
92
|
-
|
|
85
|
+
|
|
86
|
+
NSLog(@"[NosniaAudioRecorder] Duration: elapsed=%f seconds, durationMs=%f ms", elapsedSeconds, durationMs);
|
|
93
87
|
|
|
94
88
|
// Ensure event is sent on main thread
|
|
95
89
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
@@ -99,9 +93,6 @@ RCT_EXPORT_MODULE(NosniaAudioRecorder)
|
|
|
99
93
|
@"isRecording": @(self->_audioRecorder.isRecording)
|
|
100
94
|
}];
|
|
101
95
|
});
|
|
102
|
-
} else {
|
|
103
|
-
NSLog(@"[NosniaAudioRecorder] Skipping event: audioRecorder=%@, isRecording=%d",
|
|
104
|
-
self->_audioRecorder ? @"yes" : @"no", self->_isRecording);
|
|
105
96
|
}
|
|
106
97
|
}];
|
|
107
98
|
}
|
|
@@ -416,7 +407,7 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
|
|
|
416
407
|
NSLog(@"[NosniaAudioRecorder] Recording started successfully");
|
|
417
408
|
|
|
418
409
|
_isRecording = YES;
|
|
419
|
-
_recordingStartTime =
|
|
410
|
+
_recordingStartTime = [[NSDate date] timeIntervalSinceReferenceDate];
|
|
420
411
|
[self startProgressTimer];
|
|
421
412
|
resolve(nil);
|
|
422
413
|
} @catch (NSException *innerException) {
|
package/package.json
CHANGED