PlaybackClock

class PlaybackClock(smoothSteppedClock: Boolean = false, interpolateHeldReadings: Boolean = true)(source)

The last player snapshot, and how the next one is read against it.

Parameters

smoothSteppedClock

Smooth a media clock that steps rather than runs, the way upstream does for Gecko's ~40 ms steps. Off by default; interpolateHeldReadings covers coarser sources.

interpolateHeldReadings

Carry a reading forward on the wall clock while the source repeats it. Not upstream's: a browser's media clock moves every frame, but some players do not. Media3's ExoPlayer.currentPosition changes about ten times a second, and the swipe drawn from it would move in 100 ms steps. While playing without a snapshot, a reading the source keeps returning runs on from when it first appeared, at most MAX_HELD_LEAD_S ahead of it; a new reading that lands behind what was already shown holds the clock until the source catches up, rather than running the swipe backwards. A source that moves every frame never repeats a reading, so this changes nothing for it. On by default.

Constructors

Link copied to clipboard
constructor(smoothSteppedClock: Boolean = false, interpolateHeldReadings: Boolean = true)

Properties

Link copied to clipboard

Whether the player was playing at the last reading.

Link copied to clipboard

The last player time read, in seconds.

Functions

Link copied to clipboard
fun reset()

Forgets the last player snapshot, so the next tick is treated as the first one of a new song rather than as a jump away from the previous one.