phaser/src/sound/SoundManagerCreator.js

43 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-02-12 16:01:20 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
2018-03-28 14:04:09 +00:00
* @author Pavle Goloskokovic <pgoloskokovic@gmail.com> (http://prunegames.com)
2018-02-12 16:01:20 +00:00
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
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;