restart audio on press

This commit is contained in:
2025-09-24 14:34:01 -04:00
parent 06c4cc1b11
commit 3b09019295
+8 -1
View File
@@ -19,7 +19,14 @@ export default function Soundboard() {
const getButton = (title: string, ref: RefObject<HTMLAudioElement | null>) => { const getButton = (title: string, ref: RefObject<HTMLAudioElement | null>) => {
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" 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={() => ref.current?.play()}>{title}</button> onClick={() =>
{
if (ref.current){
ref.current.currentTime = 0;
ref.current?.play()
}
}
}>{title}</button>
} }
return ( return (