avaudioplayer playback progress

dubbeat picture dubbeat · Feb 24, 2010 · Viewed 11.1k times · Source

Would anybody have a link to a tutorial to add a playback progress bar to AVAudioPlayer?

I've searched extensively on this site and on google to no avail

Answer

dubbeat picture dubbeat · Feb 24, 2010

I figured it out and it wasnt too bad.

Just update it in a timer

playbackTimer=[NSTimer scheduledTimerWithTimeInterval:0.5
                                     target:self 
                                                 selector:@selector(myMethod:) 
                                   userInfo:nil 
                                    repeats:YES];

}


-(void)myMethod:(NSTimer*)timer {

    float total=audioPlayer.duration;
    float f=audioPlayer.currentTime / total;

    NSString *str = [NSString stringWithFormat:@"%f", f];

    playbackProgress.progress=f;

    NSLog(str);
}