-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added goal overlay and song samples, added keypress shortcuts for HID…
… solution for remote control
- Loading branch information
Showing
11 changed files
with
112 additions
and
2 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { useState, useEffect } from "react"; | ||
|
||
const musicUrls = [ | ||
"http://localhost:5173/scoreboard/music/Kernkraft400-ZombieNation-Sample.mp3", | ||
"http://localhost:5173/scoreboard/music/AlienAntFarm-SmoothCriminal-Sample.mp3", | ||
"http://localhost:5173/scoreboard/music/BloodhoundGang-TheBadTouch-Sample.mp3", | ||
"http://localhost:5173/scoreboard/music/Blur-Song2-Sample.mp3", | ||
"http://localhost:5173/scoreboard/music/Darude-Sandstorm-Sample.mp3", | ||
"http://localhost:5173/scoreboard/music/LittleBig-Skibidi-Sample.mp3", | ||
"http://localhost:5173/scoreboard/music/Psy-GangdamStyle-Sample.mp3", | ||
]; | ||
|
||
const GoalDialog = () => { | ||
const [showGoalDialog, setShowGoalDialog] = useState(false); | ||
const [musicUrl, setMusicUrl] = useState<string>(); | ||
|
||
setTimeout(() => { | ||
setShowGoalDialog(true); | ||
}, 1000); | ||
|
||
useEffect(() => { | ||
const url = musicUrls[Math.floor(Math.random() * musicUrls.length)]; | ||
console.log(url); | ||
setMusicUrl(url); | ||
|
||
setTimeout(() => { | ||
setShowGoalDialog(true); | ||
}, 1000); | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<div | ||
className={`${ | ||
showGoalDialog ? "visible" : "hidden" | ||
} h-full w-full absolute z-10 bg-white font-extrabold content-center items-center`} | ||
> | ||
<h1 className="text-superxl">GOAL!</h1> | ||
</div> | ||
{musicUrl && ( | ||
<audio id="musicplayer" autoPlay> | ||
<source src={musicUrl} /> | ||
</audio> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default GoalDialog; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useCallback, useEffect } from "react"; | ||
|
||
export const useKeyDown = ( | ||
callback: (event: KeyboardEvent) => void, | ||
keys: string[] | ||
) => { | ||
const onKeyDown = useCallback( | ||
(event: KeyboardEvent) => { | ||
const wasAnyKeyPressed = keys.some((key) => event.key === key); | ||
if (wasAnyKeyPressed) { | ||
event.preventDefault(); | ||
callback(event); | ||
} | ||
}, | ||
[callback, keys] | ||
); | ||
useEffect(() => { | ||
document.addEventListener("keydown", onKeyDown); | ||
return () => { | ||
document.removeEventListener("keydown", onKeyDown); | ||
}; | ||
}, [onKeyDown]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters