nosnia-audio-recorder 0.7.5 → 0.7.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 +45 -8
- 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
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Verify directory is writable
|
|
94
|
+
if (![fileManager isWritableFileAtPath:recordingDir]) {
|
|
95
|
+
NSLog(@"Recording directory is not writable: %@", recordingDir);
|
|
96
|
+
return nil;
|
|
85
97
|
}
|
|
98
|
+
|
|
86
99
|
return recordingDir;
|
|
87
100
|
}
|
|
88
101
|
|
|
@@ -196,9 +209,12 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
|
|
|
196
209
|
}
|
|
197
210
|
}
|
|
198
211
|
|
|
199
|
-
// Set audio mode to
|
|
212
|
+
// Set audio mode to default for recording
|
|
200
213
|
NSError *modeError = nil;
|
|
201
|
-
[audioSession setMode:
|
|
214
|
+
[audioSession setMode:AVAudioSessionModeDefault error:&modeError];
|
|
215
|
+
if (modeError) {
|
|
216
|
+
NSLog(@"Warning: Failed to set audio mode: %@", modeError.description);
|
|
217
|
+
}
|
|
202
218
|
|
|
203
219
|
// Activate audio session
|
|
204
220
|
NSError *activateError = nil;
|
|
@@ -265,13 +281,34 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
|
|
|
265
281
|
_audioRecorder.delegate = self;
|
|
266
282
|
[_audioRecorder setMeteringEnabled:YES];
|
|
267
283
|
|
|
268
|
-
// Attempt to start recording
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
284
|
+
// Attempt to start recording with detailed error checking
|
|
285
|
+
NSError *recordStartError = nil;
|
|
286
|
+
BOOL recordStarted = NO;
|
|
287
|
+
|
|
288
|
+
// Try to prepare recorder first
|
|
289
|
+
NSLog(@"[NosniaAudioRecorder] Preparing to record with settings: %@", _audioRecorder.settings);
|
|
290
|
+
if (![_audioRecorder prepareToRecord]) {
|
|
291
|
+
NSLog(@"[NosniaAudioRecorder] Failed to prepare audio recorder");
|
|
292
|
+
reject(@"PREPARE_ERROR", @"Failed to prepare audio recorder for recording", nil);
|
|
293
|
+
_audioRecorder = nil;
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
NSLog(@"[NosniaAudioRecorder] Recorder prepared successfully");
|
|
297
|
+
|
|
298
|
+
NSLog(@"[NosniaAudioRecorder] Attempting to start recording from URL: %@", _recordingURL);
|
|
299
|
+
recordStarted = [_audioRecorder record];
|
|
300
|
+
if (!recordStarted) {
|
|
301
|
+
NSLog(@"[NosniaAudioRecorder] Failed to start recording. Recorder is recording: %d", _audioRecorder.recording);
|
|
302
|
+
NSString *errorMsg = [NSString stringWithFormat:
|
|
303
|
+
@"Failed to start recording. Recorder state: %ld, URL: %@, Settings: %@",
|
|
304
|
+
(long)_audioRecorder.recording,
|
|
305
|
+
_recordingURL,
|
|
306
|
+
_audioRecorder.settings];
|
|
307
|
+
reject(@"START_RECORDING_ERROR", errorMsg, recordStartError);
|
|
272
308
|
_audioRecorder = nil;
|
|
273
309
|
return;
|
|
274
310
|
}
|
|
311
|
+
NSLog(@"[NosniaAudioRecorder] Recording started successfully");
|
|
275
312
|
|
|
276
313
|
_isRecording = YES;
|
|
277
314
|
[self startProgressTimer];
|
package/package.json
CHANGED