private long interpolateTimeSinceUpdate ( TrackPositionUpdate update , long currentTimestamp ) { if ( ! update . playing ) { return update . milliseconds ; } long elapsedMillis = ( currentTimestamp - update . timestamp ) / 1000000 ; long moved = Math . round ( update . pitch * elapsedMillis ) ; if ( update . reverse ) { return update . milliseconds - moved ; } return update . milliseconds + moved ; }
Figure out based on how much time has elapsed since we received an update and the playback position speed and direction at the time of that update where the player will be now .