nosnia-audio-recorder 0.7.5 → 0.7.6

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.
@@ -77,12 +77,25 @@ RCT_EXPORT_MODULE(NosniaAudioRecorder)
77
77
  NSString *recordingDir = [documentDir stringByAppendingPathComponent:@"NosniaAudioRecorder"];
78
78
 
79
79
  NSFileManager *fileManager = [NSFileManager defaultManager];
80
+ NSError *dirError = nil;
81
+
80
82
  if (![fileManager fileExistsAtPath:recordingDir]) {
81
- [fileManager createDirectoryAtPath:recordingDir
83
+ BOOL created = [fileManager createDirectoryAtPath:recordingDir
82
84
  withIntermediateDirectories:YES
83
85
  attributes:nil
84
- error:nil];
86
+ error:&dirError];
87
+ if (!created || dirError) {
88
+ NSLog(@"Failed to create recording directory: %@", dirError.description);
89
+ return nil;
90
+ }
85
91
  }
92
+
93
+ // Verify directory is writable
94
+ if (![fileManager isWritableFileAtPath:recordingDir]) {
95
+ NSLog(@"Recording directory is not writable: %@", recordingDir);
96
+ return nil;
97
+ }
98
+
86
99
  return recordingDir;
87
100
  }
88
101
 
@@ -265,10 +278,25 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
265
278
  _audioRecorder.delegate = self;
266
279
  [_audioRecorder setMeteringEnabled:YES];
267
280
 
268
- // Attempt to start recording
269
- if (![_audioRecorder record]) {
270
- NSString *errorMsg = @"Failed to start recording";
271
- reject(@"START_RECORDING_ERROR", errorMsg, nil);
281
+ // Attempt to start recording with detailed error checking
282
+ NSError *recordStartError = nil;
283
+ BOOL recordStarted = NO;
284
+
285
+ // Try to prepare recorder first
286
+ if (![_audioRecorder prepareToRecord]) {
287
+ reject(@"PREPARE_ERROR", @"Failed to prepare audio recorder for recording", nil);
288
+ _audioRecorder = nil;
289
+ return;
290
+ }
291
+
292
+ recordStarted = [_audioRecorder record];
293
+ if (!recordStarted) {
294
+ NSString *errorMsg = [NSString stringWithFormat:
295
+ @"Failed to start recording. Recorder state: %ld, URL: %@, Settings: %@",
296
+ (long)_audioRecorder.recording,
297
+ _recordingURL,
298
+ _audioRecorder.settings];
299
+ reject(@"START_RECORDING_ERROR", errorMsg, recordStartError);
272
300
  _audioRecorder = nil;
273
301
  return;
274
302
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nosnia-audio-recorder",
3
- "version": "0.7.5",
3
+ "version": "0.7.6",
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",