Switch to Howler for audio

This commit is contained in:
asraelite 2018-03-07 12:21:43 +00:00
parent 3eb74e44aa
commit 194c0bf846
13 changed files with 78 additions and 19 deletions

View file

@ -1,5 +1,23 @@
import {audio} from '../assets.mjs';
const playing = new Map();
export function play(name) {
audio[name].cloneNode(true).play();
audio[name].play();
}
export function start(name) {
if (!playing.has(name))
playing.set(name, audio[name]);
let howl = playing.get(name);
howl.loop(true);
howl.play();
}
export function stop(name) {
if (!playing.has(name)) return;
let howl = playing.get(name);
if (howl.playing())
howl.stop();
}