I use this code to get an AVAudioPlayerNode's current time,
AVAudioTime * nodeTime = _playerNode.lastRenderTime;
AVAudioTime * playerTime = [_playerNode playerTimeForNodeTime:nodeTime];
NSTimeInterval seconds = (NSTimeInterval)(playerTime.sampleTime / playerTime.sampleRate);
But, when I called this code by a CADisplayLink
, playerTime.sampleTime
return -512
or -1024
at first time.
I don't know, is it correct?
Or is there an other way to get AVAudioPlayerNode
's current time real-time?