nosnia-audio-recorder 0.8.0 → 0.8.1

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.
@@ -234,14 +234,15 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
234
234
  // Create recording settings dictionary with safety checks
235
235
  @try {
236
236
  // Use MPEG4AAC format for MP3-compatible output
237
- // Creates .m4a files which are MP3-compatible and highly reliable
238
- NSDictionary *recordingSettings = @{
239
- AVFormatIDKey: @(kAudioFormatMPEG4AAC),
240
- AVSampleRateKey: sampleRate,
241
- AVNumberOfChannelsKey: channels,
242
- AVEncoderBitRateKey: bitrate,
243
- AVEncoderAudioQualityKey: @(AVAudioQualityHigh)
244
- };
237
+ // Only use essential keys that are universally supported
238
+ NSMutableDictionary *recordingSettings = [NSMutableDictionary dictionary];
239
+ [recordingSettings setObject:@(kAudioFormatMPEG4AAC) forKey:AVFormatIDKey];
240
+ [recordingSettings setObject:sampleRate forKey:AVSampleRateKey];
241
+ [recordingSettings setObject:channels forKey:AVNumberOfChannelsKey];
242
+ [recordingSettings setObject:bitrate forKey:AVEncoderBitRateKey];
243
+ [recordingSettings setObject:@(AVAudioQualityMedium) forKey:AVEncoderAudioQualityKey];
244
+
245
+ NSLog(@"[NosniaAudioRecorder] Recording settings: %@", recordingSettings);
245
246
 
246
247
  // Validate settings dictionary created successfully
247
248
  if (!recordingSettings || recordingSettings.count == 0) {
@@ -285,11 +286,36 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
285
286
 
286
287
  // Try to prepare recorder first
287
288
  NSLog(@"[NosniaAudioRecorder] Preparing to record with settings: %@", _audioRecorder.settings);
289
+ NSLog(@"[NosniaAudioRecorder] Recording URL: %@", _recordingURL);
290
+
288
291
  if (![_audioRecorder prepareToRecord]) {
289
- NSLog(@"[NosniaAudioRecorder] Failed to prepare audio recorder");
290
- reject(@"PREPARE_ERROR", @"Failed to prepare audio recorder for recording", nil);
291
- _audioRecorder = nil;
292
- return;
292
+ NSLog(@"[NosniaAudioRecorder] Failed to prepare audio recorder. Recorder: %@, Error: %@", _audioRecorder, _audioRecorder.deviceCurrentTime);
293
+ NSLog(@"[NosniaAudioRecorder] Recording settings that failed: Format=%@, SampleRate=%@, Channels=%@, Bitrate=%@",
294
+ _audioRecorder.settings[AVFormatIDKey],
295
+ _audioRecorder.settings[AVSampleRateKey],
296
+ _audioRecorder.settings[AVNumberOfChannelsKey],
297
+ _audioRecorder.settings[AVEncoderBitRateKey]);
298
+
299
+ // Try with fallback minimal settings
300
+ NSLog(@"[NosniaAudioRecorder] Attempting fallback with minimal settings");
301
+ NSDictionary *fallbackSettings = @{
302
+ AVFormatIDKey: @(kAudioFormatMPEG4AAC),
303
+ AVSampleRateKey: @(44100.0),
304
+ AVNumberOfChannelsKey: @(1),
305
+ AVEncoderBitRateKey: @(128000),
306
+ AVEncoderAudioQualityKey: @(AVAudioQualityMedium)
307
+ };
308
+
309
+ NSError *fallbackError = nil;
310
+ _audioRecorder = [[AVAudioRecorder alloc] initWithURL:_recordingURL
311
+ settings:fallbackSettings
312
+ error:&fallbackError];
313
+ if (fallbackError || ![_audioRecorder prepareToRecord]) {
314
+ NSLog(@"[NosniaAudioRecorder] Fallback also failed: %@", fallbackError);
315
+ reject(@"PREPARE_ERROR", @"Failed to prepare audio recorder for recording with both standard and fallback settings", nil);
316
+ _audioRecorder = nil;
317
+ return;
318
+ }
293
319
  }
294
320
  NSLog(@"[NosniaAudioRecorder] Recorder prepared successfully");
295
321
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nosnia-audio-recorder",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
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",