BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/amarjay-ui/audio-player

Audio Player

amarjay-ui/audio-player
FreeBlock

Inline and floating audio-player controls.

Live preview

live · rendered by the registry
Rendered by amarjay-ui on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://ui.amarjay.com/r/audio-player.json

Source

src/components/examples/audio-player.tsxui.amarjay.com/r/audio-player.json · first 6 KB
1import { useCallback, useEffect, useRef, useState } from 'react'
2import { FastForward, ListMusic, Pause, Play, Rewind, SkipBack, SkipForward, Volume2 } from 'lucide-react'
3import { Button } from '@/components/ui/button'
4import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
5import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
6import { Slider } from '@/components/ui/slider'
7import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
8import { cn } from '@/lib/utils'
9
10export function InlineAudioPlayer() {
11 const [isPlaying, setIsPlaying] = useState(false)
12 const [volume, setVolume] = useState([72])
13 const audioContextRef = useRef<AudioContext | null>(null)
14 const sequenceStepRef = useRef(0)
15 const volumeRef = useRef(volume[0])
16 const duration = 243
17 const elapsedBeforePlayRef = useRef(102)
18 const playbackStartedAtRef = useRef(0)
19 const [currentTime, setCurrentTime] = useState(102)
20 const progress = (currentTime / duration) * 100
21 const formatTime = (seconds: number) => `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')}`
22 volumeRef.current = volume[0]
23
24 const playStep = useCallback(() => {
25 const context = audioContextRef.current
26 if (!context || context.state !== 'running') return
27 const notes = [261.63, 329.63, 392, 493.88, 440, 392, 329.63, 293.66]
28 const note = notes[sequenceStepRef.current % notes.length]
29 sequenceStepRef.current += 1
30 const oscillator = context.createOscillator()
31 const gain = context.createGain()
32 oscillator.type = 'triangle'
33 oscillator.frequency.setValueAtTime(note, context.currentTime)
34 gain.gain.setValueAtTime((volumeRef.current / 100) * 0.035, context.currentTime)
35 gain.gain.exponentialRampToValueAtTime(0.001, context.currentTime + 0.42)
36 oscillator.connect(gain).connect(context.destination)
37 oscillator.start()
38 oscillator.stop(context.currentTime + 0.43)
39 }, [])
40
41 const togglePlayback = async () => {
42 if (isPlaying) {
43 const context = audioContextRef.current
44 if (context) {
45 const elapsed = Math.min(duration, Math.floor(elapsedBeforePlayRef.current + context.currentTime - playbackStartedAtRef.current))
46 elapsedBeforePlayRef.current = elapsed
47 setCurrentTime(elapsed)
48 await context.suspend()
49 }
50 setIsPlaying(false)
51 return
52 }
53 audioContextRef.current ??= new AudioContext()
54 await audioContextRef.current.resume()
55// … truncated

What it pulls in

npm packages

  • lucide-react

Other registry items

  • button
  • avatar
  • popover
  • slider
  • tooltip

Files it writes

  • src/components/examples/audio-player.tsx

Facts

Registry
amarjay-ui
Type
registry:block
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-08
Last confirmed
today

Go to the source

Docs on amarjay-ui ui.amarjay.com amar-jay/ui on GitHub Raw registry item This item as JSON

More from amarjay-ui

All 18 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Chart Exampleschart-examplesamarjay-uiBlocksFree1 dep
Image Comparison Sliderimage-comparison-slideramarjay-uiBlocksFree1 dep
Settings Dialogsettings-dialogamarjay-uiBlocksFree2 deps
BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex