restructure for sveltekit
This commit is contained in:
parent
7deea47857
commit
9ef27fd2a2
73 changed files with 469 additions and 28 deletions
23
src/lib/sound.js
Normal file
23
src/lib/sound.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
let sounds;
|
||||
|
||||
if (typeof Audio !== typeof undefined) {
|
||||
sounds = {
|
||||
"default": new Audio("/sound/log.ogg"),
|
||||
"post": new Audio("/sound/success.ogg"),
|
||||
"boost": new Audio("/sound/hello.ogg"),
|
||||
};
|
||||
}
|
||||
|
||||
export function play_sound(name) {
|
||||
if (name === false) return;
|
||||
if (!name) name = "default";
|
||||
const sound = sounds[name];
|
||||
if (!sound) {
|
||||
console.warn(`Attempted to play sound "${name}", which does not exist!`);
|
||||
return;
|
||||
}
|
||||
sound.pause();
|
||||
sound.volume = 0.25;
|
||||
sound.currentTime = 0;
|
||||
sound.play();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue