Skip to main content
Controls play/pause state and tracks whether playback has started or is stalled. Required by PlayButton and buffering indicator components.

Import

import { playback, selectPlayback } from '@videojs/react';
// or
import { playback, selectPlayback } from '@videojs/html';

Usage

import { createPlayer, playback } from '@videojs/react';

const Player = createPlayer({
  features: [playback],
});

State

paused
boolean
Whether playback is currently paused.
ended
boolean
Whether playback has reached the end of the media.
started
boolean
Whether playback has started (played or seeked at least once).
waiting
boolean
Whether playback is stalled waiting for more data to buffer.

Actions

play()
() => Promise<void>
Start playback. Returns a promise that resolves when playback begins.
pause()
() => void
Pause playback.

Selector

Use selectPlayback to subscribe to only the playback slice of state. Returns undefined if the playback feature is not configured.
import { selectPlayback, usePlayer } from '@videojs/react';

function PlayButton() {
  const playback = usePlayer(selectPlayback);
  if (!playback) return null;

  return (
    <button onClick={playback.paused ? playback.play : playback.pause}>
      {playback.paused ? 'Play' : 'Pause'}
    </button>
  );
}
Required by: PlayButton, BufferingIndicator

Build docs developers (and LLMs) love