Remote Playback
Remote playback state and actions for the player store
Controls remote playback to devices like Chromecast. Exits fullscreen before initiating a remote playback session.
API Reference
State
| Property | Type | Details |
|---|---|---|
remotePlaybackState | 'disconnected' | 'connecting' | 'connected' | |
| ||
remotePlaybackAvailability | 'available' | 'unavailable' | 'unsupported' | |
| ||
Actions
| Action | Type | Details |
|---|---|---|
toggleRemotePlayback | () => Promise<void> | |
| ||
Selector
Pass selectRemotePlayback to usePlayer to subscribe to remote playback state. Returns undefined if the remote playback feature is not configured.
Pass selectRemotePlayback to PlayerController to subscribe to remote playback state. Returns undefined if the remote playback feature is not configured.
import { selectRemotePlayback, usePlayer } from '@videojs/react';
function CastButton() {
const remotePlayback = usePlayer(selectRemotePlayback);
if (!remotePlayback || remotePlayback.remotePlaybackAvailability !== 'available') return null;
return (
<button onClick={remotePlayback.toggleRemotePlayback}>
{remotePlayback.remotePlaybackState === 'connected' ? 'Disconnect' : 'Cast'}
</button>
);
}import { createPlayer, MediaElement, selectRemotePlayback } from '@videojs/html';
import { videoFeatures } from '@videojs/html/video';
const { PlayerController, context } = createPlayer({ features: videoFeatures });
class CastButton extends MediaElement {
readonly #remotePlayback = new PlayerController(this, context, selectRemotePlayback);
}