improved playback

This commit is contained in:
2025-09-24 14:21:53 -04:00
parent 40cfb7d874
commit cf51e857f8
5 changed files with 26 additions and 53 deletions
+25 -31
View File
@@ -1,42 +1,36 @@
"use client"
import useSound from 'use-sound';
import { useRef } from 'react';
export default function Soundboard() {
const [playBoyYouPlay] = useSound("/boyyouplay.m4a", {soundEnabled: true});
const [playEatItUp] = useSound("/eatitup.m4a", {soundEnabled: true});
const [playGangbusters] = useSound("/gangbusters.m4a", {soundEnabled: true});
const [playHusky] = useSound("/husky.m4a", {soundEnabled: true});
const [playPrettyFlags] = useSound("/prettyflags.m4a", {soundEnabled: true});
const [playHobbs] = useSound("/hobbs.m4a", {soundEnabled: true});
const [playGoodLooking] = useSound("/goodlookingband.m4a", {soundEnabled: true});
const [playImpressive] = useSound("/impressive.m4a", {soundEnabled: true});
const [playTallTubas] = useSound("/talltubas.m4a", {soundEnabled: true});
const [playWildChart] = useSound("/wildchart.m4a", {soundEnabled: true});
const [playScared] = useSound("/scared.m4a", {soundEnabled: true});
const [playNotBad] = useSound("/notbad.m4a", {soundEnabled: true});
const [playStrongTubas] = useSound("/strongtubas.m4a", {soundEnabled: true});
const [playTallBand] = useSound("/tallband.m4a", {soundEnabled: true});
const audioRef = useRef<HTMLAudioElement>(null);
const getButton = (title: string, play: () => void) => {
return <button className="border-2 rounded-lg p-4 text-center text-xl font-medium cursor-pointer hover:bg-gray-200 active:bg-blue-200" onClick={() => play()}>{title}</button>
const getButton = (title: string, src: string) => {
return <button className="border-2 rounded-lg p-4 text-center text-xl font-medium cursor-pointer hover:bg-gray-200 active:bg-blue-200"
onClick={() => {
if (audioRef.current) {
audioRef.current.src = src;
audioRef.current.play();
}
}}>{title}</button>
}
return (
<div className="grid grid-cols-2 gap-8">
{getButton("Boy you play!", playBoyYouPlay)}
{getButton("Eat It Up!", playEatItUp)}
{getButton("Gangbusters", playGangbusters)}
{getButton("Husky", playHusky)}
{getButton("Pretty Flags", playPrettyFlags)}
{getButton("Hobbs", playHobbs)}
{getButton("Good Looking Band", playGoodLooking)}
{getButton("Pretty Impressive", playImpressive)}
{getButton("3 Tall Tubas", playTallTubas)}
{getButton("Wild Chart", playWildChart)}
{getButton("Scared Me", playScared)}
{getButton("Not Bad", playNotBad)}
{getButton("Strong Tubas", playStrongTubas)}
{getButton("Tall Band", playTallBand)}
{getButton("Boy you play!", "/boyyouplay.m4a")}
{getButton("Eat It Up!", "/eatitup.m4a")}
{getButton("Gangbusters", "/gangbusters.m4a")}
{getButton("Husky", "/husky.m4a")}
{getButton("Pretty Flags", "/prettyflags.m4a")}
{getButton("Hobbs", "/hobbs.m4a")}
{getButton("Good Looking Band", "/goodlookingband.m4a")}
{getButton("Pretty Impressive", "/impressive.m4a")}
{getButton("3 Tall Tubas", "/talltubas.m4a")}
{getButton("Wild Chart", "/wildchart.m4a")}
{getButton("Scared Me", "/scared.m4a")}
{getButton("Not Bad", "/notbad.m4a")}
{getButton("Strong Tubas", "/strongtubas.m4a")}
{getButton("Tall Band", "/tallband.m4a")}
<audio hidden ref={audioRef} />
</div>
);
}