Skip to Content

useMediaSettings

Read and update player-scoped mute and volume state for the current Video instance.

useMediaSettings() exposes player-scoped audio state and actions.

Use this hook inside Video children, or inside a shared VideoPlayer that contains one Video. The player scope is resolved automatically.

Signature

const media = useMediaSettings();

It returns:

  • muted
  • volume
  • previousVolume
  • mute()
  • unmute()
  • toggleMute()
  • setVolume(volume)

Example

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

function CustomVolumeControls() {
  const {muted, volume, toggleMute, setVolume} = useMediaSettings();

  return (
    <div className="flex items-center gap-3">
      <button type="button" onClick={() => toggleMute()}>
        {muted ? "Unmute" : "Mute"}
      </button>

      <input type="range" min={0} max={1} step={0.05} value={volume} onChange={(event) => setVolume(Number(event.target.value))} />
    </div>
  );
}

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

Notes

  • This hook only affects the current scoped player.
  • muted reflects the effective audible state, including volume 0 and the interaction gate.
  • Use useGlobalPlayerSettings() only when one control should intentionally fan out to every mounted player on the page.