# Video.js v10 — HTML API (complete) > Every HTML API page in one file (about 24k tokens). Index with descriptions: https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/llms.txt --- # createPlayer Factory function that creates a typed player element and controller for HTML custom elements ## Import ```ts import { createPlayer } from "@videojs/html"; import { videoFeatures } from "@videojs/html/video"; ``` `createPlayer` is the entry point for custom HTML player compositions. It accepts a `features` array and returns the configured `PlayerElement`, a [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) already bound to that player, and `playerContext` as a lower-level escape hatch. Import `ContainerElement` separately when you need a custom container. **player.ts** ```ts import { createPlayer, UIElement, selectPlayback } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; const { PlayerElement: VideoPlayerElement, PlayerController } = createPlayer({ features: videoFeatures, }); customElements.define('video-player', VideoPlayerElement); // Control element with selector class PlayButton extends UIElement { #playback = new PlayerController(this, selectPlayback); } ``` `PlayerElement` and `PlayerController` are scoped to the created player’s feature set. The element owns its store and attachment lifecycle; the configured controller does not need a context argument. `ContainerElement` consumes the shared player context, so the same class works with any created player. Use split elements (recommended for reusable skins/layouts): **player.ts** ```ts import { ContainerElement, createPlayer } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; const { PlayerElement: PlayerRoot } = createPlayer({ features: videoFeatures }); class PlayerRegion extends ContainerElement {} ``` ## Examples ### Basic Usage **index.html** ```html Play Pause ``` **index.css** ```css .demo-video-player media-container { position: relative; } .demo-video-player media-container video { width: 100%; } .media-play-button { position: absolute; bottom: 10px; left: 10px; padding-block: 8px; padding-inline: 20px; color: black; cursor: pointer; background: rgba(255, 255, 255, 0.7); border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 9999px; backdrop-filter: blur(10px); } .media-play-button .paused { display: none; } .media-play-button .playing { display: none; } .media-play-button[data-paused] .paused { display: inline; } .media-play-button:not([data-paused]) .playing { display: inline; } ``` **index.ts** ```ts import { applyElementProps, applyStateDataAttrs, createButton, createPlayer, selectPlayback, UIElement, } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; import '@videojs/html/ui/container'; const { PlayerElement: VideoPlayerElement, PlayerController } = createPlayer({ features: videoFeatures, }); class PlayToggle extends UIElement { static readonly tagName = 'demo-play-toggle'; readonly #player = new PlayerController(this, selectPlayback); #disconnect: AbortController | null = null; override connectedCallback(): void { super.connectedCallback(); this.#disconnect = new AbortController(); const buttonProps = createButton({ onActivate: () => { const state = this.#player.value; if (!state) return; state.paused ? state.play() : state.pause(); }, isDisabled: () => !this.#player.value, }); applyElementProps(this, buttonProps, { signal: this.#disconnect.signal }); } override disconnectedCallback(): void { super.disconnectedCallback(); this.#disconnect?.abort(); this.#disconnect = null; } protected override update(changed: Map): void { super.update(changed); const state = this.#player.value; if (!state) return; applyStateDataAttrs(this, state, { paused: 'data-paused', ended: 'data-ended' }); } } customElements.define('demo-video-player', VideoPlayerElement); customElements.define(PlayToggle.tagName, PlayToggle); ``` ## API Reference ### Video `createPlayer(config): CreatePlayerResult` Creates a typed HTML player class and bound controller. #### Parameters | Parameter | Type | Default | Description | | --- | --- | --- | --- | | `config` (required) | `{ features: [PlayerFeature, PlayerFeature, PlayerFeature, PlayerFeature, PlayerFeature, PlayerFeature, PlayerFeature, PlayerFeature, PlayerFeature, PlayerFeature, PlayerFeature, PlayerFeature, PlayerFeature, PlayerFeature, typeof metadataFeature] }` | — | Player configuration with features. | #### Return Value | Property | Type | Description | | --- | --- | --- | | `PlayerElement` | `typeof UIElement & (new (...args: any[]) => PlayerElement)` | Configured player element class that owns the store and attachment lifecycle. | | `PlayerController` | `{ new (host: ReactiveControllerHost & HTMLElement): PlayerController; new (host: ReactiveControllerHost & HTMLElement, selector: Selector): PlayerController }` | Player controller bound to this player's context. | | `playerContext` | `Context` | Context that carries the player store to descendant elements. | ### Audio `createPlayer(config): CreatePlayerResult` Creates a typed HTML audio player class and bound controller. #### Parameters | Parameter | Type | Default | Description | | --- | --- | --- | --- | | `config` (required) | `{ features: [PlayerFeature, PlayerFeature, PlayerFeature, PlayerFeature, PlayerFeature, PlayerFeature, PlayerFeature, typeof metadataFeature] }` | — | Player configuration with features. | #### Return Value | Property | Type | Description | | --- | --- | --- | | `PlayerElement` | `typeof UIElement & (new (...args: any[]) => PlayerElement)` | Configured player element class that owns the store and attachment lifecycle. | | `PlayerController` | `{ new (host: ReactiveControllerHost & HTMLElement): PlayerController; new (host: ReactiveControllerHost & HTMLElement, selector: Selector): PlayerController }` | Player controller bound to this player's context. | | `playerContext` | `Context` | Context that carries the player store to descendant elements. | ### Generic `createPlayer(config): CreatePlayerResult>` Creates a typed HTML player class with custom features. #### Parameters | Parameter | Type | Default | Description | | --- | --- | --- | --- | | `config` (required) | `{ features: Features }` | — | Player configuration with features. | #### Return Value | Property | Type | Description | | --- | --- | --- | | `PlayerElement` | `typeof UIElement & (new (...args: any[]) => PlayerElement>)` | Configured player element class that owns the store and attachment lifecycle. | | `PlayerController` | `{ new (host: ReactiveControllerHost & HTMLElement): PlayerController>; new (host: ReactiveControllerHost & HTMLElement, selector: Selector['state'], Result>): PlayerController, Result> }` | Player controller bound to this player's context. | | `playerContext` | `Context>` | Context that carries the player store to descendant elements. | --- # PlayerController Reactive controller for accessing player store state in HTML custom elements ## Import ```ts import { PlayerController } from "@videojs/html/video"; ``` `PlayerController` is a reactive controller that consumes the player store from `playerContext`. Without a selector it returns the store instance directly (no subscription — use this for actions). With a selector it returns the selected value and subscribes to changes, triggering a host update on shallow-equal change. Access the current value via `.value`, which returns `undefined` until connected to a player. The controller exported by each preset, or returned by [`createPlayer`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/html-create-player), is already bound to that player’s context, so pass only the host and optional selector. The lower-level `PlayerController` exported from `@videojs/html` accepts the context as its second argument; its constructor signatures are documented below. ```ts import { UIElement, selectPlayback } from '@videojs/html'; import { PlayerController } from '@videojs/html/video'; class PlayButtonElement extends UIElement { readonly #playback = new PlayerController(this, selectPlayback); } ``` ## Examples ### Basic Usage **index.html** ```html
Paused: Yes | Time: 0.0s | Volume: 100%
``` **index.css** ```css .demo-ctrl-player media-container { position: relative; } .demo-ctrl-player media-container video { width: 100%; } .panel { display: flex; gap: 16px; align-items: center; padding: 12px; background: rgba(0, 0, 0, 0.05); border-top: 1px solid rgba(0, 0, 0, 0.1); } .actions { display: flex; gap: 6px; } .actions button { padding: 4px 12px; font-size: 0.8125rem; color: #111827; cursor: pointer; background: white; border: 1px solid #ccc; border-radius: 6px; } .state { font-size: 0.8125rem; font-variant-numeric: tabular-nums; color: #374151; } ``` **index.ts** ```ts import { applyElementProps, createButton, createPlayer, selectPlayback, selectTime, selectVolume, UIElement, } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; import '@videojs/html/ui/container'; const { PlayerElement: DemoPlayerElement, PlayerController } = createPlayer({ features: videoFeatures, }); class PlayerActions extends UIElement { static readonly tagName = 'demo-ctrl-actions'; readonly #player = new PlayerController(this); #disconnect: AbortController | null = null; override connectedCallback(): void { super.connectedCallback(); this.#disconnect = new AbortController(); const signal = this.#disconnect.signal; const playBtn = this.querySelector('.play')!; const pauseBtn = this.querySelector('.pause')!; const volumeBtn = this.querySelector('.volume')!; const bind = (el: HTMLElement, action: () => void) => { const props = createButton({ onActivate: action, isDisabled: () => !this.#player.value }); applyElementProps(el, props, { signal }); }; bind(playBtn, () => this.#player.value?.play()); bind(pauseBtn, () => this.#player.value?.pause()); bind(volumeBtn, () => this.#player.value?.setVolume(0.5)); } override disconnectedCallback(): void { super.disconnectedCallback(); this.#disconnect?.abort(); this.#disconnect = null; } } class PlayerState extends UIElement { static readonly tagName = 'demo-ctrl-state'; readonly #playback = new PlayerController(this, selectPlayback); readonly #time = new PlayerController(this, selectTime); readonly #volume = new PlayerController(this, selectVolume); protected override update(changed: Map): void { super.update(changed); const playback = this.#playback.value; const time = this.#time.value; const volume = this.#volume.value; if (!playback) return; const el = this.querySelector('.text'); if (el) { el.textContent = `Paused: ${playback.paused ? 'Yes' : 'No'} | Time: ${(time?.currentTime ?? 0).toFixed(1)}s | Volume: ${Math.round((volume?.volume ?? 0) * 100)}%`; } } } customElements.define('demo-ctrl-player', DemoPlayerElement); customElements.define(PlayerActions.tagName, PlayerActions); customElements.define(PlayerState.tagName, PlayerState); ``` ## API Reference ### Without Selector `new PlayerController(host, context)` #### Parameters | Parameter | Type | Default | Description | | --- | --- | --- | --- | | `host` (required) | `{ addController(controller: ReactiveController): void; removeController(controller: ReactiveController): void; requestUpdate(): void; updateComplete: Promise } & HTMLElement` | — | The host element that owns this controller. | | `context` (required) | `Context` | — | Player context to resolve the store from. | #### Return Value | Property | Type | | --- | --- | | `value` | `Result \| undefined` | | `displayName` | `string \| undefined` | ### With Selector `new PlayerController(host, context, selector)` #### Parameters | Parameter | Type | Default | Description | | --- | --- | --- | --- | | `host` (required) | `{ addController(controller: ReactiveController): void; removeController(controller: ReactiveController): void; requestUpdate(): void; updateComplete: Promise } & HTMLElement` | — | The host element that owns this controller. | | `context` (required) | `Context` | — | Player context to resolve the store from. | | `selector` (required) | `{ (state: Store['state']): Result; displayName?: string }` | — | Derives a value from the player store state. | #### Return Value | Property | Type | | --- | --- | | `value` | `Result \| undefined` | | `displayName` | `string \| undefined` | --- # createSelector Create a type-safe selector for a store slice's state ## Import ```ts import { createSelector } from "@videojs/store"; ``` `createSelector` is also re-exported from `@videojs/react` and `@videojs/html`. `createSelector` creates a type-safe selector function for a given slice. The returned selector extracts that slice’s state from the full store state, or returns `undefined` if the slice is not configured. The built-in selectors ([`selectPlayback`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/feature-playback), [`selectBuffer`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/feature-buffer), etc.) are all created with `createSelector`. Use it to create selectors for custom slices. **my-custom-selector.ts** ```ts import { createSelector } from '@videojs/store'; import { myCustomSlice } from './my-custom-slice'; const selectCustom = createSelector(myCustomSlice); // Use with usePlayer (React) or PlayerController (HTML) const state = selectCustom(store.state); ``` Pass selectors to [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) or [`StoreController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/store-controller) for reactive subscriptions. ## API Reference `createSelector(slice): Selector | undefined>` ### Parameters | Parameter | Type | Default | Description | | --- | --- | --- | --- | | `slice` (required) | `S` | — | The slice to create a selector for. | ### Return Value | Type | | --- | | `{ (state: object): (S extends Slice ? Simplify & Derived> : never) \| undefined; displayName?: string }` | --- # StoreController Reactive controller for subscribing to store state in HTML custom elements ## Import ```ts import { StoreController } from "@videojs/store/html"; ``` `StoreController` is a reactive controller for accessing store state and actions in custom elements. It accepts a store instance or a context, resolving the store automatically. **Without selector** – returns the store instance directly. Does NOT subscribe to changes. Use this to access store actions. ```ts class VolumeControl extends HTMLElement { #store = new StoreController(this, storeSource); handleClick() { this.#store.value.setVolume(0.5); } } ``` **With selector** – returns the selected value and subscribes to changes. Triggers a host update when the selected value changes (using shallow equality). ```ts class PlayButton extends HTMLElement { #playback = new StoreController(this, storeSource, selectPlayback); render() { const playback = this.#playback.value; // Re-renders when playback state changes } } ``` ### StoreController vs PlayerController vs SnapshotController | | `StoreController` | [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) | [`SnapshotController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/snapshot-controller) | | --- | --- | --- | --- | | **Input** | Any store or context | Player store context | `State` container | | **Typed to** | Generic store | Player features | Raw state | | **Use case** | General-purpose store access | Player UI elements | Low-level state subscription | [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) is a typed wrapper around `StoreController` scoped to the player store. For player UI, prefer `PlayerController`. Use `StoreController` when working with a custom store outside the player system. When you pass a selector, `StoreController` internally creates a [`SnapshotController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/snapshot-controller) on the store’s `$state` container. Without a selector, no subscription is created – you get the store instance for imperative access to actions. ## API Reference ### Without Selector `new StoreController(host, source)` #### Parameters | Parameter | Type | Default | Description | | --- | --- | --- | --- | | `host` (required) | `{ addController(controller: ReactiveController): void; removeController(controller: ReactiveController): void; requestUpdate(): void; updateComplete: Promise } & HTMLElement` | — | The host element that owns this controller. | | `source` (required) | `Store \| Context` | — | Store instance or context to resolve the store from. | #### Return Value | Property | Type | | --- | --- | | `value` | `Result` | ### With Selector `new StoreController(host, source, selector)` #### Parameters | Parameter | Type | Default | Description | | --- | --- | --- | --- | | `host` (required) | `{ addController(controller: ReactiveController): void; removeController(controller: ReactiveController): void; requestUpdate(): void; updateComplete: Promise } & HTMLElement` | — | The host element that owns this controller. | | `source` (required) | `Store \| Context` | — | Store instance or context to resolve the store from. | | `selector` (required) | `{ (state: Store['state']): Result; displayName?: string }` | — | Derives a value from the store state. | #### Return Value | Property | Type | | --- | --- | | `value` | `Result` | --- # SnapshotController Reactive controller for subscribing to a State container in HTML custom elements ## Import ```ts import { SnapshotController } from "@videojs/store/html"; ``` `SnapshotController` subscribes to a `State` container and triggers host updates when state changes. It has two overloads: **Full state** – returns the entire state object. Re-renders on any state change. ```ts class Display extends HTMLElement { #state = new SnapshotController(this, sliderState); render() { const value = this.#state.value; // Full state object } } ``` **With selector** – returns a derived value from state. Re-renders only when the selected value changes (using shallow equality). ```ts class SliderValue extends HTMLElement { #value = new SnapshotController(this, sliderState, (s) => s.value); render() { return this.#value.value; // Only the selected slice } } ``` Use `.track(state)` to switch to a different `State` container at runtime. ### SnapshotController vs StoreController Both are reactive controllers, but they operate at different levels: | | `SnapshotController` | [`StoreController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/store-controller) | | --- | --- | --- | | **Input** | `State` container | Store instance or context | | **Subscribes** | Always | Only with a selector | | **Use case** | Subscribe to raw state changes | Access store actions and optionally subscribe | `SnapshotController` is lower-level. It works with `State` containers directly – the reactive primitives that back a store. Use it when building custom controllers or working outside the player store system. [`StoreController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/store-controller) is higher-level. It resolves a store from a context or direct reference and internally creates a `SnapshotController` when you pass a selector. Use it for player UI elements. ### Lifecycle `SnapshotController` subscribes on `hostConnected()` and unsubscribes on `hostDisconnected()`. The React equivalent is [`useSnapshot`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/react/reference/api/use-snapshot). ## API Reference ### Without Selector `new SnapshotController(host, state)` #### Parameters | Parameter | Type | Default | Description | | --- | --- | --- | --- | | `host` (required) | `{ addController(controller: ReactiveController): void; removeController(controller: ReactiveController): void; requestUpdate(): void; updateComplete: Promise }` | — | The host element that owns this controller. | | `state` (required) | `{ current: Readonly; subscribe(callback: (() => void), options?: SubscribeOptions): (() => void) }` | — | The State container to subscribe to. | #### Return Value | Property | Type | Description | | --- | --- | --- | | `value` | `R` | | | `track` | `((state: { current: Readonly; subscribe(callback: (() => void), options?: SubscribeOptions): (() => void) }) => void)` | Switch to tracking a different state container. | ### With Selector `new SnapshotController(host, state, selector)` #### Parameters | Parameter | Type | Default | Description | | --- | --- | --- | --- | | `host` (required) | `{ addController(controller: ReactiveController): void; removeController(controller: ReactiveController): void; requestUpdate(): void; updateComplete: Promise }` | — | The host element that owns this controller. | | `state` (required) | `{ current: Readonly; subscribe(callback: (() => void), options?: SubscribeOptions): (() => void) }` | — | The State container to subscribe to. | | `selector` (required) | `{ (state: T): R; displayName?: string }` | — | Derives a value from the state. | #### Return Value | Property | Type | Description | | --- | --- | --- | | `value` | `R` | | | `track` | `((state: { current: Readonly; subscribe(callback: (() => void), options?: SubscribeOptions): (() => void) }) => void)` | Switch to tracking a different state container. | --- # SubscriptionController Reactive controller that resolves a store and manages a derived subscription ## Import ```ts import { SubscriptionController } from "@videojs/store/html"; ``` ## Usage Provide a store or store context plus functions that read the current value and subscribe to changes. ```ts class QueueController { readonly #tasks; constructor(host, storeSource) { this.#tasks = new SubscriptionController(host, storeSource, { getValue: (store) => store.queue.tasks, subscribe: (store, onChange) => store.queue.subscribe(onChange), }); } get value() { return this.#tasks.value; } } ``` The controller requests a host update when the subscription changes and unsubscribes when the host disconnects. Reading `value` throws until a store is available. ## API Reference `new SubscriptionController(host, source, config)` ### Parameters | Parameter | Type | Default | Description | | --- | --- | --- | --- | | `host` (required) | `{ addController(controller: ReactiveController): void; removeController(controller: ReactiveController): void; requestUpdate(): void; updateComplete: Promise } & HTMLElement` | — | The host element that owns this controller. | | `source` (required) | `Store \| Context` | — | Store instance or context to resolve the store from. | | `config` (required) | `{ getValue: ((store: Store) => Value); subscribe: ((store: Store, onChange: (() => void)) => (() => void)) }` | — | Subscription and value extraction configuration. | ### Return Value | Property | Type | | --- | --- | | `value` | `Value` | --- # Buffer Buffered and seekable time range state for the player store Tracks buffered and seekable time ranges. Each range is a `[start, end]` pair rather than a browser `TimeRanges` object. During live playback, `seekable` tells you which times remain available. The first start is the oldest available time, and the last end is the newest. Both values can move forward as a sliding live stream drops older video and adds new video. See [live state](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/feature-live) for the live-edge values. ## Import ```ts import { bufferFeature } from '@videojs/html'; ``` The `audioFeatures`, `liveAudioFeatures`, `liveVideoFeatures`, and `videoFeatures` [feature bundles](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/presets) include this feature. ## API Reference ### State | Property | Type | Description | | --- | --- | --- | | `buffered` | `[number, number][]` | Buffered time ranges as \[start, end\] tuples. | | `seekable` | `[number, number][]` | Seekable time ranges as \[start, end\] tuples. | ### Selector Pass `selectBuffer` to [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) to subscribe to buffer state. Returns `undefined` if the buffer feature is not configured. **buffer-bar.ts** ```ts import { createPlayer, UIElement, selectBuffer } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; const { PlayerController } = createPlayer({ features: videoFeatures }); class BufferBar extends UIElement { readonly #buffer = new PlayerController(this, selectBuffer); } ``` --- # Controls User activity and controls visibility state for the player store Tracks user activity for showing and hiding controls, with actions to toggle visibility and keep controls shown. ## Import ```ts import { controlsFeature } from '@videojs/html'; ``` The `liveVideoFeatures` and `videoFeatures` [feature bundles](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/presets) include this feature. ## API Reference ### State | Property | Type | Description | | --- | --- | --- | | `userActive` | `boolean` | Whether the user has recently interacted with the player. | | `controlsVisible` | `boolean` | Whether controls should be visible. | ### Actions | Action | Type | Description | | --- | --- | --- | | `requestControlsLock` | `() => (() => void)` | Keep controls visible during a sustained interaction. The returned function releases the lock. Multiple concurrent locks are supported and each release function is idempotent. | | `toggleControls` | `(forceShow?: boolean) => boolean` | Toggle controls visibility, or force it with `forceShow`. Returns the new `controlsVisible` value. | ### Selector Pass `selectControls` to [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) to subscribe to controls state. Returns `undefined` if the controls feature is not configured. **controls-overlay.ts** ```ts import { createPlayer, UIElement, selectControls } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; const { PlayerController } = createPlayer({ features: videoFeatures }); class ControlsOverlay extends UIElement { readonly #controls = new PlayerController(this, selectControls); } ``` --- # Error Media error state and actions for the player store Tracks media errors. ## Import ```ts import { errorFeature } from '@videojs/html'; ``` The `audioFeatures`, `liveAudioFeatures`, `liveVideoFeatures`, and `videoFeatures` [feature bundles](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/presets) include this feature. ## API Reference ### State | Property | Type | Description | | --- | --- | --- | | `error` | `{ code: number; message: string } \| null` | The current media error, or null if none. | ### Actions | Action | Type | Description | | --- | --- | --- | | `dismissError` | `() => void` | Dismiss the current error by clearing it. | ### Selector Pass `selectError` to [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) to subscribe to error state. Returns `undefined` if the error feature is not configured. **error-display.ts** ```ts import { createPlayer, UIElement, selectError } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; const { PlayerController } = createPlayer({ features: videoFeatures }); class ErrorDisplay extends UIElement { readonly #error = new PlayerController(this, selectError); } ``` --- # Fullscreen Fullscreen state and actions for the player store Controls fullscreen mode. Tries the container element first, falls back to the media element. ## Import ```ts import { fullscreenFeature } from '@videojs/html'; ``` The `liveVideoFeatures` and `videoFeatures` [feature bundles](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/presets) include this feature. ## API Reference ### State | Property | Type | Description | | --- | --- | --- | | `isFullscreen` | `boolean` | Whether fullscreen mode is currently active. | | `fullscreenAvailability` | `'available' \| 'unavailable' \| 'unsupported'` | Whether fullscreen can be requested on this platform. | ### Actions | Action | Type | Description | | --- | --- | --- | | `requestFullscreen` | `() => Promise` | Enter fullscreen mode. Tries container first, falls back to media element. | | `exitFullscreen` | `() => Promise` | Exit fullscreen mode. | ### Selector Pass `selectFullscreen` to [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) to subscribe to fullscreen state. Returns `undefined` if the fullscreen feature is not configured. **fullscreen-button.ts** ```ts import { createPlayer, UIElement, selectFullscreen } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; const { PlayerController } = createPlayer({ features: videoFeatures }); class FullscreenButton extends UIElement { readonly #fullscreen = new PlayerController(this, selectFullscreen); } ``` ### Screen orientation Add [`features.orientationLock`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/feature-orientation-lock) to lock screen orientation while fullscreen is active. Unsupported browsers and rejected lock requests are ignored, so iOS Safari continues to use its normal fullscreen behavior. The feature locks to `landscape` unless the provider sets another Screen Orientation API type. ```html ``` See [Orientation lock](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/feature-orientation-lock) for the player setup. --- # Live Live edge state for the player store Tracks when playback is at the live edge and what kind of live window the stream provides. - `liveEdgeStart` is the playback time where the live edge begins. Playback counts as live when `currentTime` reaches this value. - `targetLiveWindow` describes the kind of live window. Despite its name, it does not report a number of seconds: `0` means a sliding live window, `Infinity` means a live event with playback history, and `NaN` means on-demand or not known yet. Both values are `NaN` when the media does not provide live-edge information. Use the [buffer feature](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/feature-buffer) to find the times a viewer can seek to. Its `seekable` value contains `[start, end]` pairs. On a sliding live stream, the oldest and newest available times both move forward. The live presets do not include the [stream type feature](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/feature-stream-type), so `selectStreamType` returns `undefined` unless you add it to a custom player. The [time feature](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/feature-time) reports the end of the available live video as `duration`, even when the browser reports `Infinity`. To check for live playback, use `!Number.isNaN(targetLiveWindow)` instead of checking `duration`. ## Import ```ts import { liveFeature } from '@videojs/html'; ``` The `liveAudioFeatures` and `liveVideoFeatures` [feature bundles](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/presets) include this feature. ## API Reference ### State | Property | Type | Description | | --- | --- | --- | | `liveEdgeStart` | `number` | Playback time where the live edge begins. Playback is live when `currentTime >= liveEdgeStart`. `NaN` when the stream is not live or the value is unknown. | | `targetLiveWindow` | `number` | Describes the kind of live window available. This value is not a duration. `0` for a sliding live window, `Infinity` for a live event with playback history, and `NaN` for on-demand or unknown. | ### Selector Pass `selectLive` to [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) to subscribe to live state. Returns `undefined` if the live feature is not configured. **live-edge-button.ts** ```ts import { createPlayer, UIElement, selectLive } from '@videojs/html'; import { liveVideoFeatures } from '@videojs/html/live-video'; const { PlayerController } = createPlayer({ features: liveVideoFeatures }); class LiveEdgeButton extends UIElement { readonly #live = new PlayerController(this, selectLive); } ``` ## Jump to the live edge Use the packaged live button for the usual jump-to-live behavior. It combines the live, time, and buffer features, then seeks to the end of the last `seekable` range. It also manages its accessible label and disabled state. **index.html** ```html On air ``` Put the button in your custom controls and style it there. Do not calculate the destination from `duration` or set `currentTime` to `Infinity`. If you need different behavior, you can combine the same public features yourself: - Read `targetLiveWindow` from `selectLive` to check that the source is live. - Read the newest available time from the last range returned by `selectBuffer`. - Call the `seek()` action returned by `selectTime` with that time. Read the same three selectors with [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller). Call `selectTime`’s `seek()` action with the last end time from `selectBuffer` when `selectLive` reports a live source. --- # Metadata Resolved title and poster values for the player store Resolves what is playing into two values your UI can render: `title` and `poster`. `title` and `poster` each resolve independently through the same two tiers: the value you set, then the value the media reports. The first tier that holds a value wins; when neither does, the resolved value is an empty string. Because the tiers stay separate, clearing the value you set reveals the media’s, and a source that reports a poster but no title contributes to one while leaving the other empty. An empty string counts as a value and stops the chain: `content-title=""` resolves the title to `''`. Remove the attribute to clear your value. The metadata feature is included by the `videoFeatures`, `audioFeatures`, `liveVideoFeatures`, and `liveAudioFeatures` [presets](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/presets); apps that build a custom preset can compose it in directly. ## Import ```ts import { metadataFeature } from '@videojs/html'; ``` The `audioFeatures`, `liveAudioFeatures`, `liveVideoFeatures`, and `videoFeatures` [feature bundles](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/presets) include this feature. ## API Reference ### Configuration Attributes and matching properties the player element accepts. They exist only while this feature is selected. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `contentTitle` (attribute `content-title`) | `undefined \| null \| string` | — | The title to display. Takes precedence over the title the media carries. | | `poster` | `undefined \| null \| string` | — | The poster to display. Takes precedence over the poster the media carries. | ### State | Property | Type | Description | | --- | --- | --- | | `title` | `string` | The resolved content title. Set it through the player, not through the store. | | `poster` | `string` | The resolved poster URL, independent of the media element's own `poster`. Set it through the player, not through the store. | ### Selector To just show the name of what is playing, drop in the [Title component](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/components/title) — it reads this feature for you. Reach for the selector when building your own UI. Pass `selectMetadata` to [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) to subscribe to metadata state. Returns `undefined` if the metadata feature is not configured. **content-title.ts** ```ts import { createPlayer, UIElement, selectMetadata } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; const { PlayerController } = createPlayer({ features: videoFeatures }); class ContentTitle extends UIElement { readonly #metadata = new PlayerController(this, selectMetadata); } ``` ### Player inputs The store publishes the resolved values and takes no writes. A player input is the only way to set one. Every input is an attribute on [``](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/components/player), each with a matching property. A player built without the metadata feature observes none of them. `title` already means the tooltip on an HTML element, so the title input goes by `content-title` in markup, and by `contentTitle` as a property. The other inputs use their own names. ```html ``` Removing an attribute clears your value, so it falls through to what the media reports. **title-controls.ts** ```ts const player = document.querySelector('video-player'); player?.setAttribute('content-title', 'The Pilot'); player?.removeAttribute('content-title'); // falls back to the media ``` The flow between an attribute and its property runs one way: an attribute change writes the property, but setting the property leaves the attribute alone. Read the property for the current value. ### Media-reported values The media tier comes from media that reports content data and announces changes to it, and it covers `title` and `poster`. A media reports only the keys it can vouch for, so either may be absent while the other arrives. A key that never arrives means that tier never contributes, and the resolved value is whatever you set. Detaching the media clears its values; the values you set survive and apply to the next source. `poster` is the feature’s own resolved value, not the media element’s `poster` attribute. Setting one does not set the other. A low-resolution stand-in to show while the poster loads is not part of this feature. The [poster](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/components/poster) renders an `` you control, so give it a `background-image` and that shows until the poster itself paints over it. [Add a poster and loading placeholder](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/poster) walks through that technique for each framework. --- # Orientation lock Screen orientation locking while fullscreen is active Locks screen orientation while fullscreen is active. ## Import ```ts import { orientationLockFeature } from '@videojs/html'; ``` No packaged [feature bundle](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/presets) includes this feature — add it to your [`createPlayer`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/html-create-player) features yourself. ## API Reference ### Configuration Attributes and matching properties the player element accepts. They exist only while this feature is selected. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `orientationLockType` (attribute `orientation-lock-type`) | `undefined \| null \| 'any' \| 'landscape' \| 'landscape-primary' \| 'landscape-secondary' \| 'natural' \| 'portrait' \| 'portrait-primary' \| 'portrait-secondary'` | `'landscape'` | Screen orientation type to lock while fullscreen is active. | ### State | Property | Type | Description | | --- | --- | --- | | `orientationLockType` | `'any' \| 'landscape' \| 'landscape-primary' \| 'landscape-secondary' \| 'natural' \| 'portrait' \| 'portrait-primary' \| 'portrait-secondary'` | Screen orientation type locked while fullscreen is active. | ### Actions | Action | Type | Description | | --- | --- | --- | | `setOrientationLockType` | `(value: 'any' \| 'landscape' \| 'landscape-primary' \| 'landscape-secondary' \| 'natural' \| 'portrait' \| 'portrait-primary' \| 'portrait-secondary' \| null \| undefined) => void` | Sets the locked orientation type. A missing value, including an empty one, restores the default. | ### Usage Selecting the feature adds it to the player. **player.ts** ```ts import { createPlayer, features } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; const { PlayerElement: MyPlayer } = createPlayer({ features: [...videoFeatures, features.orientationLock], }); customElements.define('my-player', MyPlayer); ``` ### Orientation type The feature locks to `landscape` unless the provider sets another Screen Orientation API type. The value can change while the player is running; if the screen is already locked, it re-locks to the new type. ```html ``` The attribute only exists on a player that selected the feature. Setting it on an element built from `videoFeatures` alone does nothing. Clearing the value restores `landscape`. ### Selector Pass `selectOrientationLock` to [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) to subscribe to the lock state. Returns `undefined` if the orientation lock feature is not configured. **orientation-toggle.ts** ```ts import { createPlayer, features, UIElement, selectOrientationLock } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; const { PlayerController } = createPlayer({ features: [...videoFeatures, features.orientationLock], }); class OrientationToggle extends UIElement { readonly #lock = new PlayerController(this, selectOrientationLock); } ``` Unsupported browsers and rejected lock requests are ignored. --- # Picture-in-picture Picture-in-picture state and actions for the player store Controls picture-in-picture mode. ## Import ```ts import { pipFeature } from '@videojs/html'; ``` The `liveVideoFeatures` and `videoFeatures` [feature bundles](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/presets) include this feature. ## API Reference ### State | Property | Type | Description | | --- | --- | --- | | `isPictureInPicture` | `boolean` | Whether picture-in-picture mode is currently active. | | `pictureInPictureAvailability` | `'available' \| 'unavailable' \| 'unsupported'` | Whether picture-in-picture can be requested on this platform. | ### Actions | Action | Type | Description | | --- | --- | --- | | `requestPictureInPicture` | `() => Promise` | Enter picture-in-picture mode, exiting fullscreen first. Rejects before metadata is loaded. | | `exitPictureInPicture` | `() => Promise` | Exit picture-in-picture mode. | ### Selector Pass `selectPiP` to [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) to subscribe to picture-in-picture state. Returns `undefined` if the PiP feature is not configured. **pip-button.ts** ```ts import { createPlayer, UIElement, selectPiP } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; const { PlayerController } = createPlayer({ features: videoFeatures }); class PiPButton extends UIElement { readonly #pip = new PlayerController(this, selectPiP); } ``` --- # Playback Play/pause state and actions for the player store Controls play/pause state and tracks whether playback has started or is stalled. ## Import ```ts import { playbackFeature } from '@videojs/html'; ``` The `audioFeatures`, `liveAudioFeatures`, `liveVideoFeatures`, and `videoFeatures` [feature bundles](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/presets) include this feature. ## API Reference ### State | Property | Type | Description | | --- | --- | --- | | `paused` | `boolean` | Whether playback is paused. | | `ended` | `boolean` | Whether playback has reached the end. | | `started` | `boolean` | Whether playback has started (played or seeked). | | `waiting` | `boolean` | Whether playback is stalled waiting for data. | ### Actions | Action | Type | Description | | --- | --- | --- | | `play` | `() => Promise` | Start playback. Updates `paused` immediately when the media starts. | | `pause` | `() => void` | Pause playback. Updates `paused` immediately. | ### Selector Pass `selectPlayback` to [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) to subscribe to playback state. Returns `undefined` if the playback feature is not configured. **play-button.ts** ```ts import { createPlayer, UIElement, selectPlayback } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; const { PlayerController } = createPlayer({ features: videoFeatures }); class PlayButton extends UIElement { readonly #playback = new PlayerController(this, selectPlayback); } ``` --- # Playback rate Playback speed state and actions for the player store Controls speed of playback. ## Import ```ts import { playbackRateFeature } from '@videojs/html'; ``` The `audioFeatures` and `videoFeatures` [feature bundles](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/presets) include this feature. ## API Reference ### State | Property | Type | Description | | --- | --- | --- | | `playbackRates` | `readonly number[]` | Available playback rates. | | `playbackRate` | `number` | Current playback rate. | ### Actions | Action | Type | Description | | --- | --- | --- | | `setPlaybackRate` | `(rate: number) => void` | Set the playback rate. | ### Selector Pass `selectPlaybackRate` to [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) to subscribe to playback rate state. Returns `undefined` if the playback rate feature is not configured. **rate-display.ts** ```ts import { createPlayer, UIElement, selectPlaybackRate } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; const { PlayerController } = createPlayer({ features: videoFeatures }); class RateDisplay extends UIElement { readonly #rate = new PlayerController(this, selectPlaybackRate); } ``` --- # Quality Video rendition state and actions for the player store Tracks video renditions and selects a manual rendition or automatic adaptive bitrate. ## Import ```ts import { qualityFeature } from '@videojs/html'; ``` The `videoFeatures` [feature bundle](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/presets) includes this feature. ## API Reference ### State | Property | Type | Description | | --- | --- | --- | | `videoRenditionList` | `MediaVideoRendition[]` | Video renditions available for manual quality selection. | | `activeVideoRendition` | `{ id: string; width?: number; height?: number; bitrate?: number; frameRate?: number; codec?: string; selected: boolean } \| null` | Video rendition currently playing, including when automatic ABR is selected. | ### Actions | Action | Type | Description | | --- | --- | --- | | `selectVideoRendition` | `(id: string) => void` | Select a video rendition by `id`, or automatic ABR with `"auto"`. | ### Selector Pass `selectQuality` to [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) to subscribe to quality state. Returns `undefined` if the quality feature is not configured. **quality-info.ts** ```ts import { createPlayer, UIElement, selectQuality } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; const { PlayerController } = createPlayer({ features: videoFeatures }); class QualityInfo extends UIElement { readonly #quality = new PlayerController(this, selectQuality); } ``` --- # Audio track Audio track state and actions for the player store Tracks available audio tracks and selects the enabled track. ## Import ```ts import { audioTrackFeature } from '@videojs/html'; ``` The `videoFeatures` [feature bundle](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/presets) includes this feature. ## API Reference ### State | Property | Type | Description | | --- | --- | --- | | `audioTrackList` | `MediaAudioTrack[]` | Audio tracks available for manual track selection. | ### Actions | Action | Type | Description | | --- | --- | --- | | `selectAudioTrack` | `(id: string) => void` | Select an audio track by `id`. | ### Selector Pass `selectAudioTrack` to [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) to subscribe to audio track state. Returns `undefined` if the audio track feature is not configured. **audio-track-info.ts** ```ts import { createPlayer, UIElement, selectAudioTrack } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; const { PlayerController } = createPlayer({ features: videoFeatures }); class AudioTrackInfo extends UIElement { readonly #audioTrack = new PlayerController(this, selectAudioTrack); } ``` --- # Remote Playback Remote playback state and actions for the player store Controls remote playback to devices like Chromecast (Chromium) and AirPlay (Safari). Exits fullscreen before initiating a remote playback session. - [Cast to AirPlay and Chromecast](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/casting) ## Import ```ts import { remotePlaybackFeature } from '@videojs/html'; ``` The `liveVideoFeatures` and `videoFeatures` [feature bundles](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/presets) include this feature. ## API Reference ### State | Property | Type | Description | | --- | --- | --- | | `remotePlaybackState` | `'disconnected' \| 'connecting' \| 'connected'` | Current remote playback connection state. | | `remotePlaybackAvailability` | `'available' \| 'unavailable' \| 'unsupported'` | Whether remote playback can be requested on this platform. | ### Actions | Action | Type | Description | | --- | --- | --- | | `promptRemotePlayback` | `() => Promise` | Prompt the user to pick a remote playback device. Exits fullscreen first when connecting. | ### Selector Pass `selectRemotePlayback` to [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) to subscribe to remote playback state. Returns `undefined` if the remote playback feature is not configured. **cast-button.ts** ```ts import { createPlayer, UIElement, selectRemotePlayback } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; const { PlayerController } = createPlayer({ features: videoFeatures }); class CastButton extends UIElement { readonly #remotePlayback = new PlayerController(this, selectRemotePlayback); } ``` --- # Source Media source state and actions for the player store Tracks the loaded media resource and how much of it is ready. To change the source, set `src` or `source` on the media element, which also carries type and engine configuration. ## Import ```ts import { sourceFeature } from '@videojs/html'; ``` The `audioFeatures`, `liveAudioFeatures`, `liveVideoFeatures`, and `videoFeatures` [feature bundles](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/presets) include this feature. ## API Reference ### State | Property | Type | Description | | --- | --- | --- | | `currentSrc` | `string` | Current media source URL (empty string if none). | | `canPlay` | `boolean` | Whether enough data is loaded to begin playback. | ### Selector Pass `selectSource` to [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) to subscribe to source state. Returns `undefined` if the source feature is not configured. **source-info.ts** ```ts import { createPlayer, UIElement, selectSource } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; const { PlayerController } = createPlayer({ features: videoFeatures }); class SourceInfo extends UIElement { readonly #source = new PlayerController(this, selectSource); } ``` --- # Stream type Stream delivery type (live / on-demand) state for the player store Tracks whether the current source is live, on-demand, or not known yet. Use it to choose which controls to show. `streamType` is `'live'`, `'on-demand'`, or `'unknown'`. It does not tell you how close playback is to the live edge or whether viewers can rewind. HLS media reads the stream type from the loaded playlist. If you set `streamType` yourself, your value takes priority until you set it back to `'unknown'`. Other media falls back to the browser’s duration: `Infinity` means live, a finite positive value means on-demand, and any other value means unknown. Add `streamTypeFeature` to a custom player when you need `streamType` in player state. The live presets separately include the [live feature](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/feature-live), which tracks the live edge. ## Import ```ts import { streamTypeFeature } from '@videojs/html'; ``` No packaged [feature bundle](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/presets) includes this feature — add it to your [`createPlayer`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/html-create-player) features yourself. ## API Reference ### State | Property | Type | Description | | --- | --- | --- | | `streamType` | `'on-demand' \| 'live' \| 'unknown'` | Current stream delivery type. Components use this to show live-specific UI (for example, a live indicator or a "jump to live edge" button) or hide the time display. | ### Selector Pass `selectStreamType` to [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) to subscribe to stream type state. Returns `undefined` if the stream type feature is not configured. **live-indicator.ts** ```ts import { createPlayer, selectStreamType, streamTypeFeature, UIElement } from '@videojs/html'; import { liveVideoFeatures } from '@videojs/html/live-video'; const { PlayerController } = createPlayer({ features: [...liveVideoFeatures, streamTypeFeature], }); class LiveIndicator extends UIElement { readonly #stream = new PlayerController(this, selectStreamType); } ``` --- # Text tracks Subtitles, captions, and chapter track state for the player store Manages subtitles, captions, chapters, and thumbnail tracks. A default `kind="chapters"` track can also divide the [time slider](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/components/time-slider) into chapter ranges and label the chapter at the current interaction position. `thumbnailsTrack` is the first `kind="metadata"` track labeled `thumbnails`, or `null` when there is none. Its `crossOrigin` reports the media element’s CORS mode, or `null` when the media is not CORS-enabled. [Thumbnail](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/components/thumbnail) reads it to fetch sprite sheets the same way the browser fetched the track. ## Import ```ts import { textTrackFeature } from '@videojs/html'; ``` The `liveVideoFeatures` and `videoFeatures` [feature bundles](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/presets) include this feature. ## API Reference ### State | Property | Type | Description | | --- | --- | --- | | `textTrackList` | `MediaTextTrack[]` | All text tracks available on the media element. | | `subtitlesShowing` | `boolean` | Whether a captions/subtitles track is showing. | | `chaptersCues` | `MediaTextCue[]` | Cues from the first `kind="chapters"` track, with cue ends clamped to a finite media duration. | | `thumbnailsTrack` | `{ cues: MediaTextCue[]; src: string \| null; crossOrigin: 'anonymous' \| 'use-credentials' \| null } \| null` | The first thumbnails track, or `null` when there is none. | ### Actions | Action | Type | Description | | --- | --- | --- | | `toggleSubtitles` | `(forceShow?: boolean) => boolean` | Toggle captions/subtitles visibility. Showing restores the track that was last showing, or the first caption/subtitle track when there is none. Returns the new enabled value. | | `selectSubtitlesTrack` | `(id: string \| null) => void` | Show the captions/subtitles track with `id`, or turn captions/subtitles off with `null`. | ### Selector Pass `selectTextTrack` to [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) to subscribe to text track state. Returns `undefined` if the text tracks feature is not configured. **captions-button.ts** ```ts import { createPlayer, UIElement, selectTextTrack } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; const { PlayerController } = createPlayer({ features: videoFeatures }); class CaptionsButton extends UIElement { readonly #textTracks = new PlayerController(this, selectTextTrack); } ``` --- # Time Playback position and duration state for the player store Tracks playback position and duration. During live playback, the browser may report `Infinity` as the duration. The player reports the end of the last available [seekable range](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/feature-buffer) instead, so the value stays finite and moves forward with the stream. This is the newest available time, not the length of the rewindable window; its first available time may be greater than zero. Use [live state](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/feature-live) or [stream type](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/feature-stream-type) to check whether the source is live. ## Import ```ts import { timeFeature } from '@videojs/html'; ``` The `audioFeatures`, `liveAudioFeatures`, `liveVideoFeatures`, and `videoFeatures` [feature bundles](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/presets) include this feature. ## API Reference ### State | Property | Type | Description | | --- | --- | --- | | `currentTime` | `number` | Current playback position in seconds. | | `duration` | `number` | Total duration in seconds (0 if unknown). | | `seeking` | `boolean` | Whether a seek operation is in progress. | ### Actions | Action | Type | Description | | --- | --- | --- | | `seek` | `(time: number) => Promise` | Seek to a time in seconds. Returns the actual position after seek. | ### Selector Pass `selectTime` to [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) to subscribe to time state. Returns `undefined` if the time feature is not configured. **time-display.ts** ```ts import { createPlayer, UIElement, selectTime } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; const { PlayerController } = createPlayer({ features: videoFeatures }); class TimeDisplay extends UIElement { readonly #time = new PlayerController(this, selectTime); } ``` --- # Volume Volume level and mute state for the player store Controls volume level and mute state. These capabilities have independent availability values because media can support mute without supporting volume-level changes. ## Import ```ts import { volumeFeature } from '@videojs/html'; ``` The `audioFeatures`, `liveAudioFeatures`, `liveVideoFeatures`, and `videoFeatures` [feature bundles](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/presets) include this feature. ## API Reference ### State | Property | Type | Description | | --- | --- | --- | | `volume` | `number` | Volume level from 0 (silent) to 1 (max). | | `muted` | `boolean` | Whether audio is muted. | | `volumeAvailability` | `'available' \| 'unavailable' \| 'unsupported'` | Whether volume can be programmatically set on this platform. | | `mutedAvailability` | `'available' \| 'unavailable' \| 'unsupported'` | Whether the media can be muted. Separate from `volumeAvailability` because the two come apart: an embed can take a mute command while offering no way to set a level, and iOS Safari refuses a volume write on media that mutes perfectly well. | ### Actions | Action | Type | Description | | --- | --- | --- | | `setVolume` | `(volume: number) => number` | Set volume (clamped 0-1). Returns the clamped value. | | `setMuted` | `(muted: boolean) => boolean` | Set the muted state, updating the store immediately. Unmuting at volume 0 restores volume to 0.25. Returns the new muted value. | ### Selector Pass `selectVolume` to [`PlayerController`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/player-controller) to subscribe to volume state. Returns `undefined` if the volume feature is not configured. Check `volumeAvailability` before showing a volume-level control, and check `mutedAvailability` before showing a mute control. **volume-slider.ts** ```ts import { createPlayer, UIElement, selectVolume } from '@videojs/html'; import { videoFeatures } from '@videojs/html/video'; const { PlayerController } = createPlayer({ features: videoFeatures }); class VolumeSlider extends UIElement { readonly #volume = new PlayerController(this, selectVolume); } ``` --- # createI18n Factory that creates framework i18n helpers with custom loading options ## Import ```ts import { createI18n } from "@videojs/html/i18n"; ``` `createI18n` returns a context-bound `ProviderMixin`, `TextMixin`, and `I18nController` for custom elements. Use it when you need a custom locale loader or custom i18n elements. Most apps use `` and `` from `@videojs/html/i18n`. ```ts import { ReactiveElement } from '@videojs/element'; import { createI18n } from '@videojs/html/i18n'; const { ProviderMixin, TextMixin } = createI18n(); class LocalizedRoot extends ProviderMixin(ReactiveElement) {} class LocalizedText extends TextMixin(ReactiveElement) {} ``` ## API Reference `createI18n(options?): CreateI18nResult` ### Parameters | Parameter | Type | Default | | --- | --- | --- | | `options` | `{ loader?: ((tag: string) => Promise \| undefined>) }` | — | ### Return Value | Property | Type | | --- | --- | | `context` | `Context` | | `I18nController` | `typeof I18nController` | | `ProviderMixin` | `((Base: Base) => Constructor & Base)` | | `TextMixin` | `((Base: Base) => Constructor & Base)` | --- # media-i18n HTML custom element that resolves locale and supplies translations to descendants ## Import ```ts import "@videojs/html/i18n"; ``` One import registers both `` and ``. `` applies the i18n provider mixin to a subtree. Wrap a player, standalone controls, or one of several players that need different locales with this element. Without it, HTML controls use English defaults. Set `lang` on the provider or an ancestor. Built-in packs lazy-load automatically; register locale strings with [`registerI18n`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/register-i18n) when you need custom copy or synchronous first paint. See [Translation phrases](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/translation-phrases) for supported keys. ```html Play ``` ## Attributes | Attribute | Description | | --- | --- | | `lang` | Forces the active BCP 47 locale for this subtree. Omit to inherit the nearest ancestor `[lang]`. | ## Related - [``](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/media-text): Renders translated text content - [Internationalize the player](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/internationalization) --- # media-text HTML custom element that renders a translated string by semantic key ## Import ```ts import "@videojs/html/i18n"; ``` One import registers both `` and ``. `` renders a translated value inside a [``](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/media-i18n) (or any ancestor with the i18n provider mixin). Set `token` to the semantic translation key and use the text content as its English fallback. Use it for authored component content, standalone labels, tooltips, or demos. ```html Play ``` ## Token and fallback The `token` attribute accepts an opaque key such as `buttons.play`. The initial text content is the fallback shown when the active locale has no value for that key. See [Translation phrases](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/translation-phrases) for the supported keys and English defaults. Without `token`, `` keeps its text content unchanged. This is useful for literal copy that should not be translated. Parametric translations are not yet supported on ``. Use `createTranslator` in script for interpolated strings. --- # Translation phrases Semantic i18n keys, their English defaults, and the player UI that uses them Video.js uses opaque semantic keys so English copy can change without breaking translation packs. English defaults are defined in `packages/core/src/core/i18n/locales/en.ts`. Both HTML and React controls use the same keys. Locale packs and provider overrides use nested objects, so `buttons.play` is authored as `{ buttons: { play: '…' } }`. Translators and the `` attribute use the dotted form. ## Playback controls | Key | English default | Used by | | --- | --- | --- | | `buttons.play` | Play | Play button and its tooltip | | `buttons.pause` | Pause | Play button and its tooltip | | `buttons.replay` | Replay | Play button and its tooltip | | `buttons.mute` | Mute | Mute button and its tooltip | | `buttons.unmute` | Unmute | Mute button and its tooltip | | `seek.forward` | Seek forward `{seconds}` seconds | Seek-forward button and its tooltip | | `seek.backward` | Seek backward `{seconds}` seconds | Seek-backward button and its tooltip | | `fullscreen.enter` | Enter fullscreen | Fullscreen button | | `fullscreen.exit` | Exit fullscreen | Fullscreen button | | `captions.enable` | Enable captions | Captions button and captions selection control | | `captions.disable` | Disable captions | Captions button and captions selection control | | `pip.enter` | Enter picture-in-picture | Picture-in-picture button | | `pip.exit` | Exit picture-in-picture | Picture-in-picture button | | `live.playing` | Playing live | Live button | | `live.seekToEdge` | Seek to live edge | Live button | | `live.badge` | Live | Live button badge | | `cast.start` | Start casting | Cast button | | `cast.stop` | Stop casting | Cast button | | `cast.connecting` | Connecting | Cast button | | `airplay.start` | Start AirPlay | AirPlay button | | `airplay.stop` | Stop AirPlay | AirPlay button | | `container.label` | Media player | Player container aria label | ## Time and volume | Key | English default | Used by | | --- | --- | --- | | `slider.seek` | Seek | Time slider aria label | | `time.current` | Current time | Current-time display aria label | | `time.duration` | Duration | Duration display aria label | | `time.remaining` | Remaining | Remaining-time display aria label | | `time.elapsedSuffix` | `{duration} elapsed` | Elapsed time in a toggleable display aria label | | `time.durationSuffix` | `{duration} duration` | Duration in a toggleable display aria label | | `time.remainingSuffix` | `{duration} remaining` | Remaining time display | | `time.showElapsed` | `Show elapsed time, {duration}.` | Toggleable time display aria label | | `time.showDuration` | `Show duration, {duration}.` | Toggleable time display aria label | | `time.showRemaining` | `Show remaining time, {duration}.` | Toggleable time display aria label | | `time.toggleElapsed` | `Toggle between elapsed and remaining time.` | Elapsed-time toggle aria description | | `time.toggleDuration` | `Toggle between duration and remaining time.` | Duration toggle aria description | | `time.position` | `{current} of {duration}` | Time slider value text | | `time.unknown` | Media not loaded, unknown time. | Time display aria label and time slider value text before a duration is known | | `playback.rate` | Playback rate `{rate}` | Playback-rate button and radio group | | `volume.mutedValue` | `{percent}, muted` | Muted volume slider value text | | `volume.muted` | Muted | Volume input feedback | | `volume.label` | Volume | Volume slider aria label | | `volume.value` | Volume `{value}` | Volume input feedback | ## Playback feedback | Key | English default | Used by | | --- | --- | --- | | `status.captionsOn` | Captions on | Input feedback after enabling captions | | `status.captionsOff` | Captions off | Input feedback after disabling captions | | `status.paused` | Paused | Input feedback after pausing | | `status.playing` | Playing | Input feedback after starting playback | | `status.fullscreen` | Fullscreen | Input feedback after entering fullscreen | | `status.pip` | Picture in picture | Input feedback after entering picture-in-picture | | `status.exitPip` | Exit picture in picture | Input feedback after exiting picture-in-picture | | `status.seekedTo` | Seeked to `{time}` | Status announcer after a seek | ## Errors | Key | English default | Used by | | --- | --- | --- | | `errors.aborted` | You stopped media playback before it finished. | Media error dialog for `MEDIA_ERR_ABORTED` | | `errors.network` | This media could not be loaded due to a network or server issue. | Media error dialog for `MEDIA_ERR_NETWORK` | | `errors.decode` | This media could not be played. It may be corrupted, or your browser may not support its format. | Media error dialog for `MEDIA_ERR_DECODE` | | `errors.source` | This media could not be loaded. It may be unavailable, or your browser may not support its format. | Media error dialog for `MEDIA_ERR_SRC_NOT_SUPPORTED` | | `errors.encrypted` | This media could not be played because it could not be decrypted. | Media error dialog for `MEDIA_ERR_ENCRYPTED` | | `errors.unplayable` | This media is unsupported by the player. | Media error dialog when the player cannot play a source the browser supports | | `errors.title` | Something went wrong. | Generic media error dialog title | | `errors.unexpected` | An unexpected error occurred. | Generic media error dialog fallback description | | `common.empty` | `''` | Empty description for a custom media error | | `common.ok` | OK | Error dialog confirmation button | ## Settings and track menus | Key | English default | Used by | | --- | --- | --- | | `menu.settings` | Settings | Video settings menu trigger | | `menu.quality` | Quality | Quality menu | | `menu.audio` | Audio | Audio-track menu and fallback track label | | `menu.default` | Default | Reserved default-option label; no stock control currently emits it | | `menu.speed` | Speed | Playback-rate menu | | `menu.captions` | Captions | Captions menu | | `menu.playbackRate` | Playback rate | Playback-rate radio group | | `menu.back` | Back | Nested settings-menu back button | | `menu.off` | Off | Captions menu option | | `menu.auto` | Auto | Automatic-quality option | | `menu.autoWithLabel` | Auto (`{label}`) | Automatic-quality option with the active rendition | | `menu.subtitles` | Subtitles | Subtitles track option | ## Related pages - [Internationalize the player](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/internationalization): Translate player labels and announcements: shipped locale packs, custom translations, runtime switching, and server rendering. --- # registerI18n Register or merge translation strings for a BCP 47 locale tag in the global i18n registry ## Import ```ts import { registerI18n } from "@videojs/html/i18n"; ``` `registerI18n` merges a partial translation map into the process-wide registry for a locale tag. Components carry their own English fallback text. Built-in non-English packs lazy-load automatically; call `registerI18n` for custom locales, CDN locale modules, or patched shipped packs before the provider renders. Keys are nested semantic names such as `buttons.play` and `buttons.pause`. See [Translation phrases](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/translation-phrases) for the complete catalog. ```ts import { registerI18n } from '@videojs/html/i18n'; registerI18n('es', { buttons: { play: 'Reproducir', pause: 'Pausar', }, }); ``` ## API Reference `registerI18n(locale, translations): void` ### Parameters | Parameter | Type | Default | Description | | --- | --- | --- | --- | | `locale` (required) | `(typeof LOCALES)[number] \| string & {}` | — | BCP 47 tag (normalized to lowercase; unicode extensions stripped for the registry key). | | `translations` (required) | `Partial` | — | Partial nested locale values; merges with any existing layer for the tag. | ### Return Value `void` --- # getI18nTranslations Read the merged translation map for a locale using BCP 47 parent-chain fallback ## Import ```ts import { getI18nTranslations } from "@videojs/html/i18n"; ``` `getI18nTranslations` walks the BCP 47 lookup chain (`es-MX` → `es` → `en`) and merges registry layers into one map. Providers combine this map with lazy-loaded built-in packs and provider overrides. Call it directly when building custom UI outside built-in controls. See [Internationalize the player](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/internationalization) for merge order and fallback rules. ```ts import { createTranslator, getI18nTranslations } from '@videojs/html/i18n'; const t = createTranslator(getI18nTranslations('pt-BR'), 'pt-BR'); t('buttons.play', { default: 'Play' }); ``` ## API Reference `getI18nTranslations(locale): FlatTranslations` ### Parameters | Parameter | Type | Default | Description | | --- | --- | --- | --- | | `locale` (required) | `(typeof LOCALES)[number] \| string & {}` | — | BCP 47 tag to resolve (e.g. `es-MX`, `zh-Hant-HK`). | ### Return Value | Type | | --- | | `{ [Key in TranslationKey]?: TranslationParams[Key] extends never ? string : Key extends keyof ParametricTranslations ? ParametricTranslations[Key] : string; } & Record` | --- # hasRegisteredLocale Check whether an exact locale tag exists in the global i18n registry ## Import ```ts import { hasRegisteredLocale } from "@videojs/html/i18n"; ``` `hasRegisteredLocale` returns whether a normalized locale tag has an explicit registry layer from [`registerI18n`](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/register-i18n). It does **not** indicate whether a lazy built-in pack exists. Only registry entries count. ```ts import { hasRegisteredLocale, registerI18n } from '@videojs/html/i18n'; hasRegisteredLocale('fr'); // false until registered registerI18n('fr', { buttons: { play: 'Lecture' } }); hasRegisteredLocale('fr'); // true ``` ## API Reference `hasRegisteredLocale(locale): boolean` ### Parameters | Parameter | Type | Default | Description | | --- | --- | --- | --- | | `locale` (required) | `(typeof LOCALES)[number] \| string & {}` | — | BCP 47 tag to test. | ### Return Value `boolean` --- # onI18nRegistryChange Subscribe to global i18n registry mutations ## Import ```ts import { onI18nRegistryChange } from "@videojs/html/i18n"; ``` `onI18nRegistryChange` registers a callback that runs whenever any locale layer changes, for example after `registerI18n` or browser translation prefetch. Returns an unsubscribe function. ## API Reference `onI18nRegistryChange(callback): (() => void)` ### Parameters | Parameter | Type | Default | Description | | --- | --- | --- | --- | | `callback` (required) | `(() => void)` | — | Invoked when any locale layer changes. | ### Return Value | Type | | --- | | `(() => void)` | --- # createTranslator Build a typed translator from a resolved translation map ## Import ```ts import { createTranslator } from "@videojs/html/i18n"; ``` `createTranslator` wraps the flat map returned by `getI18nTranslations` and returns a typed translator. Providers call this internally after merging registry, lazy-loaded built-in packs, browser-translated fallback copy, and provider layers. Use it directly for custom UI outside built-in controls. ```ts import { createTranslator, getI18nTranslations } from '@videojs/html/i18n'; const t = createTranslator(getI18nTranslations('fr'), 'fr'); t('buttons.play', { default: 'Play' }); t('seek.forward', { seconds: 5, default: 'Seek forward {seconds} seconds' }); ``` ## API Reference `createTranslator(translations, locale): Translator` ### Parameters | Parameter | Type | Default | Description | | --- | --- | --- | --- | | `translations` (required) | `{ [Key in TranslationKey]?: TranslationParams[Key] extends never ? string : Key extends keyof ParametricTranslations ? ParametricTranslations[Key] : string; } & Record` | — | Merged translation map for the active locale. | | `locale` (required) | `(typeof LOCALES)[number] \| string & {}` | — | BCP 47 tag associated with the map (reserved for future locale-aware behavior). | ### Return Value | Type | | --- | | `{ (key: Key, ...args: Key extends TranslationKey ? TranslationParams[Key] extends never ? [params?: TranslationOptions] : [params: TranslationParams[Key] & TranslationOptions] : [params?: TextParams & TranslationOptions]): string; (text: Text, params?: TextParams): string }` | --- # I18nController Reactive controller for consuming translator and locale values from an HTML i18n context ## Import ```ts import { I18nController } from "@videojs/html"; ``` ## Usage Create the controller with a reactive host and an i18n context. Read the translator from `value` and the active locale from `locale`. ```ts import { I18nController, UIElement, i18nContext } from "@videojs/html"; class LocalizedPlayLabel extends UIElement { readonly #i18n = new I18nController(this, i18nContext); get label() { return this.#i18n.value("buttons.play", { default: "Play" }); } } ``` The controller requests a host update when its context changes. Without a provider, it falls back to the default English locale and updates when registered translations change. ## API Reference `new I18nController(host, context)` ### Parameters | Parameter | Type | Default | Description | | --- | --- | --- | --- | | `host` (required) | `{ addController(controller: ReactiveController): void; removeController(controller: ReactiveController): void; requestUpdate(): void; updateComplete: Promise } & HTMLElement` | — | Reactive host updated when the i18n value changes. | | `context` (required) | `Context` | — | I18n context to consume. | ### Return Value | Property | Type | | --- | --- | | `value` | `Translator` | | `locale` | `(typeof LOCALES)[number] \| string & {}` | --- # AriaKeyShortcutsController Reactive controller that exposes registered hotkey shortcut metadata ## Import ```ts import { AriaKeyShortcutsController } from "@videojs/html"; ``` ## Usage Create the controller on a reactive element inside a player container. It follows the container’s hotkey registrations and requests a host update when they change. ```ts class CustomPlayButton extends UIElement { readonly #shortcut = new AriaKeyShortcutsController(this, "togglePaused"); get ariaKeyShortcuts() { return this.#shortcut.aria; } get shortcutLabel() { return this.#shortcut.shortcut; } } ``` Use `aria` for the element’s `aria-keyshortcuts` value and `shortcut` for display text. Both are `undefined` until the matching action has a registered shortcut. ## API Reference `new AriaKeyShortcutsController(host, action, options?)` ### Parameters | Parameter | Type | Default | Description | | --- | --- | --- | --- | | `host` (required) | `{ addController(controller: ReactiveController): void; removeController(controller: ReactiveController): void; requestUpdate(): void; updateComplete: Promise } & HTMLElement` | — | Host element whose nearest player container supplies hotkey registrations. | | `action` (required) | `string` | — | Registered hotkey action to look up. | | `options` | `{ value?: (() => number \| undefined) }` | `{}` | Optional value resolver for value-dependent shortcuts. | ### Return Value | Property | Type | | --- | --- | | `value` | `string \| undefined` | | `aria` | `string \| undefined` | | `shortcut` | `string \| undefined` | | `details` | `{ aria?: string; shortcut?: string }` | --- # Error Codes Error codes emitted by the video.js package and how to resolve them Playback failures use the [error feature](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/feature-error) instead. See [Handle playback errors](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/playback-errors) for application handling. ## Video.js 8 Error Codes The `video.js` package throws these `VJS8_LEGACY_*` errors when code calls a Video.js 8 API that does not exist in Video.js 10. Each code identifies the old API and its Video.js 10 equivalent. - [VJS8_LEGACY_INIT](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/vjs8-legacy-init) `videojs()` was the Video.js 8 API. Video.js 10 has no factory; players are components you compose. - [VJS8_LEGACY_PLUGIN](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/vjs8-legacy-plugin) `videojs.registerPlugin()` was the Video.js 8 plugin system. Video.js 10 has no plugin registry. - [VJS8_LEGACY_COMPONENT](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/vjs8-legacy-component) `videojs.registerComponent()` was the Video.js 8 component tree. Video.js 10 components are custom elements and React components. - [VJS8_LEGACY_GET_PLAYER](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/vjs8-legacy-get-player) `videojs.getPlayer()` looked players up by id. Video.js 10 has no registry; hold a reference to the element. - [VJS8_LEGACY_OPTIONS](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/reference/api/vjs8-legacy-options) `videojs.options` held Video.js 8 global defaults. Video.js 10 has no global; configuration lives on the components you render. --- # VJS8_LEGACY_INIT Legacy Video.js 8 player initialization error `videojs()` was the Video.js 8 API. Video.js 10 has no factory; players are components you compose. ## Trigger ```javascript const player = videojs('my-video', { controls: true }); ``` ## Video.js 10 equivalent Keep `import 'video.js'`, remove the factory call, and render ``. See [Migrate from Video.js 8](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/migrate-from-video-js-8) for the full setup. ## Video.js 8 Video.js 8 continues to receive security patches. Its documentation is at [legacy.videojs.org](https://legacy.videojs.org). Pin the major version with `npm install video.js@8` to keep using it. --- # VJS8_LEGACY_PLUGIN Legacy Video.js 8 plugin registration error `videojs.registerPlugin()` was the Video.js 8 plugin system. Video.js 10 has no plugin registry. ## Trigger ```javascript videojs.registerPlugin('myPlugin', function () { /* ... */ }); ``` ## Video.js 10 equivalent Compose behavior as components inside ``, or add an extension such as `@videojs/google-cast`. See [Migrate from Video.js 8](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/migrate-from-video-js-8) for the full setup. ## Video.js 8 Video.js 8 continues to receive security patches. Its documentation is at [legacy.videojs.org](https://legacy.videojs.org). Pin the major version with `npm install video.js@8` to keep using it. --- # VJS8_LEGACY_COMPONENT Legacy Video.js 8 component registration error `videojs.registerComponent()` was the Video.js 8 component tree. Video.js 10 components are custom elements and React components. ## Trigger ```javascript videojs.registerComponent('MyButton', MyButton); ``` ## Video.js 10 equivalent Define a custom element and place it inside `` or your own skin markup. See [Migrate from Video.js 8](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/migrate-from-video-js-8) for the full setup. ## Video.js 8 Video.js 8 continues to receive security patches. Its documentation is at [legacy.videojs.org](https://legacy.videojs.org). Pin the major version with `npm install video.js@8` to keep using it. --- # VJS8_LEGACY_GET_PLAYER Legacy Video.js 8 player lookup error `videojs.getPlayer()` looked players up by id. Video.js 10 has no registry; hold a reference to the element. ## Trigger ```javascript const player = videojs.getPlayer('my-video'); ``` ## Video.js 10 equivalent `document.querySelector('video-player')` and call actions on its `store.state`. See [Migrate from Video.js 8](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/migrate-from-video-js-8) for the full setup. ## Video.js 8 Video.js 8 continues to receive security patches. Its documentation is at [legacy.videojs.org](https://legacy.videojs.org). Pin the major version with `npm install video.js@8` to keep using it. --- # VJS8_LEGACY_OPTIONS Legacy Video.js 8 global options error `videojs.options` held Video.js 8 global defaults. Video.js 10 has no global; configuration lives on the components you render. ## Trigger ```javascript videojs.options.autoplay = true; ``` ## Video.js 10 equivalent Set attributes on ``, ``, and the media element. See [Migrate from Video.js 8](https://deploy-preview-2970--vjs10-site.netlify.app/docs/framework/html/guides/migrate-from-video-js-8) for the full setup. ## Video.js 8 Video.js 8 continues to receive security patches. Its documentation is at [legacy.videojs.org](https://legacy.videojs.org). Pin the major version with `npm install video.js@8` to keep using it.