return new Promise((resolve) => { // If the context is suspended, resume it first. Otherwise play() will be called asynchronously and our // whenOverride will not work. if(!Howler.ctx) { new Howl({ src: [ "#" ], preload: false }); } if(Howler.state !== "running") { Howler._autoResume(); Howler._howls[0].once("resume", resolve); } else { resolve(); } }).then(() => {
import _find from 'lodash/collection/find'; import _findIndex from 'lodash/array/findIndex'; import { Howl, Howler } from 'howler'; import Promise from 'promise-polyfill'; let progressedCount = 0; let isPlaying = false; const items = []; const placedItems = []; const callbacks = []; // It _should_ deal with the distorted sounds issue on iOS // https://github.com/goldfire/howler.js/issues/434 Howler.unload(); export default { onLoad, getSound, items, addSound, resumeAll, pauseAll, placeSound, finishSound, allReady: () => new Promise.all( items.map( item => item.promise ) ) }; function onLoad (callback) { callbacks.push(callback); } function getSound (name) { return _find(items, { name }).sound; } function executeCallbacks () { if (!callbacks.length) { return; }
killAllSounds: () => { Howler.unload() return { type: constants.KILL_ALL_SOUNDS } }
return function () { Howler.mute(); };
export function readjustVolumes(newVolume){ Howler.volume(newVolume); }
unmute() { $('.mute img').attr('src', 'images/icon-unmute.svg'); localStorage.muted = 'false'; Howler.mute(false); this.muted = false; }
mute() { $('.mute img').attr('src', 'images/icon-mute.svg'); localStorage.muted = 'true'; Howler.mute(true); this.muted = true; }
focus() { if (!this.muted) { Howler.mute(false); } }
// eslint-disable-next-line blur() { Howler.mute(true); }