Example #1
0
		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(() => {
Example #2
0
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();
 };
Example #5
0
export function readjustVolumes(newVolume){
    Howler.volume(newVolume);
}
Example #6
0
 unmute() {
   $('.mute img').attr('src', 'images/icon-unmute.svg');
   localStorage.muted = 'false';
   Howler.mute(false);
   this.muted = false;
 }
Example #7
0
 mute() {
   $('.mute img').attr('src', 'images/icon-mute.svg');
   localStorage.muted = 'true';
   Howler.mute(true);
   this.muted = true;
 }
Example #8
0
 focus() {
   if (!this.muted) {
     Howler.mute(false);
   }
 }
Example #9
0
 // eslint-disable-next-line
 blur() {
   Howler.mute(true);
 }