Files
video.js-mirror/packages/spf/docs/reference/features/initial-load.md

5.2 KiB

@videojs/spf/features/initial-load

Source: src/playback/features/initial-load.ts

initialLoadFeature

Defers loading until the media element's preload allows it or the user plays or seeks, mirroring native HTMLMediaElement preload behavior. Syncs preload between the element and state, and activates loading on the first play or seeking for each source.

Without it, a composition loads the moment a source is set; seed loadActivated: true in its initial state, as the background-video engine does. The two behaviors compose together: syncing preload without the load triggers would leave preload="none" and "metadata" sources unable to load on play.

Behaviors

  1. syncPreload
  2. trackLoadTriggers

Config

Feature default is the value a feature's defaultConfig supplies. A behavior's own fallback for a key left unset is described under Doc.

Key Type Feature default Read by Doc
defaultPreload? StandardPreload — syncPreload Backfill applied to state.preload when neither the host element nor external code has supplied a W3C value. Defaults to 'metadata'.

State

Key Type Initial Declared by Doc
loadActivated boolean | undefined — trackLoadTriggers Sticky-true per source. Flips to true the first time an event occurs that should switch loading behavior from preload-based to standard load (currently DOM play / seeking). Reset to false on source change. Read by resolvePresentation and loadVideoSegments / loadAudioSegments to mirror native HTMLMediaElement preload semantics — only meaningful when preload !== 'auto', which already loads fully regardless.
preload "metadata" | "auto" | "none" | undefined — syncPreload The preload hint the engine honors. syncPreload keeps it in step with the element's authored preload attribute (both ways) and backfills its defaultPreload when nothing supplied one; resolvePresentation holds manifest resolution while it is 'none' unless loadActivated, and the loadXSegments dispatchers choose their load mode from it.
presentation MaybeResolvedPresentation | undefined — syncPreload, trackLoadTriggers The presentation being played. A caller writes { url }; resolvePresentation parses the manifest and populates the rest. (documented on resolvePresentation)

Context

Key Type Declared by Doc
mediaElement (MediaElementLike & HTMLMediaElement) | undefined syncPreload, trackLoadTriggers The media element the engine drives. No behavior writes it: an adapter attaches one with engine.context.mediaElement.set(element) and detaches with set(undefined), as SPF's adapters do. (documented on setupMediaSource)

Composed by

Other functions and constants

Name Kind Description Source
behaviors const The behaviors the feature composes, in setup order. Listed under Behaviors. src/playback/features/initial-load.ts
defaultConfig const The config defaults the feature contributes. It contributes none ({}). src/playback/features/initial-load.ts
initialState const The state values the feature seeds. It seeds none ({}). src/playback/features/initial-load.ts

Types

Name Kind Description Source
Behaviors type The type of behaviors. src/playback/features/initial-load.ts
Config type Every config key the behaviors read. Listed under Config. src/playback/features/initial-load.ts
Context type Every context key the behaviors declare. Listed under Context. src/playback/features/initial-load.ts
State type Every state key the behaviors and external signals declare. Listed under State. src/playback/features/initial-load.ts