mirror of
https://github.com/tcsenpai/shellquest.git
synced 2025-06-02 09:20:17 +00:00
20 lines
543 B
TypeScript
20 lines
543 B
TypeScript
import player from 'play-sound';
|
|
|
|
const audioPlayer = player({});
|
|
|
|
export function playSound(sound: 'success' | 'error' | 'typing' | 'levelComplete'): void {
|
|
try {
|
|
const soundMap = {
|
|
success: 'sounds/success.wav',
|
|
error: 'sounds/error.wav',
|
|
typing: 'sounds/typing.wav',
|
|
levelComplete: 'sounds/level-complete.wav'
|
|
};
|
|
|
|
audioPlayer.play(soundMap[sound], (err) => {
|
|
if (err) console.error('Error playing sound:', err);
|
|
});
|
|
} catch (error) {
|
|
// Silently fail if sound can't be played
|
|
}
|
|
}
|