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.
@@ -189,11 +189,11 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
189
189
  return;
190
190
  }
191
191
 
192
- // Set audio category - use Record category with DuckOthers only
193
- // Note: DefaultToSpeaker is NOT compatible with Record category
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 = AVAudioSessionCategoryOptionDuckOthers;
196
- BOOL categorySuccess = [audioSession setCategory:AVAudioSessionCategoryRecord
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 Record with DuckOthers");
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
- NSString *errorMsg = [NSString stringWithFormat:
321
- @"Failed to start recording. Recorder state: %ld, URL: %@, Settings: %@",
322
- (long)_audioRecorder.recording,
323
- _recordingURL,
324
- _audioRecorder.settings];
325
- reject(@"START_RECORDING_ERROR", errorMsg, recordStartError);
326
- _audioRecorder = nil;
327
- return;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nosnia-audio-recorder",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
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",