nosnia-audio-recorder 0.8.2 → 0.8.3
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 +26 -13
- package/package.json +1 -1
|
@@ -189,11 +189,11 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
|
|
|
189
189
|
return;
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
// Set audio category - use
|
|
193
|
-
//
|
|
192
|
+
// Set audio category - use PlayAndRecord for better simulator/device compatibility
|
|
193
|
+
// This works reliably on both real devices and simulators
|
|
194
194
|
NSError *categoryError = nil;
|
|
195
|
-
AVAudioSessionCategoryOptions options =
|
|
196
|
-
BOOL categorySuccess = [audioSession setCategory:
|
|
195
|
+
AVAudioSessionCategoryOptions options = AVAudioSessionCategoryOptionDefaultToSpeaker;
|
|
196
|
+
BOOL categorySuccess = [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord
|
|
197
197
|
withOptions:options
|
|
198
198
|
error:&categoryError];
|
|
199
199
|
if (!categorySuccess || categoryError) {
|
|
@@ -202,7 +202,7 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
|
|
|
202
202
|
reject(@"AUDIO_SESSION_ERROR", msg, categoryError);
|
|
203
203
|
return;
|
|
204
204
|
}
|
|
205
|
-
NSLog(@"[NosniaAudioRecorder] Audio category set to
|
|
205
|
+
NSLog(@"[NosniaAudioRecorder] Audio category set to PlayAndRecord with DefaultToSpeaker");
|
|
206
206
|
|
|
207
207
|
// Set audio mode to default for recording
|
|
208
208
|
NSError *modeError = nil;
|
|
@@ -317,14 +317,27 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
|
|
|
317
317
|
recordStarted = [_audioRecorder record];
|
|
318
318
|
if (!recordStarted) {
|
|
319
319
|
NSLog(@"[NosniaAudioRecorder] Failed to start recording. Recorder is recording: %d", _audioRecorder.recording);
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
320
|
+
|
|
321
|
+
// Try alternative: reset audio session and retry
|
|
322
|
+
NSLog(@"[NosniaAudioRecorder] Attempting recovery: resetting audio session");
|
|
323
|
+
NSError *resetError = nil;
|
|
324
|
+
[[AVAudioSession sharedInstance] setActive:NO error:&resetError];
|
|
325
|
+
|
|
326
|
+
NSError *reactivateError = nil;
|
|
327
|
+
[[AVAudioSession sharedInstance] setActive:YES error:&reactivateError];
|
|
328
|
+
|
|
329
|
+
// Retry recording once
|
|
330
|
+
recordStarted = [_audioRecorder record];
|
|
331
|
+
if (!recordStarted) {
|
|
332
|
+
NSString *errorMsg = [NSString stringWithFormat:
|
|
333
|
+
@"Failed to start recording after retry. Recorder state: %ld. This may be a simulator audio limitation. Try on a real device.",
|
|
334
|
+
(long)_audioRecorder.recording];
|
|
335
|
+
NSLog(@"[NosniaAudioRecorder] %@", errorMsg);
|
|
336
|
+
reject(@"START_RECORDING_ERROR", errorMsg, nil);
|
|
337
|
+
_audioRecorder = nil;
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
NSLog(@"[NosniaAudioRecorder] Recovery successful - recording started");
|
|
328
341
|
}
|
|
329
342
|
NSLog(@"[NosniaAudioRecorder] Recording started successfully");
|
|
330
343
|
|
package/package.json
CHANGED