Add NoAudioSound methods

This commit is contained in:
samme 2020-04-21 14:53:37 -07:00
parent 7fbe57c2dd
commit 9909ada001

View file

@ -10,6 +10,21 @@ var Class = require('../../utils/Class');
var EventEmitter = require('eventemitter3'); var EventEmitter = require('eventemitter3');
var Extend = require('../../utils/object/Extend'); var Extend = require('../../utils/object/Extend');
var returnFalse = function ()
{
return false;
};
var returnNull = function ()
{
return null;
};
var returnThis = function ()
{
return this;
};
/** /**
* @classdesc * @classdesc
* No audio implementation of the sound. It is used if audio has been * No audio implementation of the sound. It is used if audio has been
@ -71,51 +86,103 @@ var NoAudioSound = new Class({
this.pendingRemove = false; this.pendingRemove = false;
}, },
/**
* @method Phaser.Sound.NoAudioSound#addMarker
* @since 3.0.0
*
* @param {Phaser.Types.Sound.SoundMarker} marker - Marker object.
*
* @return {boolean} false
*/
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
addMarker: function (marker) addMarker: returnFalse,
{
return false;
},
/**
* @method Phaser.Sound.NoAudioSound#updateMarker
* @since 3.0.0
*
* @param {Phaser.Types.Sound.SoundMarker} marker - Marker object with updated values.
*
* @return {boolean} false
*/
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
updateMarker: function (marker) updateMarker: returnFalse,
{
return false;
},
// eslint-disable-next-line no-unused-vars /**
removeMarker: function (markerName) * @method Phaser.Sound.NoAudioSound#removeMarker
{ * @since 3.0.0
return null; *
}, * @param {string} markerName - The name of the marker to remove.
*
* @return {null} null
*/
removeMarker: returnNull,
// eslint-disable-next-line no-unused-vars /**
play: function (markerName, config) * @method Phaser.Sound.NoAudioSound#play
{ * @since 3.0.0
return false; *
}, * @param {(string|Phaser.Types.Sound.SoundConfig)} [markerName=''] - If you want to play a marker then provide the marker name here. Alternatively, this parameter can be a SoundConfig object.
* @param {Phaser.Types.Sound.SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound.
*
* @return {boolean} false
*/
play: returnFalse,
pause: function () /**
{ * @method Phaser.Sound.NoAudioSound#pause
return false; * @since 3.0.0
}, *
* @return {boolean} false
*/
pause: returnFalse,
resume: function () /**
{ * Resumes the sound.
return false; *
}, * @method Phaser.Sound.NoAudioSound#resume
* @since 3.0.0
*
* @return {boolean} false
*/
resume: returnFalse,
stop: function () /**
{ * Stop playing this sound.
return false; *
}, * @method Phaser.Sound.NoAudioSound#stop
* @since 3.0.0
*
* @return {boolean} false
*/
stop: returnFalse,
/**
* Destroys this sound and all associated events and marks it for removal from the sound manager.
*
* @method Phaser.Sound.NoAudioSound#destroy
* @fires Phaser.Sound.Events#DESTROY
* @since 3.0.0
*/
destroy: function () destroy: function ()
{ {
this.manager.remove(this); this.manager.remove(this);
BaseSound.prototype.destroy.call(this); BaseSound.prototype.destroy.call(this);
} },
setMute: returnThis,
setVolume: returnThis,
setRate: returnThis,
setDetune: returnThis,
setSeek: returnThis,
setLoop: returnThis
}); });
module.exports = NoAudioSound; module.exports = NoAudioSound;