Skip to content

PlayerFacade

PlayerFacade connects the media element, engines, ports, and plugins. Its configuration must be explicit so runtime errors remain auditable.

Attach the Runtime

facade.attach(videoEl, plugins, config, ports, [createShakaEngineFactory()]);
await facade.load(config);
Parameter Default Explanation Avoid
videoEl None HTMLVideoElement controlled by the facade. Calling load before attach.
plugins [] Plugins initialized with PlayerContext. Believing an installed package acts without being passed to attach.
config None Initial configuration and source of truth at startup. Mutating silently without calling load again.
ports.http Global fetch Remote config and external providers. Enabling remote config without a functional HTTP port.
ports.storage Memory Local progress, remote config cache, plugins. Expecting browser persistence with the memory port.
ports.telemetry Noop QoE events, errors, and measurements. Sending media or license secrets into logs.
engines Native + provided engines Engine selection by source and capabilities. Removing the native fallback for simple files.

Loading Cycle

  1. Apply remoteConfig when enabled.
  2. Normalize playlist or series.
  3. Merge DRM and profile on the active source.
  4. Select the compatible engine.
  5. Load the media.
  6. Publish state, events, metadata, tracks, and diagnostics.