foo-webview-sdk
    Preparing search index...

    Class PlaybackClock

    Follows playback through playback:timeHighRes, playback:seeked, playback:stateChanged and playback: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.

    const clock = new PlaybackClock();
    await clock.ready;
    const draw = () => {
    bar.style.width = `${(clock.position() / clock.duration) * 100}%`;
    requestAnimationFrame(draw);
    };
    requestAnimationFrame(draw);
    Index
    ready: Promise<void>

    Resolves once the first read of state and position settled; never rejects.

    • 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.

      Parameters

      • at: number = ...

      Returns number

    • 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.

      Parameters

      Returns Promise<void>