Add Egyptian escape room digital lock web app.
React/Vite lock UI with color-coded inputs, celebration SFX, and unlock video; Docker/nginx packaging and homelab deploy scripts documented in AGENTS.md.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import type { MediaConfig } from './mediaConfig';
|
||||
|
||||
export function playClip(src: string): HTMLAudioElement {
|
||||
const audio = new Audio(src);
|
||||
void audio.play();
|
||||
return audio;
|
||||
}
|
||||
|
||||
export function playIncorrectSound(incorrectUrl: string) {
|
||||
playClip(incorrectUrl);
|
||||
}
|
||||
|
||||
type CelebrationConfig = Pick<
|
||||
MediaConfig,
|
||||
| 'unlockConfirmUrl'
|
||||
| 'celebrationPopUrl'
|
||||
| 'celebrationHornUrl'
|
||||
| 'celebrationHornDurationMs'
|
||||
>;
|
||||
|
||||
/** Confirm, pop, and horn together; horn is trimmed — ends before unlock video audio. */
|
||||
export function playCelebrationSounds(config: CelebrationConfig) {
|
||||
playClip(config.unlockConfirmUrl);
|
||||
playClip(config.celebrationPopUrl);
|
||||
|
||||
const horn = playClip(config.celebrationHornUrl);
|
||||
window.setTimeout(() => {
|
||||
horn.pause();
|
||||
horn.currentTime = 0;
|
||||
}, config.celebrationHornDurationMs);
|
||||
}
|
||||
Reference in New Issue
Block a user