BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/ncdai/use-sound

useSound

ncdai/use-sound
UnverifiedHook

Hook for playing sound effects with volume, playback rate, and interrupt controls.

Install it

npx shadcn@latest add https://raw.githubusercontent.com/Untel/untel.github.io/master/public/r/use-sound.json

Source

src/registry/hooks/sound/use-sound.tsraw.githubusercontent.com/Untel/untel.github.io/master/public/r/use-sound.json
1"use client"
2
3import { useCallback, useEffect, useRef, useState } from "react"
4
5import {
6 fetchAndDecodeAudio,
7 getAudioContext,
8} from "@/registry/lib/sound/sound-engine"
9import type {
10 PlayFunction,
11 SoundControls,
12 UseSoundOptions,
13 UseSoundReturn,
14} from "@/registry/lib/sound/sound-types"
15
16export function useSound(
17 url: string,
18 options: UseSoundOptions = {}
19): UseSoundReturn {
20 const {
21 volume = 1,
22 playbackRate = 1,
23 interrupt = false,
24 soundEnabled = true,
25 lazy = false,
26 onPlay,
27 onEnd,
28 onPause,
29 onStop,
30 } = options
31
32 const [isPlaying, setIsPlaying] = useState(false)
33
34 const sourceRef = useRef<AudioBufferSourceNode | null>(null)
35 const gainRef = useRef<GainNode | null>(null)
36 const bufferRef = useRef<AudioBuffer | null>(null)
37
38 useEffect(() => {
39 bufferRef.current = null
40
41 if (lazy) return
42
43 let cancelled = false
44
45 fetchAndDecodeAudio(url).then((buffer) => {
46 if (cancelled) return
47 bufferRef.current = buffer
48 })
49
50 return () => {
51 cancelled = true
52 }
53 }, [url, lazy])
54
55 const stop = useCallback(() => {
56 if (sourceRef.current) {
57 try {
58 sourceRef.current.stop()
59 } catch {
60 // Already stopped.
61 }
62 sourceRef.current = null
63 }
64 setIsPlaying(false)
65 onStop?.()
66 }, [onStop])
67
68 const play: PlayFunction = useCallback(
69 (overrides?) => {
70 if (!soundEnabled) return
71
72 const startPlayback = (buffer: AudioBuffer) => {
73 const ctx = getAudioContext()
74
75 if (ctx.state === "suspended") {
76 ctx.resume()
77 }
78
79 if (interrupt && sourceRef.current) {
80 stop()
81 }
82
83 const source = ctx.createBufferSource()
84 const gain = ctx.createGain()
85
86 source.buffer = buffer
87 source.playbackRate.value = overrides?.playbackRate ?? playbackRate
88 gain.gain.value = overrides?.volume ?? volume
89
90 source.connect(gain)
91 gain.connect(ctx.destination)
92
93 source.onended = () => {
94 setIsPlaying(false)
95 onEnd?.()
96 }
97
98 source.start(0)
99 sourceRef.current = source
100 gainRef.current = gain
101 setIsPlaying(true)
102 onPlay?.()
103 }
104
105 if (bufferRef.current) {
106 startPlayback(bufferRef.current)
107 return
108 }
109
110 // Lazy: load on first play, then play immediately.
111 fetchAndDecodeAudio(url).then((buffer) => {
112 bufferRef.current = buffer
113 startPlayback(buffer)
114 })
115// … truncated

Files it writes

  • src/registry/hooks/sound/use-sound.ts
  • src/registry/lib/sound/sound-engine.ts
  • src/registry/lib/sound/sound-types.ts

Facts

Registry
ncdai
Type
registry:hook
Access
Unverified
Files written
3
Licence
the repository states none
In the index
at or before 2026-08-09
Last confirmed
today

Go to the source

chanhdai.com Prathamesh-exe/prathfolio on GitHub Raw registry item This item as JSON

More from ncdai

All 17 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
useControllableStateuse-controllable-statencdaiHooksUnverifiedno deps

Also from Kynth Studios

Built for the same person as BlockDex

SkillWorks

Claude Code skills and plugins, scored

skillworks.kynth.studio

RuleStack

AGENTS.md gallery and agent-config comparison

rulestack.kynth.studio

ToolDrift

What the AI coding tools changed last night

tooldrift.kynth.studio

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

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

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

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

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

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

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex