When you call AVAudioPlayer.currentTime
, it returns how far the audio would be into playing if it's rate
was 1.0
. When you change the rate
, the value that currentTime
returns changes proportionately.
Put another way, AVAudioPlayer.duration
doesn't change when you change rate
, and myAudioPlayer.currentTime / myAudioPlayer.duration
will always tell you what portion of the audio file has played. So if you evaluate that expression when half the audio file has played, it will return roughly 0.5
, regardless of what the rate is.
This means that if myAudio.rate < 1.0
, myAudio.currentTime
will consistently return a value less than how long the user has been listening to the audio. Conversely, if myAudio.rate > 1.0
, myAudio.currentTime
will consistently return a value longer than how long the user has been listening.
If you want to get how long the user has been listening, you can calculate it easily: myAudio.currentTime / myAudio.rate
.