Audio
nordaun-ui/audioFreeBlock
An audio playback with extendable control modules already included such as volume and speed.
Live preview
live · rendered by the registry
Rendered by @nordaun/ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.nordaun.com/r/audio.jsonSource
1"use client";23import { MenuTrigger } from "@base-ui/react";4import * as React from "react";56import { Button } from "@/components/ui/button";7import {8 DropdownMenu,9 DropdownMenuContent,10 DropdownMenuItem,11 DropdownMenuTrigger,12} from "@/components/ui/dropdown-menu";13import { Slider } from "@/components/ui/slider";14import { cn } from "@/lib/utils";15import {16 Check,17 Gauge,18 Pause,19 Play,20 Repeat,21 Repeat1,22 Volume,23 Volume1,24 Volume2,25 VolumeX,26} from "lucide-react";2728declare global {29 interface Window {30 webkitAudioContext: typeof AudioContext;31 }32}3334type AudioContext = {35 audioRef: React.RefObject<HTMLAudioElement | null>;36 containerRef: React.RefObject<HTMLDivElement | null>;37 analyserRef: React.RefObject<AnalyserNode | null>;38 graphRef: React.RefObject<globalThis.AudioContext | null>;39 paused: boolean;40 setPaused: React.Dispatch<React.SetStateAction<boolean>>;41 progress: number;42 setProgress: React.Dispatch<React.SetStateAction<number>>;43 volume: number;44 setVolume: React.Dispatch<React.SetStateAction<number>>;45 muted: boolean;46 setMuted: React.Dispatch<React.SetStateAction<boolean>>;47 loop: boolean;48 setLoop: React.Dispatch<React.SetStateAction<boolean>>;49 playbackRate: number;50 setPlaybackRate: React.Dispatch<React.SetStateAction<number>>;51 duration: number;52 setDuration: React.Dispatch<React.SetStateAction<number>>;53 currentTime: number;54 setCurrentTime: React.Dispatch<React.SetStateAction<number>>;55};5657const DefaultAudioContext: AudioContext = {58 audioRef: { current: null },59 containerRef: { current: null },60 analyserRef: { current: null },61 graphRef: { current: null },62 paused: true,63 setPaused: () => {},64 progress: 0,65 setProgress: () => {},66 volume: 1,67 setVolume: () => {},68 muted: false,69 setMuted: () => {},70 loop: false,71 setLoop: () => {},72 playbackRate: 1,73 setPlaybackRate: () => {},74 duration: 0,75 setDuration: () => {},76 currentTime: 0,77 setCurrentTime: () => {},78};7980if (typeof window !== "undefined") {81 const _error = console.error.bind(console);82 console.error = (...args) => {83 if (typeof args[0] === "string" && args[0].includes("script")) return;84 _error(...args);85 };86}8788const WaveformCache = new WeakMap<89 HTMLAudioElement,90 { ctx: globalThis.AudioContext; analyser: AnalyserNode }91>();9293const Context = React.createContext<AudioContext>(DefaultAudioContext);9495// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from @nordaun/ui
All 8 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Filefile | @nordaun/ui | Blocks | Free | 1 dep · 3 files | |
| Flagflag | @nordaun/ui | Blocks | Free | no deps · 2 files | |
| Loadingloading | @nordaun/ui | Blocks | Free | no deps | |
| Mapmap | @nordaun/ui | Blocks | Free | 2 deps · 2 files | |
| Passwordpassword | @nordaun/ui | Blocks | Free | 1 dep | |
| Phonephone | @nordaun/ui | Blocks | Free | 2 deps · 3 files | |
| Videovideo | @nordaun/ui | Blocks | Free | 1 dep · 2 files |
