Skip to content

Commit 15d9521

Browse files
committed
SoundManager.destroy doesn't close the context if it's being stored in PhaserGlobal (thanks @brianbunch phaserjs#2356)
1 parent cc3a07b commit 15d9521

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
331331
* The `mouseoutglobal` event listener wasn't removed when the game was destroyed (thanks @stoneman1 #2345 #2344 #2342)
332332
* Fixed issue with IE crashing on this.context.close in the Sound Manager (thanks @stoneman1 #2349)
333333
* Phaser.World.centerX and Phaser.World.centerY only worked if the bounds had an origin of 0, 0. They now take into account the actual origin (thanks @fillmoreb #2353)
334-
* SoundManager.close now validates that context.close is a valid function before calling it (thanks @brianbunch #2355)
334+
* SoundManager.destroy now validates that context.close is a valid function before calling it (thanks @brianbunch #2355)
335+
* SoundManager.destroy doesn't close the context if it's being stored in PhaserGlobal (thanks @brianbunch #2356)
335336

336337
### Pixi Updates
337338

src/sound/SoundManager.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -730,15 +730,20 @@ Phaser.SoundManager.prototype = {
730730

731731
this.onSoundDecode.dispose();
732732

733-
if (this.context && this.context.close)
733+
if (this.context)
734734
{
735-
this.context.close();
736-
}
737-
738-
if (this.context && window['PhaserGlobal'])
739-
{
740-
// Store this in the PhaserGlobal window var, if set, to allow for re-use if the game is created again without the page refreshing
741-
window['PhaserGlobal'].audioContext = this.context;
735+
if (window['PhaserGlobal'])
736+
{
737+
// Store this in the PhaserGlobal window var, if set, to allow for re-use if the game is created again without the page refreshing
738+
window['PhaserGlobal'].audioContext = this.context;
739+
}
740+
else
741+
{
742+
if (this.context.close)
743+
{
744+
this.context.close();
745+
}
746+
}
742747
}
743748

744749
}

0 commit comments

Comments
 (0)