Skip to content
FrameworkStyle

Cast

Cast state and actions for the player store

Controls casting to remote playback devices (e.g. Chromecast). Exits fullscreen before initiating a cast session.

API Reference

State

Property Type Details
castState 'disconnected' | 'connecting' | 'connected'
castAvailability 'available' | 'unavailable' | 'unsupported'

Actions

Action Type Details
toggleCast () => Promise<void>

Selector

Pass selectCast to usePlayer to subscribe to cast state. Returns undefined if the cast feature is not configured.

import { selectCast, usePlayer } from '@videojs/react';

function CastButton() {
  const cast = usePlayer(selectCast);
  if (!cast || cast.castAvailability !== 'available') return null;

  return (
    <button onClick={cast.toggleCast}>
      {cast.castState === 'connected' ? 'Disconnect' : 'Cast'}
    </button>
  );
}