Skip to content
Source
Sign inSign up

snapShotSound.ts

11 lines442 Bytes

1import type { SnapShotSound } from "@t3tools/contracts";
2​
3import snapShotClickUrl from "../assets/snap-shot-click.mp3?url";
4import snapShotWhooshUrl from "../assets/snap-shot-whoosh.mp3?url";
5​
6export function playSnapShotSound(sound: SnapShotSound): void {
7 const audio = new Audio(sound === "soft-pop" ? snapShotWhooshUrl : snapShotClickUrl);
8 audio.preload = "auto";
9 audio.currentTime = 0;
10 void audio.play().catch(() => undefined);