Skip to content

Commit 9909ada

Browse files
committed
Add NoAudioSound methods
1 parent 7fbe57c commit 9909ada

1 file changed

Lines changed: 101 additions & 34 deletions

File tree

src/sound/noaudio/NoAudioSound.js

Lines changed: 101 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ var Class = require('../../utils/Class');
1010
var EventEmitter = require('eventemitter3');
1111
var Extend = require('../../utils/object/Extend');
1212

13+
var returnFalse = function ()
14+
{
15+
return false;
16+
};
17+
18+
var returnNull = function ()
19+
{
20+
return null;
21+
};
22+
23+
var returnThis = function ()
24+
{
25+
return this;
26+
};
27+
1328
/**
1429
* @classdesc
1530
* No audio implementation of the sound. It is used if audio has been
@@ -71,51 +86,103 @@ var NoAudioSound = new Class({
7186
this.pendingRemove = false;
7287
},
7388

89+
/**
90+
* @method Phaser.Sound.NoAudioSound#addMarker
91+
* @since 3.0.0
92+
*
93+
* @param {Phaser.Types.Sound.SoundMarker} marker - Marker object.
94+
*
95+
* @return {boolean} false
96+
*/
7497
// eslint-disable-next-line no-unused-vars
75-
addMarker: function (marker)
76-
{
77-
return false;
78-
},
79-
98+
addMarker: returnFalse,
99+
100+
/**
101+
* @method Phaser.Sound.NoAudioSound#updateMarker
102+
* @since 3.0.0
103+
*
104+
* @param {Phaser.Types.Sound.SoundMarker} marker - Marker object with updated values.
105+
*
106+
* @return {boolean} false
107+
*/
80108
// eslint-disable-next-line no-unused-vars
81-
updateMarker: function (marker)
109+
updateMarker: returnFalse,
110+
111+
/**
112+
* @method Phaser.Sound.NoAudioSound#removeMarker
113+
* @since 3.0.0
114+
*
115+
* @param {string} markerName - The name of the marker to remove.
116+
*
117+
* @return {null} null
118+
*/
119+
removeMarker: returnNull,
120+
121+
/**
122+
* @method Phaser.Sound.NoAudioSound#play
123+
* @since 3.0.0
124+
*
125+
* @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.
126+
* @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.
127+
*
128+
* @return {boolean} false
129+
*/
130+
play: returnFalse,
131+
132+
/**
133+
* @method Phaser.Sound.NoAudioSound#pause
134+
* @since 3.0.0
135+
*
136+
* @return {boolean} false
137+
*/
138+
pause: returnFalse,
139+
140+
/**
141+
* Resumes the sound.
142+
*
143+
* @method Phaser.Sound.NoAudioSound#resume
144+
* @since 3.0.0
145+
*
146+
* @return {boolean} false
147+
*/
148+
resume: returnFalse,
149+
150+
/**
151+
* Stop playing this sound.
152+
*
153+
* @method Phaser.Sound.NoAudioSound#stop
154+
* @since 3.0.0
155+
*
156+
* @return {boolean} false
157+
*/
158+
stop: returnFalse,
159+
160+
/**
161+
* Destroys this sound and all associated events and marks it for removal from the sound manager.
162+
*
163+
* @method Phaser.Sound.NoAudioSound#destroy
164+
* @fires Phaser.Sound.Events#DESTROY
165+
* @since 3.0.0
166+
*/
167+
destroy: function ()
82168
{
83-
return false;
84-
},
169+
this.manager.remove(this);
85170

86-
// eslint-disable-next-line no-unused-vars
87-
removeMarker: function (markerName)
88-
{
89-
return null;
171+
BaseSound.prototype.destroy.call(this);
90172
},
91173

92-
// eslint-disable-next-line no-unused-vars
93-
play: function (markerName, config)
94-
{
95-
return false;
96-
},
174+
setMute: returnThis,
97175

98-
pause: function ()
99-
{
100-
return false;
101-
},
176+
setVolume: returnThis,
102177

103-
resume: function ()
104-
{
105-
return false;
106-
},
178+
setRate: returnThis,
107179

108-
stop: function ()
109-
{
110-
return false;
111-
},
180+
setDetune: returnThis,
112181

113-
destroy: function ()
114-
{
115-
this.manager.remove(this);
182+
setSeek: returnThis,
183+
184+
setLoop: returnThis
116185

117-
BaseSound.prototype.destroy.call(this);
118-
}
119186
});
120187

121188
module.exports = NoAudioSound;

0 commit comments

Comments
 (0)