From 9909ada0015b59dab135a5c492662a8aa8720836 Mon Sep 17 00:00:00 2001 From: samme Date: Tue, 21 Apr 2020 14:53:37 -0700 Subject: [PATCH] Add NoAudioSound methods --- src/sound/noaudio/NoAudioSound.js | 129 +++++++++++++++++++++++------- 1 file changed, 98 insertions(+), 31 deletions(-) diff --git a/src/sound/noaudio/NoAudioSound.js b/src/sound/noaudio/NoAudioSound.js index 5878d4019..df2bc1c4c 100644 --- a/src/sound/noaudio/NoAudioSound.js +++ b/src/sound/noaudio/NoAudioSound.js @@ -10,6 +10,21 @@ var Class = require('../../utils/Class'); var EventEmitter = require('eventemitter3'); var Extend = require('../../utils/object/Extend'); +var returnFalse = function () +{ + return false; +}; + +var returnNull = function () +{ + return null; +}; + +var returnThis = function () +{ + return this; +}; + /** * @classdesc * No audio implementation of the sound. It is used if audio has been @@ -71,51 +86,103 @@ var NoAudioSound = new Class({ 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 - addMarker: function (marker) - { - return false; - }, + addMarker: returnFalse, + /** + * @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 - updateMarker: function (marker) - { - return false; - }, + updateMarker: returnFalse, - // eslint-disable-next-line no-unused-vars - removeMarker: function (markerName) - { - return null; - }, + /** + * @method Phaser.Sound.NoAudioSound#removeMarker + * @since 3.0.0 + * + * @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) - { - return false; - }, + /** + * @method Phaser.Sound.NoAudioSound#play + * @since 3.0.0 + * + * @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 () - { - return false; - }, + /** + * @method Phaser.Sound.NoAudioSound#pause + * @since 3.0.0 + * + * @return {boolean} false + */ + pause: returnFalse, - resume: function () - { - return false; - }, + /** + * Resumes the sound. + * + * @method Phaser.Sound.NoAudioSound#resume + * @since 3.0.0 + * + * @return {boolean} false + */ + resume: returnFalse, - stop: function () - { - return false; - }, + /** + * Stop playing this sound. + * + * @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 () { this.manager.remove(this); BaseSound.prototype.destroy.call(this); - } + }, + + setMute: returnThis, + + setVolume: returnThis, + + setRate: returnThis, + + setDetune: returnThis, + + setSeek: returnThis, + + setLoop: returnThis + }); module.exports = NoAudioSound;