Skip to Content

Video usage

Load Rixl videos in React, request muted autoplay, handle events, and build scoped controls.

Authenticate before mounting media; see Installation.

Standard player

import {Video} from "@rixl/media-react/video";

export function Player() {
  return (
    <Video
      id="YOUR_VIDEO_ID"
      style={{display: "block", width: "100%", aspectRatio: "16 / 9"}}
      onPausedChange={(paused) => console.log("Paused:", paused)}
      onRixlAnalytics={(event) => console.log(event.detail.event)}
    />
  );
}

The media ID is resolved through the Rixl SDK. State callbacks use booleans; analytics callbacks receive a custom event.

Muted autoplay

<Video id="YOUR_VIDEO_ID" autoPlay muted loop theme="hideUI" style={{display: "block", width: "100%", aspectRatio: "16 / 9"}} />

Set muted explicitly when requesting autoplay. Browser policies can still restrict playback. Provide a pause control for a background video when appropriate.

Custom controls

import {Video, VideoPlayer} from "@rixl/media-react/video";
import {usePlayback} from "@rixl/media-react";

function PlayButton() {
  const {paused, togglePlay} = usePlayback();
  return (
    <button type="button" onClick={() => void togglePlay()}>
      {paused ? "Play" : "Pause"}
    </button>
  );
}

export function CustomPlayer() {
  return (
    <VideoPlayer>
      <Video id="YOUR_VIDEO_ID" theme="hideUI" style={{display: "block", aspectRatio: "16 / 9"}} />
      <PlayButton />
    </VideoPlayer>
  );
}

A VideoPlayer scope contains one video. Controls can alternatively be children of Video, which supplies a scope automatically.

Host classes and inline styles configure layout, not the internal controls. See Video props and Hooks for more.