phaser/v3/src/sound/WebAudioSoundManager.js

38 lines
836 B
JavaScript
Raw Normal View History

2017-11-10 11:55:32 +00:00
var Class = require('../utils/Class');
var BaseSoundManager = require('./BaseSoundManager');
// Phaser.Loader.WebAudioSoundManager
2017-11-10 11:55:32 +00:00
var WebAudioSoundManager = new Class({
Extends: BaseSoundManager,
2017-11-10 11:55:32 +00:00
initialize:
function WebAudioSoundManager (game)
{
BaseSoundManager.call(this, game);
2017-11-10 11:55:32 +00:00
/**
* @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)
2017-11-10 11:55:32 +00:00
{
return audioConfig.context;
2017-11-10 11:55:32 +00:00
}
return new (window['AudioContext'] || window['webkitAudioContext'])();
}
});
module.exports = WebAudioSoundManager;