ReadonlyreadyResolves once the first read of state and position settled; never rejects.
Length of the playing track in seconds; 0 when unknown or stopped.
The transport state last reported by the host.
Stop following playback and drop the listeners. Safe to call more than once.
Call listener whenever the estimate jumps; returns a function that removes it.
Estimated position in seconds at monotonic time at (the
performance.now() scale, now when omitted), kept within the track's
duration when it is known. Paused and stopped positions do not move.
Refresh the estimate from the host's state and position. By default, failed responses are ignored and successful answers may still apply. With rejectOnFailure, both calls must succeed before either applies; host failure envelopes reject with ApiCallError and transport errors propagate. Events received during the read take precedence over older answers.
If a newer read replaces a successful strict read, the older caller waits for a complete newer snapshot for the current track. It rejects if none is available or pending; it does not start another read. Disposing the clock releases pending reads without applying their answers, even in strict mode.
Follows playback through
playback:timeHighRes,playback:seeked,playback:stateChangedandplayback:trackChanged, and reads the state and position once at creation, again when the page becomes visible, and on PlaybackClock.resync. Call PlaybackClock.dispose when done.With a host that does not send
hostTime, updates count as read when they arrive, so the estimate trails the audio by the delivery delay.Example