Я хочу обнаружить звук во время записи. Если звук останавливается в течение 2-3 секунд, запись должна останавливаться автоматически.Автоматически обнаруживать, что нет звука AVrecorder
есть ли способ? я сделал запись: -
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];
Заранее спасибо
Спасибо за быстрый reply.But, что делает порог означает здесь –