diff --git a/README.md b/README.md
index 6552e625f..dd9ca529d 100644
--- a/README.md
+++ b/README.md
@@ -328,6 +328,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
* Group.getByName searches the Group for the first instance of a child with the `name` property matching the given argument. Should more than one child have the same name only the first instance is returned.
* BitmapData has a new property `frameData` which is a Phaser.FrameData container instance. It contains a single Frame by default, matching the dimensions of the entire BitmapData, but can be populated with additional frames should you wish to create animations from dynamic BitmapData textures.
* FrameData.destroy will nullify the local arrays used to contain Frame instances.
+* SoundManager.muteOnPause is a new boolean that allows you to control if the Sound system gets muted automatically when a Phaser game pauses, such as when it loses focus. You may need to set this to `false` if you wish to control the audio system from outside of your Phaser game, i.e. from DOM buttons or similar (#2382)
### Updates
diff --git a/src/core/Game.js b/src/core/Game.js
index ba20a688e..efc258402 100644
--- a/src/core/Game.js
+++ b/src/core/Game.js
@@ -1045,8 +1045,14 @@ Phaser.Game.prototype = {
if (!this._paused)
{
this._paused = true;
+
this.time.gamePaused();
- this.sound.setMute();
+
+ if (this.sound.muteOnPause)
+ {
+ this.sound.setMute();
+ }
+
this.onPause.dispatch(event);
// Avoids Cordova iOS crash event: https://github.com/photonstorm/phaser/issues/1800
@@ -1071,9 +1077,16 @@ Phaser.Game.prototype = {
if (this._paused && !this._codePaused)
{
this._paused = false;
+
this.time.gameResumed();
+
this.input.reset();
- this.sound.unsetMute();
+
+ if (this.sound.muteOnPause)
+ {
+ this.sound.unsetMute();
+ }
+
this.onResume.dispatch(event);
// Avoids Cordova iOS crash event: https://github.com/photonstorm/phaser/issues/1800
diff --git a/src/sound/SoundManager.js b/src/sound/SoundManager.js
index 42d0f3037..4efb920d5 100644
--- a/src/sound/SoundManager.js
+++ b/src/sound/SoundManager.js
@@ -94,6 +94,15 @@ Phaser.SoundManager = function (game) {
*/
this.channels = 32;
+ /**
+ * Set to true to have all sound muted when the Phaser game pauses (such as on loss of focus),
+ * or set to false to keep audio playing, regardless of the game pause state. You may need to
+ * do this should you wish to control audio muting via external DOM buttons or similar.
+ * @property {boolean} muteOnPause
+ * @default
+ */
+ this.muteOnPause = true;
+
/**
* @property {boolean} _codeMuted - Internal mute tracking var.
* @private
diff --git a/src/stubs/SoundManager.js b/src/stubs/SoundManager.js
index 52d7eb078..af9105004 100644
--- a/src/stubs/SoundManager.js
+++ b/src/stubs/SoundManager.js
@@ -9,7 +9,9 @@
* It allows you to exclude the default Sound Manager from your build, without making Game crash.
*/
-Phaser.SoundManager = function () {};
+Phaser.SoundManager = function () {
+ this.muteOnPause = false;
+};
Phaser.SoundManager.prototype.boot = function () {};
Phaser.SoundManager.prototype.update = function () {};
diff --git a/typescript/phaser.d.ts b/typescript/phaser.d.ts
index 5f78e544f..45303339a 100644
--- a/typescript/phaser.d.ts
+++ b/typescript/phaser.d.ts
@@ -1,7 +1,7 @@
///
///
-// Type definitions for Phaser 2.4.7 - 1st March 2016
+// Type definitions for Phaser 2.4.7 - 6th April 2016
// Project: https://github.com/photonstorm/phaser
declare module "phaser" {
@@ -1689,6 +1689,7 @@ declare module Phaser {
filter(predicate: Function, checkExists?: boolean): ArraySet;
getAt(index: number): PIXI.DisplayObject | number;
getBottom(): any;
+ getByName(name: string): any;
getFirstAlive(createIfNull?: boolean, x?: number, y?: number, key?: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture, frame?: string | number): any;
getFirstDead(createIfNull?: boolean, x?: number, y?: number, key?: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture, frame?: string | number): any;
getFirstExists(exists: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture, frame?: string | number): any;
@@ -4350,6 +4351,7 @@ declare module Phaser {
context: any;
game: Phaser.Game;
mute: boolean;
+ muteOnPause: boolean;
noAudio: boolean;
onSoundDecode: Phaser.Signal;
onVolumeChange: Phaser.Signal;