mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 09:57:38 +00:00
85faaa1ca7
Signed-off-by: Jef LeCompte <jeffreylec@gmail.com>
26 lines
587 B
TypeScript
26 lines
587 B
TypeScript
import playerLib from 'play-sound';
|
|
import {Config} from '../config';
|
|
import {Logger} from '../logger';
|
|
import fs from 'fs';
|
|
|
|
const notificationSound = Config.notifications.playSound;
|
|
const player = playerLib();
|
|
|
|
export function playSound() {
|
|
// Check if file exists
|
|
fs.access(notificationSound, fs.constants.F_OK, err => {
|
|
if (err) {
|
|
Logger.error(`error opening sound file: ${err.message}`);
|
|
return;
|
|
}
|
|
|
|
player.play(notificationSound, (err: string) => {
|
|
Logger.info('✔ playing sound');
|
|
|
|
if (err) {
|
|
Logger.error(`error playing sound: ${err}`);
|
|
}
|
|
});
|
|
});
|
|
}
|