File size: 473 Bytes
39371ea
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
// Share one preloaded clip so rapid clicks replay it without stacking meows.
const meow = new Audio(new URL('../public/cat-meow-v1.mp3', import.meta.url).href);
meow.preload = 'auto';
meow.volume = .65;

export function playCatSound() {
  // Call directly from the click handler so mobile browsers allow playback.
  try {
    meow.currentTime = 0;
    void meow.play().catch(() => {});
  } catch { /* A failed audio download must not interrupt the cat interaction. */ }
}