TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Use-sound, a React hook for sound effects on the web

131 点作者 joshwcomeau大约 5 年前

12 条评论

mtm7大约 5 年前
I&#x27;ve been following your site for a few weeks, and I just love it. The design, the writing, the interactive examples, the little sounds... it&#x27;s all so thoughtful!<p>I&#x27;m thinking of switching to Gatsby so I can have more fun with these kinds of things. I write electronic music in my spare time, so adding a few sound effects sounds like an ideal afternoon! :)
评论 #22733951 未加载
timharding大约 5 年前
This is cool but, oh boy, a mute button that makes a sound when you click it is user hostile.
评论 #22735614 未加载
评论 #22736507 未加载
jacobsimon大约 5 年前
This is really cool &amp; you have a great website! The one thing I don’t quite understand is why this needs to be a React hook per se - couldn’t it just be a normal library function that you call inside your component?
评论 #22734779 未加载
评论 #22737877 未加载
Uhhrrr大约 5 年前
I am very glad this post starts by acknowledging that sound on the web is frequently annoying.
评论 #22734739 未加载
bennyg大约 5 年前
Not to nitpick, but I&#x27;m wondering about the tradeoffs of adjusting volume&#x2F;playback rate in an effect (<a href="https:&#x2F;&#x2F;github.com&#x2F;joshwcomeau&#x2F;use-sound&#x2F;blob&#x2F;master&#x2F;src&#x2F;index.ts#L75" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;joshwcomeau&#x2F;use-sound&#x2F;blob&#x2F;master&#x2F;src&#x2F;ind...</a>). I&#x27;m kind of wondering how this works in a concurrent mode world when there are other, higher priority things React is deferring reconciliation&#x2F;effects for.
评论 #22735663 未加载
spidersandstuff大约 5 年前
Really cool. Also, the showcase website is made really well, kudos.
desert_boi大约 5 年前
I was hoping to see the source for the lib, but I can&#x27;t find it in the npm package listing. Anyone manage to track it down?
评论 #22733954 未加载
quickthrower2大约 5 年前
Ok not working on iOS safari for me, but that’s not your fault... I had a howler based app that seemed to work 6 months ago and after some update stopped working on iOS (no more sound!). I wonder if anyone knows why.
vcoelho大约 5 年前
Could some one clarify for me why the consts for the useSound() are declared inside an array?<p>const [play] = useSound()
评论 #22737396 未加载
评论 #22736793 未加载
评论 #22736809 未加载
kkdaemas大约 5 年前
When all you have is a hammer...
评论 #22744742 未加载
bestouff大约 5 年前
Is there a way to do all of this with CSS only ?
评论 #22746580 未加载
d33大约 5 年前
I wish I could think of a leveled way to speak my mind but gosh, there&#x27;s something about all this that really makes me want to throw up.<p>The idea of adding a tiny little button that makes a sound is innocent. It&#x27;s a single button after all, isn&#x27;t it? The thing is, once you share this idea, it has a risk of going to all of the pages. Websites everywhere are already full of distractors that make them annoying to browse for people with limited attention. Once you also add sounds, you might hit several problems you might have not thought of:<p>1. the tab is opened in the background and the user is trying to find the one that&#x27;s using the speaker, 2. the volume is mismanaged because some other tab is playing their sounds too silently and yours will make the user&#x27;s ears explode, 3. (probably some more that I hadn&#x27;t thought of)<p>At first it just felt like a chunch, but then I saw another IMHO not-so-great idea coming from the user - the sticky navbar at the top is partially transparent, effectively taking even more screen estate. Probably looks shiny, but also makes your website hard to read. It really does feel like some hostile design.<p>It really looks like we&#x27;re back to 90s&#x27;, with a new generation of equivalents of &lt;marquee&gt; tags, annoying GIFs, mismatched colors and &quot;still in development&quot; signs. Thing is, this generation is sugar-coated and seems shiny at first, until you realize that every single web 4.0 page is making you nauseated. After all, it&#x27;s legitimate to put on a GDPR consent overlay covering 90% of your smartphone and do other shitty moves other people do anyway, right? Though I have to admit I appreciate that this at least this one wasn&#x27;t to be found on your website.<p>I mean, excuse the rant... as much as I appreciate open sourcing your work and hoping to improve something on the net, consider effects on users&#x27; sanity this change will bring. In the meantime, I wish I could anti-star your project, as an example of where I don&#x27;t want the web to go.
评论 #22736644 未加载
评论 #22736808 未加载
评论 #22744318 未加载