nosnia-audio-recorder 0.7.7 → 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.
- package/ios/NosniaAudioRecorder.mm +41 -17
- package/package.json +1 -1
|
@@ -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_%@.
|
|
106
|
+
return [NSString stringWithFormat:@"recording_%@.m4a", timestamp];
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
|
|
@@ -233,17 +233,16 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
|
|
|
233
233
|
|
|
234
234
|
// Create recording settings dictionary with safety checks
|
|
235
235
|
@try {
|
|
236
|
-
// Use
|
|
237
|
-
//
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
};
|
|
236
|
+
// Use MPEG4AAC format for MP3-compatible output
|
|
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);
|
|
247
246
|
|
|
248
247
|
// Validate settings dictionary created successfully
|
|
249
248
|
if (!recordingSettings || recordingSettings.count == 0) {
|
|
@@ -253,7 +252,7 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
|
|
|
253
252
|
|
|
254
253
|
// Validate all required keys are present
|
|
255
254
|
if (!recordingSettings[AVFormatIDKey] || !recordingSettings[AVSampleRateKey] ||
|
|
256
|
-
!recordingSettings[AVNumberOfChannelsKey] || !recordingSettings[
|
|
255
|
+
!recordingSettings[AVNumberOfChannelsKey] || !recordingSettings[AVEncoderBitRateKey]) {
|
|
257
256
|
reject(@"SETTINGS_ERROR", @"Incomplete recording settings", nil);
|
|
258
257
|
return;
|
|
259
258
|
}
|
|
@@ -287,11 +286,36 @@ RCT_EXPORT_METHOD(startRecording:(NSDictionary *)options
|
|
|
287
286
|
|
|
288
287
|
// Try to prepare recorder first
|
|
289
288
|
NSLog(@"[NosniaAudioRecorder] Preparing to record with settings: %@", _audioRecorder.settings);
|
|
289
|
+
NSLog(@"[NosniaAudioRecorder] Recording URL: %@", _recordingURL);
|
|
290
|
+
|
|
290
291
|
if (![_audioRecorder prepareToRecord]) {
|
|
291
|
-
NSLog(@"[NosniaAudioRecorder] Failed to prepare audio recorder");
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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
|
+
}
|
|
295
319
|
}
|
|
296
320
|
NSLog(@"[NosniaAudioRecorder] Recorder prepared successfully");
|
|
297
321
|
|
package/package.json
CHANGED