Skip to main content

TimeDriver

The TimeDriver interface defines the contract for time synchronization drivers. Drivers manage media elements, animations, and ensure frame-accurate playback.

Required methods

(scope: unknown) => void
Initialize the driver with an animation scope. For browser drivers, this is typically the document object.
(timeInMs: number, options?) => void
Update the driver to a specific time in milliseconds with playback options.Parameters:
  • timeInMs: Target time in milliseconds
  • options.isPlaying: Whether playback is active
  • options.playbackRate: Speed multiplier
  • options.volume: Master volume (0.0 to 1.0)
  • options.muted: Master mute state
  • options.audioTracks: Per-track audio state
() => Promise<void>
Returns a promise that resolves when all asynchronous operations (media seeking, image loading, etc.) are complete. Critical for deterministic rendering.

Optional methods

() => void
Clean up resources when the driver is no longer needed.
(callback: (meta: DriverMetadata) => void) => () => void
Subscribe to metadata updates (e.g., discovered audio tracks). Returns an unsubscribe function.
() => Promise<unknown>
Get the Web Audio API AudioContext for custom audio processing.
(trackId: string) => Promise<unknown>
Get a MediaElementAudioSourceNode for a specific audio track, useful for visualization.

DriverMetadata

Metadata reported by drivers about available resources.
AudioTrackMetadata[]
Audio tracks discovered by the driver from the DOM.

AudioTrackMetadata

Detailed metadata for an audio track.
string
Unique track identifier.
string
Audio source URL or path.
number
Track start time in the composition timeline.
number
Track duration in seconds.
number
Optional fade-in duration in seconds.
number
Optional fade-out duration in seconds.
string
Optional easing function name for fade transitions.

Ticker

The Ticker interface defines the contract for playback loop implementations.
(callback: TickCallback) => void
Start the ticker loop, calling the callback on each tick with the delta time since the last tick.
() => void
Stop the ticker loop.

TickCallback

Callback type for ticker implementations.
number
Time elapsed since the last tick in milliseconds.

Built-in implementations

Helios provides several built-in driver and ticker implementations:

Drivers

  • DomDriver: Synchronizes WAAPI animations and media elements with Helios playback
  • NoopDriver: Minimal driver with no synchronization (default when autoSyncAnimations is false)

Tickers

  • RafTicker: Uses requestAnimationFrame for smooth browser-based playback (default in browsers)
  • TimeoutTicker: Uses setTimeout for Node.js environments (default in Node.js)
  • ManualTicker: Manual tick control for testing or custom playback loops

Usage examples

Custom time driver

Custom ticker

Accessing audio context

Subscribing to metadata