Controls
User activity and controls visibility state for the player store
Read-only — tracks user activity for showing and hiding controls.
Import
import { controlsFeature } from '@videojs/react';import { controlsFeature } from '@videojs/html';The liveVideoFeatures and videoFeatures feature bundles include this feature.
API Reference
State
| Property | Type | Details |
|---|---|---|
userActive | boolean | |
| ||
controlsVisible | boolean | |
| ||
Actions
| Action | Type | Details |
|---|---|---|
requestControlsLock | () => (() => void) | |
| ||
toggleControls | () => boolean | |
| ||
Selector
Pass selectControls to usePlayer to subscribe to controls state. Returns undefined if the controls feature is not configured.
Pass selectControls to PlayerController to subscribe to controls state. Returns undefined if the controls feature is not configured.
import { selectControls, usePlayer } from '@videojs/react';
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, 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);
}