If you use AVAudioPlayer with AVAudioRecorder , you can get audioPlayer.duration and get the time.
like this.
NSError *playerError; audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:yoururl error:&playerError]; NSlog(@"%@",audioPlayer.duration);
But only if you use AVAudioPlayer with AVAudioRecorder .
UPDATE
Or you can do it as follows.
//put this where you start recording myTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateTime) userInfo:nil repeats:YES]; // a method for update - (void)updateTime { if([recorder isRecording]) { float minutes = floor(recorder.currentTime/60); float seconds = recorder.currentTime - (minutes * 60); NSString *time = [[NSString alloc] initWithFormat:@"%0.0f.%0.0f", minutes, seconds]; } }
steel, you can get some delay because they have a value of a few microseconds, and I donβt know how to fix it. But all this.
source share