phaser/v3/src/sound/WebAudioSoundManager.js

23 lines
804 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,
initialize: function WebAudioSoundManager(game) {
2017-11-10 11:55:32 +00:00
/**
* @property {AudioContext} context - The AudioContext being used for playback.
* @default
*/
this.context = this.createAudioContext();
BaseSoundManager.call(this, game);
2017-11-10 11:55:32 +00:00
},
createAudioContext: function () {
var audioConfig = this.game.config.audio;
if (audioConfig && audioConfig.context) {
return audioConfig.context;
2017-11-10 11:55:32 +00:00
}
return new (window['AudioContext'] || window['webkitAudioContext'])();
}
});
module.exports = WebAudioSoundManager;