nosnia-audio-recorder 0.9.8 → 0.9.10

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.
@@ -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,7 @@
18
17
  BOOL _isRecording;
19
18
  NSTimer *_progressTimer;
20
19
  BOOL _hasListeners;
21
- CFTimeInterval _recordingStartTime;
20
+ double _elapsedTimeMs;
22
21
  }
23
22
 
24
23
  RCT_EXPORT_MODULE(NosniaAudioRecorder)
@@ -57,51 +56,35 @@ RCT_EXPORT_MODULE(NosniaAudioRecorder)
57
56
  }
58
57
 
59
58
  NSLog(@"[NosniaAudioRecorder] Starting progress timer");
60
- NSLog(@"[NosniaAudioRecorder] hasListeners: %d, isRecording: %d, audioRecorder: %@",
61
- _hasListeners, _isRecording, _audioRecorder ? @"YES" : @"NO");
59
+ _elapsedTimeMs = 0.0;
62
60
 
63
- // Send initial duration event immediately (should be very close to 0)
61
+ // Send initial duration event immediately
64
62
  if (_audioRecorder && _isRecording) {
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);
69
-
70
63
  dispatch_async(dispatch_get_main_queue(), ^{
71
- NSLog(@"[NosniaAudioRecorder] About to send initial event on main thread");
72
64
  [self sendEventWithName:@"onRecordingProgress"
73
65
  body:@{
74
- @"duration": @(durationMs),
66
+ @"duration": @(0.0),
75
67
  @"isRecording": @(self->_audioRecorder.isRecording)
76
68
  }];
77
- NSLog(@"[NosniaAudioRecorder] Initial event sent (hasListeners=%d)", self->_hasListeners);
78
69
  });
79
70
  }
80
71
 
81
72
  _progressTimer = [NSTimer scheduledTimerWithTimeInterval:0.1
82
73
  repeats:YES
83
74
  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
75
  if (self->_audioRecorder && self->_isRecording) {
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);
76
+ // Simply increment by 100ms (the interval)
77
+ self->_elapsedTimeMs += 100.0;
78
+
79
+ NSLog(@"[NosniaAudioRecorder] Sending duration: %.0f ms", self->_elapsedTimeMs);
93
80
 
94
- // Ensure event is sent on main thread
95
81
  dispatch_async(dispatch_get_main_queue(), ^{
96
82
  [self sendEventWithName:@"onRecordingProgress"
97
83
  body:@{
98
- @"duration": @(durationMs),
84
+ @"duration": @(self->_elapsedTimeMs),
99
85
  @"isRecording": @(self->_audioRecorder.isRecording)
100
86
  }];
101
87
  });
102
- } else {
103
- NSLog(@"[NosniaAudioRecorder] Skipping event: audioRecorder=%@, isRecording=%d",
104
- self->_audioRecorder ? @"yes" : @"no", self->_isRecording);
105
88
  }
106
89
  }];
107
90
  }
@@ -111,7 +94,6 @@ RCT_EXPORT_MODULE(NosniaAudioRecorder)
111
94
  [_progressTimer invalidate];
112
95
  _progressTimer = nil;
113
96
  }
114
- _recordingStartTime = 0; // Reset start time
115
97
  }
116
98
 
117
99
  - (NSString *)getRecordingDirectory {
@@ -416,7 +398,6 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
416
398
  NSLog(@"[NosniaAudioRecorder] Recording started successfully");
417
399
 
418
400
  _isRecording = YES;
419
- _recordingStartTime = CACurrentMediaTime(); // Record start time when recording actually starts
420
401
  [self startProgressTimer];
421
402
  resolve(nil);
422
403
  } @catch (NSException *innerException) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nosnia-audio-recorder",
3
- "version": "0.9.8",
3
+ "version": "0.9.10",
4
4
  "description": "This is a modern audio recorder which actually works cross platform",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",