phaser/src/sound/noaudio/NoAudioSoundManager.js

79 lines
2.3 KiB
JavaScript
Raw Normal View History

var Class = require('../../utils/Class');
var EventEmitter = require('eventemitter3');
var NoAudioSound = require('./NoAudioSound');
var BaseSoundManager = require('../BaseSoundManager');
var NOOP = require('../../utils/NOOP');
2018-01-26 14:40:45 +00:00
/*!
* @author Pavle Goloskokovic <pgoloskokovic@gmail.com> (http://prunegames.com)
*/
var NoAudioSoundManager = new Class({
Extends: EventEmitter,
2018-01-26 14:40:45 +00:00
/**
* No audio implementation of the sound manager. It is used if audio has been
* disabled in the game config or the device doesn't support any audio.
*
* It represents a graceful degradation of sound manager logic that provides
* minimal functionality and prevents Phaser projects that use audio from
* breaking on devices that don't support any audio playback technologies.
*
* @class Phaser.Sound.NoAudioSoundManager
* @constructor
* @param {Phaser.Game} game - Reference to the current game instance.
*/
2018-01-26 14:40:45 +00:00
initialize: function NoAudioSoundManager (game)
{
EventEmitter.call(this);
this.game = game;
this.sounds = [];
2018-01-20 19:00:21 +00:00
this.mute = false;
2018-01-20 19:00:36 +00:00
this.volume = 1;
2018-01-20 19:00:55 +00:00
this.rate = 1;
2018-01-20 19:01:09 +00:00
this.detune = 0;
this.pauseOnBlur = true;
2018-01-20 19:01:44 +00:00
this.locked = false;
},
2018-01-26 14:40:45 +00:00
add: function (key, config)
{
var sound = new NoAudioSound(this, key, config);
this.sounds.push(sound);
return sound;
},
2018-01-26 14:40:45 +00:00
addAudioSprite: function (key, config)
{
var sound = this.add(key, config);
sound.spritemap = {};
return sound;
},
2018-01-26 14:40:45 +00:00
play: function (key, extra)
{
return false;
},
2018-01-26 14:40:45 +00:00
playAudioSprite: function (key, spriteName, config)
{
return false;
},
2018-01-26 14:40:45 +00:00
remove: function (sound)
{
return BaseSoundManager.prototype.remove.call(this, sound);
},
2018-01-26 14:40:45 +00:00
removeByKey: function (key)
{
return BaseSoundManager.prototype.removeByKey.call(this, key);
},
pauseAll: NOOP,
2018-01-20 19:25:27 +00:00
resumeAll: NOOP,
2018-01-20 19:31:53 +00:00
stopAll: NOOP,
update: NOOP,
2018-01-26 14:40:45 +00:00
destroy: function ()
{
BaseSoundManager.prototype.destroy.call(this);
},
2018-01-26 14:40:45 +00:00
forEachActiveSound: function (callbackfn, thisArg)
{
BaseSoundManager.prototype.forEachActiveSound.call(this, callbackfn, thisArg);
}
});
module.exports = NoAudioSoundManager;