Skip to main content

Function: withResyncedAnchor()

function withResyncedAnchor(
state: PlayerState,
position: number,
now: number
): PlayerState;

Defined in: packages/player/src/state.ts:1216

Re-anchor the projection on an authoritative position, without touching any other field.

Used by the one-shot time-pos resync: reading the real position is not an event, so it does not go through reducePlayerState, but it must still produce a fresh immutable snapshot.

Parameters

ParameterTypeDescription
statePlayerStateThe snapshot to re-anchor.
positionnumberThe authoritative position in seconds.
nownumberDate.now()-style timestamp the position was read at.

Returns

PlayerState

A new snapshot, or state if the anchor would not change.