diff --git a/src/sound/html5/HTML5AudioSoundManager.js b/src/sound/html5/HTML5AudioSoundManager.js index 5d44a251b..b9ec0a1c2 100644 --- a/src/sound/html5/HTML5AudioSoundManager.js +++ b/src/sound/html5/HTML5AudioSoundManager.js @@ -137,6 +137,11 @@ var HTML5AudioSoundManager = new Class({ this._volume = 1; BaseSoundManager.call(this, game); + + if (this.locked) + { + this.unlock(); + } }, /** @@ -168,6 +173,8 @@ var HTML5AudioSoundManager = new Class({ */ unlock: function () { + console.log('unlock'); + this.locked = false; var _this = this; @@ -187,10 +194,11 @@ var HTML5AudioSoundManager = new Class({ return true; }); - if (!this.locked) - { - return; - } + // if (!this.locked) + // { + // console.log('unlock bail 1'); + // return; + // } var moved = false; @@ -201,6 +209,8 @@ var HTML5AudioSoundManager = new Class({ var unlock = function () { + console.log('unlock->unlock!', moved); + if (moved) { moved = false; @@ -210,6 +220,8 @@ var HTML5AudioSoundManager = new Class({ document.body.removeEventListener('touchmove', detectMove); document.body.removeEventListener('touchend', unlock); + _this.emit(Events.UNLOCKED, _this); + var lockedTags = []; _this.game.cache.audio.entries.each(function (key, tags) @@ -254,6 +266,9 @@ var HTML5AudioSoundManager = new Class({ this.once(Events.UNLOCKED, function () { + console.log('unlocked event handler', this.lockedActionsQueue.length); + + /* this.forEachActiveSound(function (sound) { if (sound.currentMarker === null && sound.duration === 0) @@ -277,9 +292,12 @@ var HTML5AudioSoundManager = new Class({ lockedAction.sound[lockedAction.prop] = lockedAction.value; } } + */ }, this); + console.log('unlock added listeners'); + document.body.addEventListener('touchmove', detectMove, false); document.body.addEventListener('touchend', unlock, false); }, @@ -322,21 +340,6 @@ var HTML5AudioSoundManager = new Class({ this.onBlurPausedSounds.length = 0; }, - /** - * Calls Phaser.Sound.BaseSoundManager#destroy method - * and cleans up all HTML5 Audio related stuff. - * - * @method Phaser.Sound.HTML5AudioSoundManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - BaseSoundManager.prototype.destroy.call(this); - - this.onBlurPausedSounds.length = 0; - this.onBlurPausedSounds = null; - }, - /** * Method used internally by Phaser.Sound.HTML5AudioSound class methods and property setters * to check if sound manager is locked and then either perform action immediately or queue it @@ -386,33 +389,6 @@ var HTML5AudioSoundManager = new Class({ return this; }, - /** - * @name Phaser.Sound.HTML5AudioSoundManager#mute - * @type {boolean} - * @fires Phaser.Sound.Events#GLOBAL_MUTE - * @since 3.0.0 - */ - mute: { - - get: function () - { - return this._mute; - }, - - set: function (value) - { - this._mute = value; - - this.forEachActiveSound(function (sound) - { - sound.updateMute(); - }); - - this.emit(Events.GLOBAL_MUTE, this, value); - } - - }, - /** * Sets the volume of this Sound Manager. * @@ -456,6 +432,48 @@ var HTML5AudioSoundManager = new Class({ this.emit(Events.GLOBAL_VOLUME, this, value); } + }, + + /** + * @name Phaser.Sound.HTML5AudioSoundManager#mute + * @type {boolean} + * @fires Phaser.Sound.Events#GLOBAL_MUTE + * @since 3.0.0 + */ + mute: { + + get: function () + { + return this._mute; + }, + + set: function (value) + { + this._mute = value; + + this.forEachActiveSound(function (sound) + { + sound.updateMute(); + }); + + this.emit(Events.GLOBAL_MUTE, this, value); + } + + }, + + /** + * Calls Phaser.Sound.BaseSoundManager#destroy method + * and cleans up all HTML5 Audio related stuff. + * + * @method Phaser.Sound.HTML5AudioSoundManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + BaseSoundManager.prototype.destroy.call(this); + + this.onBlurPausedSounds.length = 0; + this.onBlurPausedSounds = null; } });