Files
streetmerchant/src/notification/sound.ts
T
Jef LeCompte 85faaa1ca7 chore: update desc of variables (#101)
Signed-off-by: Jef LeCompte <jeffreylec@gmail.com>
2020-09-20 09:15:57 -04:00

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}`);
}
});
});
}