Skip to content

Commit ae5182b

Browse files
committed
Default Phaser.Core.Config#audio; and refactor
1 parent efd15f9 commit ae5182b

5 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/core/Config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ var Config = new Class({
293293
/**
294294
* @const {Phaser.Types.Core.AudioConfig} Phaser.Core.Config#audio - The Audio Configuration object.
295295
*/
296-
this.audio = GetValue(config, 'audio');
296+
this.audio = GetValue(config, 'audio', {});
297297

298298
// If you do: { banner: false } it won't display any banner at all
299299

src/core/DebugHeader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ var DebugHeader = function (game)
4141

4242
var audioType;
4343

44-
if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio))
44+
if (deviceAudio.webAudio && !audioConfig.disableWebAudio)
4545
{
4646
audioType = 'Web Audio';
4747
}
48-
else if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData))
48+
else if (audioConfig.noAudio || (!deviceAudio.webAudio && !deviceAudio.audioData))
4949
{
5050
audioType = 'No Audio';
5151
}

src/loader/filetypes/AudioFile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ AudioFile.create = function (loader, key, urls, config, xhrSettings)
122122
// https://developers.google.com/web/updates/2012/02/HTML5-audio-and-the-Web-Audio-API-are-BFFs
123123
// var stream = GetFastValue(config, 'stream', false);
124124

125-
if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio))
125+
if (deviceAudio.webAudio && !audioConfig.disableWebAudio)
126126
{
127127
return new AudioFile(loader, key, urlConfig, xhrSettings, game.sound.context);
128128
}
@@ -231,7 +231,7 @@ FileTypesManager.register('audio', function (key, urls, config, xhrSettings)
231231
var audioConfig = game.config.audio;
232232
var deviceAudio = game.device.audio;
233233

234-
if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData))
234+
if (audioConfig.noAudio || (!deviceAudio.webAudio && !deviceAudio.audioData))
235235
{
236236
// Sounds are disabled, so skip loading audio
237237
return this;

src/sound/SoundManagerCreator.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var WebAudioSoundManager = require('./webaudio/WebAudioSoundManager');
1818
* @since 3.0.0
1919
*
2020
* @param {Phaser.Game} game - Reference to the current game instance.
21-
*
21+
*
2222
* @return {(Phaser.Sound.HTML5AudioSoundManager|Phaser.Sound.WebAudioSoundManager|Phaser.Sound.NoAudioSoundManager)} The Sound Manager instance that was created.
2323
*/
2424
var SoundManagerCreator = {
@@ -28,12 +28,12 @@ var SoundManagerCreator = {
2828
var audioConfig = game.config.audio;
2929
var deviceAudio = game.device.audio;
3030

31-
if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData))
31+
if (audioConfig.noAudio || (!deviceAudio.webAudio && !deviceAudio.audioData))
3232
{
3333
return new NoAudioSoundManager(game);
3434
}
3535

36-
if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio))
36+
if (deviceAudio.webAudio && !audioConfig.disableWebAudio)
3737
{
3838
return new WebAudioSoundManager(game);
3939
}

src/sound/webaudio/WebAudioSoundManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ var WebAudioSoundManager = new Class({
108108
{
109109
var audioConfig = game.config.audio;
110110

111-
if (audioConfig && audioConfig.context)
111+
if (audioConfig.context)
112112
{
113113
audioConfig.context.resume();
114114

@@ -355,7 +355,7 @@ var WebAudioSoundManager = new Class({
355355
this.masterMuteNode.disconnect();
356356
this.masterMuteNode = null;
357357

358-
if (this.game.config.audio && this.game.config.audio.context)
358+
if (this.game.config.audio.context)
359359
{
360360
this.context.suspend();
361361
}

0 commit comments

Comments
 (0)