nosnia-audio-recorder 0.7.6 → 0.8.0

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.
@@ -103,7 +103,7 @@ RCT_EXPORT_MODULE(NosniaAudioRecorder)
103
103
  NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
104
104
  [formatter setDateFormat:@"yyyyMMdd_HHmmss"];
105
105
  NSString *timestamp = [formatter stringFromDate:[NSDate date]];
106
- return [NSString stringWithFormat:@"recording_%@.wav", timestamp];
106
+ return [NSString stringWithFormat:@"recording_%@.m4a", timestamp];
107
107
  }
108
108
 
109
109
  RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
@@ -209,9 +209,12 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
209
209
  }
210
210
  }
211
211
 
212
- // Set audio mode to measurement for recording
212
+ // Set audio mode to default for recording
213
213
  NSError *modeError = nil;
214
- [audioSession setMode:AVAudioSessionModeMeasurement error:&modeError];
214
+ [audioSession setMode:AVAudioSessionModeDefault error:&modeError];
215
+ if (modeError) {
216
+ NSLog(@"Warning: Failed to set audio mode: %@", modeError.description);
217
+ }
215
218
 
216
219
  // Activate audio session
217
220
  NSError *activateError = nil;
@@ -230,15 +233,13 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
230
233
 
231
234
  // Create recording settings dictionary with safety checks
232
235
  @try {
233
- // Use Linear PCM as the most basic and universally supported format
234
- // iOS will handle audio encoding reliably with PCM
236
+ // Use MPEG4AAC format for MP3-compatible output
237
+ // Creates .m4a files which are MP3-compatible and highly reliable
235
238
  NSDictionary *recordingSettings = @{
236
- AVFormatIDKey: @(kAudioFormatLinearPCM),
239
+ AVFormatIDKey: @(kAudioFormatMPEG4AAC),
237
240
  AVSampleRateKey: sampleRate,
238
241
  AVNumberOfChannelsKey: channels,
239
- AVLinearPCMBitDepthKey: @(16),
240
- AVLinearPCMIsBigEndianKey: @(NO),
241
- AVLinearPCMIsNonInterleaved: @(NO),
242
+ AVEncoderBitRateKey: bitrate,
242
243
  AVEncoderAudioQualityKey: @(AVAudioQualityHigh)
243
244
  };
244
245
 
@@ -250,7 +251,7 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
250
251
 
251
252
  // Validate all required keys are present
252
253
  if (!recordingSettings[AVFormatIDKey] || !recordingSettings[AVSampleRateKey] ||
253
- !recordingSettings[AVNumberOfChannelsKey] || !recordingSettings[AVLinearPCMBitDepthKey]) {
254
+ !recordingSettings[AVNumberOfChannelsKey] || !recordingSettings[AVEncoderBitRateKey]) {
254
255
  reject(@"SETTINGS_ERROR", @"Incomplete recording settings", nil);
255
256
  return;
256
257
  }
@@ -283,14 +284,19 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
283
284
  BOOL recordStarted = NO;
284
285
 
285
286
  // Try to prepare recorder first
287
+ NSLog(@"[NosniaAudioRecorder] Preparing to record with settings: %@", _audioRecorder.settings);
286
288
  if (![_audioRecorder prepareToRecord]) {
289
+ NSLog(@"[NosniaAudioRecorder] Failed to prepare audio recorder");
287
290
  reject(@"PREPARE_ERROR", @"Failed to prepare audio recorder for recording", nil);
288
291
  _audioRecorder = nil;
289
292
  return;
290
293
  }
294
+ NSLog(@"[NosniaAudioRecorder] Recorder prepared successfully");
291
295
 
296
+ NSLog(@"[NosniaAudioRecorder] Attempting to start recording from URL: %@", _recordingURL);
292
297
  recordStarted = [_audioRecorder record];
293
298
  if (!recordStarted) {
299
+ NSLog(@"[NosniaAudioRecorder] Failed to start recording. Recorder is recording: %d", _audioRecorder.recording);
294
300
  NSString *errorMsg = [NSString stringWithFormat:
295
301
  @"Failed to start recording. Recorder state: %ld, URL: %@, Settings: %@",
296
302
  (long)_audioRecorder.recording,
@@ -300,6 +306,7 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
300
306
  _audioRecorder = nil;
301
307
  return;
302
308
  }
309
+ NSLog(@"[NosniaAudioRecorder] Recording started successfully");
303
310
 
304
311
  _isRecording = YES;
305
312
  [self startProgressTimer];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nosnia-audio-recorder",
3
- "version": "0.7.6",
3
+ "version": "0.8.0",
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",