I\'m using an AVAudioPlayerNode
attached to an AVAudioEngine
to play a sound.
to get the current time of the player I\'m doing this:
I ran into same issue. Apparently the framestoplay
was always 0, which happened because of sampleRate
. The value for playerTime.sampleRate
was always 0 in my case.
So,
let framestoplay = AVAudioFrameCount(Float(playerTime.sampleRate) * length)
must be replaced with
let framestoplay = AVAudioFrameCount(Float(sampleRate) * length)