restart audio on press
This commit is contained in:
@@ -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 (
|
||||||
|
|||||||
Reference in New Issue
Block a user