我的代理方法audioRecorderDidFinishRecording
和audioPlayerDidFinishPlaying
未被調用。這些方法應該觸發一個'stopanimation'方法,在記錄結束後停止動畫。AVAudioPlayer和AVAudioRecorder:未調用代理方法
我在audioPlayerDidFinishPlaying
的末尾給stopanimation
方法打了一個電話。
下面是相關的代碼,其中委託分配:
VoiceEditor.h
@interface VoiceEditor : UIViewController <UITextFieldDelegate, AVAudioRecorderDelegate, AVAudioPlayerDelegate>{
}
VoiceEditor.m
- (void)record{
recorder = [[AVAudioRecorder alloc] initWithURL:[NSURL fileURLWithPath:pathString] settings:recordSettings error:nil];
[recorder setDelegate:self];
[recorder record];
recording = YES;
[pauseButton setImage:[UIImage imageNamed:@"stop.png"] forState:UIControlStateNormal];
[pauseButton setEnabled:YES];
[playButton setEnabled:NO];
[recordButton setEnabled:NO];
[self beginAnimation];
}
- (void)play{
player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:pathString] error:nil];
double seconds=[player duration];
NSLog(@"%f",seconds);
[player setDelegate:self];
[player play];
playing = YES;
[recordButton setEnabled:NO];
[pauseButton setEnabled:YES];
[playButton setEnabled:NO];
[self beginAnimation];
}
我已經經歷了破發點檢查,並沒有在that.but停止當我在設備上它worked.i意味着委託方法稱爲 –
謝謝你運行它!! ...你是對的.. –