avaudioplayer playback progress

The CADisplayLink class, which automatically calls a method you define as soon as a screen redraw happens

Timer doesn't offer precise firing and can drift earlier or later than requested updates, and also has no idea about screen redraws and so could happily fire 10ms after a screen redraw just happened.

let displayLink = CADisplayLink(target: self,
                                selector: #selector(update))
displayLink.add(to: .current, forMode: .common)


@objc func update() {
    let currentTime = avAudioPlayer.currentTime
    let totalTime = avAudioPlayer.duration
    let progress = currentTime / totalTime
}

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);
}