selectControls
Select the controls state slice from the player store
Import
import { selectControls } from '@videojs/core/dom';Usage
Pass selectControls to usePlayer (React) or PlayerController (HTML) to subscribe to controls state. Returns undefined if the controls feature is not configured.
The returned state includes whether controls are visible and whether the user is active (interacting with the player).
import { usePlayer } from '@videojs/react';
import { selectControls } from '@videojs/core/dom';
function ControlsOverlay({ children }: { children: React.ReactNode }) {
const controls = usePlayer(selectControls);
if (!controls) return null;
return (
<div style={{ opacity: controls.visible ? 1 : 0 }}>
{children}
</div>
);
}import { createPlayer, features, MediaElement } from '@videojs/html';
import { selectControls } from '@videojs/core/dom';
const { PlayerController, context } = createPlayer({ features: features.video });
class ControlsOverlay extends MediaElement {
#controls = new PlayerController(this, context, selectControls);
}API Reference
Parameters
| Parameter | Type | Default | |
|---|---|---|---|
state* | {} | — |
Return Value
MediaControlsState | undefined