Skip to content

ReferenceFeatures

Playback

Play/pause state and actions for the player store

Controls play/pause state and tracks whether playback has started or is stalled.

When the media has autoplay, autoplaying is true from the moment a source loads until playback starts. It also turns false when the autoplay is refused: browsers don’t announce that, so it shows as the media being able to play through but staying paused, and embeds report it with a pause or error event. Treat it as playback about to begin: the play button shows pause and the buffering indicator shows while it’s true, and pause() cancels it.

Import

import { playbackFeature } from '@videojs/html';

The audioFeatures, liveAudioFeatures, liveVideoFeatures, and videoFeatures feature bundles include this feature.

API Reference

State

PropertyTypeDetails
pausedboolean
endedboolean
startedboolean
waitingboolean
autoplayboolean
autoplayingboolean

Actions

ActionTypeDetails
playfunction
pausefunction

Selector

Pass selectPlayback to PlayerController to subscribe to playback state. Returns undefined if the playback feature is not configured.

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);
}