Interface: PositionAnchorMs
Defined in: packages/player/src/state.ts:89
The same anchor in the units every remote surface speaks: milliseconds.
Remarks
Why a second shape exists at all. PositionAnchor is seconds
({ position, timestamp, rate }) because that is mpv's unit; media3,
MPNowPlayingInfoCenter and therefore @afkcodes/timbre-media-session's
PlaybackState.position are milliseconds ({ value, at, rate }). Converting
at the call site is a one-line arithmetic chore that was silently getting the
factor of 1000 wrong in real integrations — a lock-screen scrubber that
finishes a three-minute song in a fifth of a second. This field is that
conversion, done once, in the reducer, in the exact shape the session layer
accepts.
Structural, not imported. @afkcodes/timbre-player does not depend on
@afkcodes/timbre-media-session (nor the other way round — see CLAUDE.md §2): the
two types match by shape, which is all a structural type system needs, and
the player stays usable with any session layer.
rate already accounts for "not moving". PositionAnchor.rate is
mpv's speed and stays at 1 while paused, buffering, seeking or stopped,
because the projection is gated separately. A remote surface has no such
gate — it projects value + elapsed × rate and nothing else — so this
field's rate is 0 whenever the position is not advancing. Broadcast it
verbatim; do not re-derive it.
It is recomputed only when it changes, which is on a discontinuity — a seek, a pause/unpause, a rate change, a track change, a playback restart. Between them the field keeps its object identity, so a snapshot that changed for some unrelated reason does not make every surface redraw its scrubber.
Properties
at
readonly at: number;
Defined in: packages/player/src/state.ts:93
Date.now()-style millisecond timestamp at which value held.
rate
readonly rate: number;
Defined in: packages/player/src/state.ts:98
Rate the position advances at from at onwards. 0 freezes the
projection — paused, buffering, seeking, ended, idle or errored.
value
readonly value: number;
Defined in: packages/player/src/state.ts:91
Known-good playback position, in milliseconds, at at.