Added new methods to NoAudio

This commit is contained in:
Richard Davey 2018-03-21 14:56:08 +00:00
parent 2433844cd3
commit eb10a0121a

View file

@ -1,8 +1,10 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @author Pavle Goloskokovic <pgoloskokovic@gmail.com> (http://prunegames.com)
* @copyright 2018 Photon Storm Ltd. * @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/ */
var BaseSoundManager = require('../BaseSoundManager'); var BaseSoundManager = require('../BaseSoundManager');
var Class = require('../../utils/Class'); var Class = require('../../utils/Class');
var EventEmitter = require('eventemitter3'); var EventEmitter = require('eventemitter3');
@ -22,16 +24,20 @@ var NOOP = require('../../utils/NOOP');
* @extends Phaser.Sound.BaseSoundManager * @extends Phaser.Sound.BaseSoundManager
* @memberOf Phaser.Sound * @memberOf Phaser.Sound
* @constructor * @constructor
* @author Pavle Goloskokovic <pgoloskokovic@gmail.com> (http://prunegames.com)
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.Game} game - Reference to the current game instance. * @param {Phaser.Game} game - Reference to the current game instance.
*/ */
var NoAudioSoundManager = new Class({ var NoAudioSoundManager = new Class({
Extends: EventEmitter, Extends: EventEmitter,
initialize: function NoAudioSoundManager (game)
initialize:
function NoAudioSoundManager (game)
{ {
EventEmitter.call(this); EventEmitter.call(this);
this.game = game; this.game = game;
this.sounds = []; this.sounds = [];
this.mute = false; this.mute = false;
@ -41,47 +47,66 @@ var NoAudioSoundManager = new Class({
this.pauseOnBlur = true; this.pauseOnBlur = true;
this.locked = false; this.locked = false;
}, },
add: function (key, config) add: function (key, config)
{ {
var sound = new NoAudioSound(this, key, config); var sound = new NoAudioSound(this, key, config);
this.sounds.push(sound); this.sounds.push(sound);
return sound; return sound;
}, },
addAudioSprite: function (key, config) addAudioSprite: function (key, config)
{ {
var sound = this.add(key, config); var sound = this.add(key, config);
sound.spritemap = {}; sound.spritemap = {};
return sound; return sound;
}, },
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
play: function (key, extra) play: function (key, extra)
{ {
return false; return false;
}, },
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
playAudioSprite: function (key, spriteName, config) playAudioSprite: function (key, spriteName, config)
{ {
return false; return false;
}, },
remove: function (sound) remove: function (sound)
{ {
return BaseSoundManager.prototype.remove.call(this, sound); return BaseSoundManager.prototype.remove.call(this, sound);
}, },
removeByKey: function (key) removeByKey: function (key)
{ {
return BaseSoundManager.prototype.removeByKey.call(this, key); return BaseSoundManager.prototype.removeByKey.call(this, key);
}, },
pauseAll: NOOP, pauseAll: NOOP,
resumeAll: NOOP, resumeAll: NOOP,
stopAll: NOOP, stopAll: NOOP,
update: NOOP, update: NOOP,
destroy: function () setRate: NOOP,
{ setDetune: NOOP,
BaseSoundManager.prototype.destroy.call(this); setMute: NOOP,
}, setVolume: NOOP,
forEachActiveSound: function (callbackfn, scope) forEachActiveSound: function (callbackfn, scope)
{ {
BaseSoundManager.prototype.forEachActiveSound.call(this, callbackfn, scope); BaseSoundManager.prototype.forEachActiveSound.call(this, callbackfn, scope);
},
destroy: function ()
{
BaseSoundManager.prototype.destroy.call(this);
} }
}); });
module.exports = NoAudioSoundManager; module.exports = NoAudioSoundManager;