phaser/v3/src/sound/WebAudioSoundManager.js
Pavle Goloskokovic 0fe8757054 moved create method meant for instantiating global sound manager object form BaseSoundManager class to dedicated SoundManagerCreator class
moved setting local game reference from WebAudioSoundManager class to BaseSoundManager class constructor
fixed bug with audio context creation condition in WebAudioSoundManager class
2017-11-10 19:05:26 +01:00

37 lines
836 B
JavaScript

var Class = require('../utils/Class');
var BaseSoundManager = require('./BaseSoundManager');
// Phaser.Loader.WebAudioSoundManager
var WebAudioSoundManager = new Class({
Extends: BaseSoundManager,
initialize:
function WebAudioSoundManager (game)
{
BaseSoundManager.call(this, game);
/**
* @property {AudioContext} context - The AudioContext being used for playback.
* @default
*/
this.context = this.createAudioContext();
},
createAudioContext: function ()
{
var audioConfig = this.game.config.audio;
if (audioConfig && audioConfig.context)
{
return audioConfig.context;
}
return new (window['AudioContext'] || window['webkitAudioContext'])();
}
});
module.exports = WebAudioSoundManager;