Skip to content
FrameworkStyle

useAudioTrackOptions

Hook to build audio track menu options from the player audio track state

useAudioTrackOptions returns the currently enabled audio track, the available options, and a setValue callback for wiring track selection into a menu. It returns null when the audio track feature is not configured.

import { Menu, useAudioTrackOptions } from "@videojs/react";

function AudioMenu() {
  const audioTrack = useAudioTrackOptions();
  if (audioTrack?.state.availability !== "available") return null;

  return (
    <Menu.RadioGroup value={audioTrack.value} onValueChange={audioTrack.setValue} aria-label="Audio">
      {audioTrack.options.map((option) => (
        <Menu.RadioItem key={option.value} value={option.value} disabled={option.disabled}>
          {option.label}
          <Menu.ItemIndicator checked={option.value === audioTrack.value} />
        </Menu.RadioItem>
      ))}
    </Menu.RadioGroup>
  );
}

Option labels use the track label, then language, then kind. Pass formatTrack to customize the visible labels.

See AudioTrackRadioGroup for the component-level pattern, and Menu for a complete settings menu example.

API Reference

Parameters

Parameter Type Default Details
props AudioTrackOptionsProps

Return Value

AudioTrackOptionsResult | null