Skip to content

Commit d46b744

Browse files
committed
check file when recording complete
1 parent 7d2b452 commit d46b744

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/ios/AudioRecorderAPI.m

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,24 @@ - (void)record:(CDVInvokedUrlCommand*)command {
6262
}];
6363
}
6464

65-
- (void)stop:(CDVInvokedUrlCommand*)command
66-
{
65+
- (void)stop:(CDVInvokedUrlCommand*)command {
6766
_command = command;
6867
NSLog(@"stopRecording");
6968
[recorder stop];
7069
NSLog(@"stopped");
7170
}
7271

73-
- (void)audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag
74-
{
75-
NSLog(@"recording saved: %@", recorderFilePath);
76-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:recorderFilePath];
77-
[self.commandDelegate sendPluginResult:pluginResult callbackId:_command.callbackId];
72+
- (void)audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag {
73+
NSURL *url = [NSURL fileURLWithPath: recorderFilePath];
74+
NSError *err = nil;
75+
NSData *audioData = [NSData dataWithContentsOfFile:[url path] options: 0 error:&err];
76+
if(!audioData) {
77+
NSLog(@"audio data: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
78+
} else {
79+
NSLog(@"recording saved: %@", recorderFilePath);
80+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:recorderFilePath];
81+
[self.commandDelegate sendPluginResult:pluginResult callbackId:_command.callbackId];
82+
}
7883
}
7984

8085
@end

0 commit comments

Comments
 (0)