audiocn

useSystemAudio

Capture system or tab audio through the browser's screen-share picker.

$ pnpm dlx shadcn@latest add @audiocn/use-system-audio

Usage

const system = useSystemAudio();
const analyser = useAudioAnalyser(system.stream, { channels: "stereo" });

<Button disabled={!system.isSupported} onClick={system.start}>
  Capture system audio
</Button>;

The browser shows its screen-share picker. The user must choose a screen, window or tab and tick the option to share audio. The video track is dropped immediately; only audio is kept.

Browser support varies

What can be captured depends on the browser and operating system. Chromium browsers can share tab audio everywhere and whole-system audio on some platforms. Other browsers may offer no audio at all. Always handle the no-audio and unsupported states.

Options

Prop

Type

Returns

Prop

Type