nosnia-audio-recorder 0.7.4 → 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.
- package/ios/NosniaAudioRecorder.mm +35 -7
- package/package.json +1 -1
|
@@ -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
|
|
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
|
|
|
@@ -90,7 +103,7 @@ RCT_EXPORT_MODULE(NosniaAudioRecorder)
|
|
|
90
103
|
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
|
|
91
104
|
[formatter setDateFormat:@"yyyyMMdd_HHmmss"];
|
|
92
105
|
NSString *timestamp = [formatter stringFromDate:[NSDate date]];
|
|
93
|
-
return [NSString stringWithFormat:@"recording_%@.
|
|
106
|
+
return [NSString stringWithFormat:@"recording_%@.wav", timestamp];
|
|
94
107
|
}
|
|
95
108
|
|
|
96
109
|
RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
|
|
@@ -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
|
-
|
|
270
|
-
|
|
271
|
-
|
|
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