Switch to Howler for audio
This commit is contained in:
parent
3eb74e44aa
commit
194c0bf846
13 changed files with 78 additions and 19 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue