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.
@@ -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
- CFTimeInterval _recordingStartTime;
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
- 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);
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
- // Use elapsed time instead of currentTime (which doesn't update reliably)
89
- CFTimeInterval elapsedSeconds = CACurrentMediaTime() - self->_recordingStartTime;
82
+ // Calculate elapsed time from recording start using NSDate
83
+ NSTimeInterval elapsedSeconds = [[NSDate date] timeIntervalSinceReferenceDate] - self->_recordingStartTime;
90
84
  double durationMs = elapsedSeconds * 1000;
91
- NSLog(@"[NosniaAudioRecorder] Duration: elapsed=%f seconds, durationMs=%f milliseconds (hasListeners=%d)",
92
- elapsedSeconds, durationMs, self->_hasListeners);
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 = CACurrentMediaTime(); // Record start time when recording actually starts
410
+ _recordingStartTime = [[NSDate date] timeIntervalSinceReferenceDate];
420
411
  [self startProgressTimer];
421
412
  resolve(nil);
422
413
  } @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.9",
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",