nosnia-audio-recorder 0.9.9 → 0.9.11
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 +9 -17
- package/package.json +1 -1
|
@@ -17,8 +17,6 @@
|
|
|
17
17
|
BOOL _isRecording;
|
|
18
18
|
NSTimer *_progressTimer;
|
|
19
19
|
BOOL _hasListeners;
|
|
20
|
-
NSTimeInterval _recordingStartTime;
|
|
21
|
-
NSTimeInterval _pausedDuration;
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
RCT_EXPORT_MODULE(NosniaAudioRecorder)
|
|
@@ -57,19 +55,13 @@ RCT_EXPORT_MODULE(NosniaAudioRecorder)
|
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
NSLog(@"[NosniaAudioRecorder] Starting progress timer");
|
|
60
|
-
NSLog(@"[NosniaAudioRecorder] hasListeners: %d, isRecording: %d, audioRecorder: %@",
|
|
61
|
-
_hasListeners, _isRecording, _audioRecorder ? @"YES" : @"NO");
|
|
62
58
|
|
|
63
|
-
// Send initial duration event immediately
|
|
59
|
+
// Send initial duration event immediately
|
|
64
60
|
if (_audioRecorder && _isRecording) {
|
|
65
|
-
double durationMs = 0.0;
|
|
66
|
-
NSLog(@"[NosniaAudioRecorder] Sending initial progress: duration=%f ms (hasListeners=%d)",
|
|
67
|
-
durationMs, _hasListeners);
|
|
68
|
-
|
|
69
61
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
70
62
|
[self sendEventWithName:@"onRecordingProgress"
|
|
71
63
|
body:@{
|
|
72
|
-
@"duration": @(
|
|
64
|
+
@"duration": @(0.0),
|
|
73
65
|
@"isRecording": @(self->_audioRecorder.isRecording)
|
|
74
66
|
}];
|
|
75
67
|
});
|
|
@@ -79,13 +71,15 @@ RCT_EXPORT_MODULE(NosniaAudioRecorder)
|
|
|
79
71
|
repeats:YES
|
|
80
72
|
block:^(NSTimer * _Nonnull timer) {
|
|
81
73
|
if (self->_audioRecorder && self->_isRecording) {
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
|
|
74
|
+
// Update meters to ensure accurate currentTime reading
|
|
75
|
+
[self->_audioRecorder updateMeters];
|
|
76
|
+
|
|
77
|
+
// Use the recorder's currentTime directly - this is the reliable way
|
|
78
|
+
double durationMs = self->_audioRecorder.currentTime * 1000.0;
|
|
85
79
|
|
|
86
|
-
NSLog(@"[NosniaAudioRecorder] Duration:
|
|
80
|
+
NSLog(@"[NosniaAudioRecorder] Duration: %.0f ms (currentTime: %.4f seconds)",
|
|
81
|
+
durationMs, self->_audioRecorder.currentTime);
|
|
87
82
|
|
|
88
|
-
// Ensure event is sent on main thread
|
|
89
83
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
90
84
|
[self sendEventWithName:@"onRecordingProgress"
|
|
91
85
|
body:@{
|
|
@@ -102,7 +96,6 @@ RCT_EXPORT_MODULE(NosniaAudioRecorder)
|
|
|
102
96
|
[_progressTimer invalidate];
|
|
103
97
|
_progressTimer = nil;
|
|
104
98
|
}
|
|
105
|
-
_recordingStartTime = 0; // Reset start time
|
|
106
99
|
}
|
|
107
100
|
|
|
108
101
|
- (NSString *)getRecordingDirectory {
|
|
@@ -407,7 +400,6 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
|
|
|
407
400
|
NSLog(@"[NosniaAudioRecorder] Recording started successfully");
|
|
408
401
|
|
|
409
402
|
_isRecording = YES;
|
|
410
|
-
_recordingStartTime = [[NSDate date] timeIntervalSinceReferenceDate];
|
|
411
403
|
[self startProgressTimer];
|
|
412
404
|
resolve(nil);
|
|
413
405
|
} @catch (NSException *innerException) {
|
package/package.json
CHANGED