My delegate methods audioRecorderDidFinishRecording
and audioPlayerDidFinishPlaying
are not being called. Those methods should trigger a 'stopanimation` method that stops an animation after recording is finished.
I have placed a call call to the stopanimation
method at the end of audioPlayerDidFinishPlaying
.
Here is the relevant code where the delegate is assigned:
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];
}