2018-01-11 16:29:57 +00:00
|
|
|
var HTML5AudioSoundManager = require('./html5/HTML5AudioSoundManager');
|
2018-01-20 20:23:43 +00:00
|
|
|
var NoAudioSoundManager = require('./noaudio/NoAudioSoundManager');
|
2018-02-12 12:25:30 +00:00
|
|
|
var WebAudioSoundManager = require('./webaudio/WebAudioSoundManager');
|
2017-11-10 18:05:26 +00:00
|
|
|
|
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.
|
|
|
|
*/
|
2017-11-10 18:05:26 +00:00
|
|
|
var SoundManagerCreator = {
|
|
|
|
|
|
|
|
create: function (game)
|
|
|
|
{
|
|
|
|
var audioConfig = game.config.audio;
|
2018-01-25 17:03:35 +00:00
|
|
|
var deviceAudio = game.device.audio;
|
2017-11-10 18:05:26 +00:00
|
|
|
|
|
|
|
if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData))
|
|
|
|
{
|
2018-01-20 20:23:43 +00:00
|
|
|
return new NoAudioSoundManager(game);
|
2017-11-10 18:05:26 +00:00
|
|
|
}
|
|
|
|
|
2018-02-12 12:25:30 +00:00
|
|
|
if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio))
|
2017-11-10 18:05:26 +00:00
|
|
|
{
|
|
|
|
return new WebAudioSoundManager(game);
|
|
|
|
}
|
|
|
|
|
2018-01-11 16:29:57 +00:00
|
|
|
return new HTML5AudioSoundManager(game);
|
2017-11-10 18:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = SoundManagerCreator;
|