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