phaser/src/sound/SoundManagerCreator.js

36 lines
1 KiB
JavaScript
Raw Normal View History

var HTML5AudioSoundManager = require('./html5/HTML5AudioSoundManager');
var NoAudioSoundManager = require('./noaudio/NoAudioSoundManager');
2018-02-12 12:25:30 +00:00
var WebAudioSoundManager = require('./webaudio/WebAudioSoundManager');
2018-02-12 12:25:30 +00:00
/**
* Creates a Web Audio, HTML5 Audio or No Audio Sound Manager based on config and device settings.
*
* @function Phaser.Sound.SoundManagerCreator
* @since 3.0.0
*
* @param {Phaser.Game} game - Reference to the current game instance.
*/
var SoundManagerCreator = {
create: function (game)
{
var audioConfig = game.config.audio;
var deviceAudio = game.device.audio;
if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData))
{
return new NoAudioSoundManager(game);
}
2018-02-12 12:25:30 +00:00
if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio))
{
return new WebAudioSoundManager(game);
}
return new HTML5AudioSoundManager(game);
}
};
module.exports = SoundManagerCreator;