Objective c 目标C:记录循环
我想知道我的错误或者我是否在代码中忘记了什么Objective c 目标C:记录循环,objective-c,ios,cocoa,avfoundation,Objective C,Ios,Cocoa,Avfoundation,我想知道我的错误或者我是否在代码中忘记了什么 -(IBAction)playRecord { NSLog(@"stop rec"); [recorder stop]; [self playSound]; } -(void)playSound{ NSLog(@"play"); recorderFilePath = [NSString stringWithFormat:@"%@/MySound.caf", DOCUMENTS_FOLDER]; NS
-(IBAction)playRecord
{
NSLog(@"stop rec");
[recorder stop];
[self playSound];
}
-(void)playSound{
NSLog(@"play");
recorderFilePath = [NSString stringWithFormat:@"%@/MySound.caf", DOCUMENTS_FOLDER];
NSURL *urlRecord = [NSURL fileURLWithPath:recorderFilePath isDirectory:NO];
NSError *errorRecord;
soundRecord = [[AVAudioPlayer alloc] initWithContentsOfURL:urlRecord error:&errorRecord];
[soundRecord prepareToPlay];
[soundRecord play];
soundRecord.delegate = self;
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(stopPlayRec) userInfo:nil repeats:YES];
}
-(void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag
{
[recorder prepareToRecord];
[recorder record];
NSLog(@"Finish");
}
-(void)stopPlayRec
{
if ([recorder peakPowerForChannel:(0)] <= (-30) && [recorder peakPowerForChannel:(0)] >= (-43))//detecting voice then record
{
NSLog(@"test");
[self playRecord];
}
else
{
if ([recorder peakPowerForChannel:(0)] >= (-160))
{
NSLog(@"playing");
}
}
}
因此,在我的视图加载时,它开始录制..然后在我按下播放按钮后,它将播放我录制的文件..在我按下播放按钮后,我的代码流现在将循环回录制,如果它的峰值功率或频道为-30到-43(检测到语音)然后,如果它的峰值功率通道是-160或更低,它将播放录制的文件。。。现在,我的问题是,当我录制超过5次时,我的声音现在无法听到我录制的文件,我不知道是什么问题。。请帮忙。。我完全不知道……急需帮助。。请。。需要答案请。。。图特
[self startRecording];