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)
|
2019-01-15 16:20:22 +00:00
|
|
|
* @copyright 2019 Photon Storm Ltd.
|
2019-05-10 15:15:04 +00:00
|
|
|
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
2018-02-12 16:01:20 +00:00
|
|
|
*/
|
|
|
|
|
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.
|
|
|
|
*
|
2018-05-04 10:33:56 +00:00
|
|
|
* Be aware of https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
|
|
|
|
*
|
2018-02-12 12:25:30 +00:00
|
|
|
* @function Phaser.Sound.SoundManagerCreator
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.Game} game - Reference to the current game instance.
|
2020-01-15 10:29:09 +00:00
|
|
|
*
|
|
|
|
* @return {(Phaser.Sound.HTML5AudioSoundManager|Phaser.Sound.WebAudioSoundManager|Phaser.Sound.NoAudioSoundManager)} The Sound Manager instance that was created.
|
2018-02-12 12:25:30 +00:00
|
|
|
*/
|
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;
|