I want to detect the sound while recording that. If the sound stops for 2-3 seconds then the recording should stop automatically.
is there any way? I had done recording :-
NSArray *dirPaths;
NSString *docsDir;
dirPaths = NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"ddMMyyyyhh:mm:ss"];
NSDate *now = [[NSDate alloc] init];
NSString *dateString = [dateFormatter stringFromDate:now];
dateString=[NSString stringWithFormat:@"%@.caf",dateString];
soundFilePath = [docsDir
stringByAppendingPathComponent:dateString];
NSLog(@"soundFilePath==>%@",soundFilePath);
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
[soundFilePath retain];
NSDictionary *recordSettings = [NSDictionary
dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:AVAudioQualityMin],
AVEncoderAudioQualityKey,
[NSNumber numberWithInt:16],
AVEncoderBitRateKey,
[NSNumber numberWithInt: 2],
AVNumberOfChannelsKey,
[NSNumber numberWithFloat:44100.0],
AVSampleRateKey,
nil];
NSError *error = nil;
recorder = [[AVAudioRecorder alloc]
initWithURL:soundFileURL
settings:recordSettings
error:&error];
if (error)
{
NSLog(@"error: %@", [error localizedDescription]);
} else {
[recorder prepareToRecord];
}
[recorder record];
Thanks in advance