1
내 앱에서 오디오 파일을 재생할 때 오디오 파일 재생 진행을 위해 UIToolbar에 UIProgressBar를 표시하려고합니다. 누구나 코드 작성 방법을 알려줄 수 있습니다.AvAudioPlayer 재생 진행을위한 UIProgressBar
내 앱에서 오디오 파일을 재생할 때 오디오 파일 재생 진행을 위해 UIToolbar에 UIProgressBar를 표시하려고합니다. 누구나 코드 작성 방법을 알려줄 수 있습니다.AvAudioPlayer 재생 진행을위한 UIProgressBar
나는과 같이, 현재 시간을 확인하고 매 30 초 내 진행률 표시 줄을 업데이트 타이머를 사용이 도움이
tmrCounter = [NSTimer scheduledTimerWithTimeInterval:0.5f target:self selector:@selector(updateElapsedTime) userInfo:nil repeats:YES];
-(void)updateElapsedTime{
if (player) {
[prgIndicator setProgress:[player currentTime]/[player duration]];
[lblTime setText:[NSString stringWithFormat:@"%@", [self formatTime:[player currentTime]]]];
}
}
-(NSString*)formatTime:(float)time{
int minutes = time/60;
int seconds = (int)time % 60;
return [NSString stringWithFormat:@"%@%d:%@%d", minutes/10 ? [NSString stringWithFormat:@"%d", minutes/10] : @"", minutes % 10, [NSString stringWithFormat:@"%d", seconds/10], seconds % 10];
}
희망!
BTW 오디오를 재생할 AVAudioPlayer 클래스를 사용하고 있습니다. –