From c3d70e50ac6f76c9c42a5b0d248e966fa9ba0bec Mon Sep 17 00:00:00 2001 From: Darius Cepulis Date: Tue, 7 Jul 2026 14:27:30 -0500 Subject: [PATCH] docs(site): rework Google Cast concept page and move it in the sidebar (#1806) Co-authored-by: Claude --- site/src/content/docs/concepts/cast.mdx | 177 ++++++++++++++---------- site/src/docs.config.ts | 2 +- 2 files changed, 106 insertions(+), 73 deletions(-) diff --git a/site/src/content/docs/concepts/cast.mdx b/site/src/content/docs/concepts/cast.mdx index d4d132cb..cecea865 100644 --- a/site/src/content/docs/concepts/cast.mdx +++ b/site/src/content/docs/concepts/cast.mdx @@ -1,6 +1,6 @@ --- title: Google Cast -description: How to add Chromecast support to your Video.js player — lazy SDK loading, session lifecycle, and configuration options +description: Cast playback to Chromecast devices with built-in Google Cast support, and configure the receiver and load request --- import FrameworkCase from '@/components/docs/FrameworkCase.astro'; @@ -8,34 +8,80 @@ import DocsLink from '@/components/docs/DocsLink.astro'; import DocsLinkCard from '@/components/docs/DocsLinkCard.astro'; import Aside from '@/components/Aside.astro'; -Video.js has built-in Google Cast support for HLS and DASH media elements. When a Chromecast device is on the same network, a Cast button appears automatically in Chromium browsers. Tapping it starts a session that moves playback to the TV while the browser stays in control. +Video.js streaming media elements (HLS and DASH) have Google Cast built in. Add a CastButton and users can move playback to a Chromecast device while the browser stays in control: + + +```tsx title="App.tsx" +import { CastButton, createPlayer } from '@videojs/react'; +import { HlsJsVideo } from '@videojs/react/media/hlsjs-video'; +import { videoFeatures } from '@videojs/react/video'; + +const Player = createPlayer({ features: videoFeatures }); + +export default function App() { + return ( + + + + + + + ); +} +``` + + + +```html title="index.html" + + + + + + +``` + + +The pre-built skins include a Cast button already. It appears when a Chromecast device is on the network and stays hidden otherwise. ## How Cast works Cast uses a **sender / receiver** model: -- **Sender** — the browser tab. It controls playback commands (play, pause, seek, volume) and sends a load request to the receiver with the source URL and metadata. -- **Receiver** — the Chromecast device running the default media receiver application (or a custom receiver you configure). +- **Sender** — the browser tab. It sends the receiver a load request with the source URL and metadata, then issues playback commands (play, pause, seek, volume). +- **Receiver** — the Chromecast device running a receiver application: Google's default media receiver, or a custom one you configure. ### Session lifecycle -A Cast session moves through three states, exposed via the Remote Playback feature: +A Cast session moves through three states, exposed by the Remote Playback feature: | State | Meaning | |---|---| | `'disconnected'` | No active session | -| `'connecting'` | User accepted; session negotiating | -| `'connected'` | Receiver is playing | +| `'connecting'` | Device picked; session starting | +| `'connected'` | Session active; receiver has the media | While `connected`, the media element's `play`, `pause`, `currentTime`, `volume`, `muted`, and `playbackRate` all proxy to the Cast receiver. Local playback is suspended. ### The lazy-loaded SDK -The Cast SDK (`cast_sender.js`) is injected into the page as a `