nosnia-audio-recorder 0.9.5 → 0.9.7
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 +16 -9
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#import "NosniaAudioRecorder.h"
|
|
2
2
|
#import <AVFoundation/AVFoundation.h>
|
|
3
|
+
#import <CoreMedia/CoreMedia.h>
|
|
3
4
|
#import <React/RCTBridgeModule.h>
|
|
4
5
|
#import <React/RCTEventEmitter.h>
|
|
5
6
|
#import <React/RCTLog.h>
|
|
@@ -17,6 +18,7 @@
|
|
|
17
18
|
BOOL _isRecording;
|
|
18
19
|
NSTimer *_progressTimer;
|
|
19
20
|
BOOL _hasListeners;
|
|
21
|
+
CFTimeInterval _recordingStartTime;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
RCT_EXPORT_MODULE(NosniaAudioRecorder)
|
|
@@ -58,17 +60,18 @@ RCT_EXPORT_MODULE(NosniaAudioRecorder)
|
|
|
58
60
|
NSLog(@"[NosniaAudioRecorder] hasListeners: %d, isRecording: %d, audioRecorder: %@",
|
|
59
61
|
_hasListeners, _isRecording, _audioRecorder ? @"YES" : @"NO");
|
|
60
62
|
|
|
61
|
-
// Send initial duration event immediately
|
|
63
|
+
// Send initial duration event immediately (should be very close to 0)
|
|
62
64
|
if (_audioRecorder && _isRecording) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
CFTimeInterval elapsedSeconds = CACurrentMediaTime() - _recordingStartTime;
|
|
66
|
+
double durationMs = elapsedSeconds * 1000;
|
|
67
|
+
NSLog(@"[NosniaAudioRecorder] Sending initial progress: elapsed=%f seconds, duration=%f ms (hasListeners=%d)",
|
|
68
|
+
elapsedSeconds, durationMs, _hasListeners);
|
|
66
69
|
|
|
67
70
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
68
71
|
NSLog(@"[NosniaAudioRecorder] About to send initial event on main thread");
|
|
69
72
|
[self sendEventWithName:@"onRecordingProgress"
|
|
70
73
|
body:@{
|
|
71
|
-
@"duration": @(
|
|
74
|
+
@"duration": @(durationMs),
|
|
72
75
|
@"isRecording": @(self->_audioRecorder.isRecording)
|
|
73
76
|
}];
|
|
74
77
|
NSLog(@"[NosniaAudioRecorder] Initial event sent (hasListeners=%d)", self->_hasListeners);
|
|
@@ -82,15 +85,17 @@ RCT_EXPORT_MODULE(NosniaAudioRecorder)
|
|
|
82
85
|
self->_hasListeners, self->_audioRecorder ? @"yes" : @"no", self->_isRecording);
|
|
83
86
|
|
|
84
87
|
if (self->_audioRecorder && self->_isRecording) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
// Use elapsed time instead of currentTime (which doesn't update reliably)
|
|
89
|
+
CFTimeInterval elapsedSeconds = CACurrentMediaTime() - self->_recordingStartTime;
|
|
90
|
+
double durationMs = elapsedSeconds * 1000;
|
|
91
|
+
NSLog(@"[NosniaAudioRecorder] Duration: elapsed=%f seconds, durationMs=%f milliseconds (hasListeners=%d)",
|
|
92
|
+
elapsedSeconds, durationMs, self->_hasListeners);
|
|
88
93
|
|
|
89
94
|
// Ensure event is sent on main thread
|
|
90
95
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
91
96
|
[self sendEventWithName:@"onRecordingProgress"
|
|
92
97
|
body:@{
|
|
93
|
-
@"duration": @(
|
|
98
|
+
@"duration": @(durationMs),
|
|
94
99
|
@"isRecording": @(self->_audioRecorder.isRecording)
|
|
95
100
|
}];
|
|
96
101
|
});
|
|
@@ -106,6 +111,7 @@ RCT_EXPORT_MODULE(NosniaAudioRecorder)
|
|
|
106
111
|
[_progressTimer invalidate];
|
|
107
112
|
_progressTimer = nil;
|
|
108
113
|
}
|
|
114
|
+
_recordingStartTime = 0; // Reset start time
|
|
109
115
|
}
|
|
110
116
|
|
|
111
117
|
- (NSString *)getRecordingDirectory {
|
|
@@ -410,6 +416,7 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
|
|
|
410
416
|
NSLog(@"[NosniaAudioRecorder] Recording started successfully");
|
|
411
417
|
|
|
412
418
|
_isRecording = YES;
|
|
419
|
+
_recordingStartTime = CACurrentMediaTime(); // Record start time when recording actually starts
|
|
413
420
|
[self startProgressTimer];
|
|
414
421
|
resolve(nil);
|
|
415
422
|
} @catch (NSException *innerException) {
|
package/package.json
CHANGED