File size: 486 Bytes
73a2501
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const beepSoundFile = new URL("../assets/beep.mp3", import.meta.url).href;
const beepSound = new Audio(beepSoundFile);

export function useBeep() {
  let beepInterval: ReturnType<typeof setInterval> | null = null;

  function startBeeping() {
    beepSound.play();
    beepInterval = setInterval(() => {
      beepSound.play();
    }, 3000);
  }

  function stopBeeping() {
    if (beepInterval) {
      clearInterval(beepInterval);
    }
  }

  return { startBeeping, stopBeeping };
}