2024-06-29 14:48:34 +01:00
|
|
|
import sound_log from '../sound/log.ogg';
|
|
|
|
import sound_hello from '../sound/hello.ogg';
|
|
|
|
import sound_success from '../sound/success.ogg';
|
2024-06-29 10:46:27 +01:00
|
|
|
let sounds;
|
|
|
|
|
|
|
|
if (typeof Audio !== typeof undefined) {
|
|
|
|
sounds = {
|
2024-06-29 14:48:34 +01:00
|
|
|
"default": new Audio(sound_log),
|
|
|
|
"post": new Audio(sound_hello),
|
|
|
|
"boost": new Audio(sound_success),
|
2024-06-29 10:46:27 +01:00
|
|
|
};
|
|
|
|
}
|
2024-06-17 21:17:27 +01:00
|
|
|
|
|
|
|
export function play_sound(name) {
|
2024-06-28 08:43:12 +01:00
|
|
|
if (name === false) return;
|
2024-06-17 21:17:27 +01:00
|
|
|
if (!name) name = "default";
|
|
|
|
const sound = sounds[name];
|
|
|
|
if (!sound) {
|
|
|
|
console.warn(`Attempted to play sound "${name}", which does not exist!`);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
sound.pause();
|
2024-06-28 06:19:00 +01:00
|
|
|
sound.volume = 0.25;
|
2024-06-17 21:17:27 +01:00
|
|
|
sound.currentTime = 0;
|
|
|
|
sound.play();
|
|
|
|
}
|