Skip to content

Commit c8bbea5

Browse files
committed
Fixed issue in HTMLAudioSound where mute would get into a recursive loop.
1 parent 623df29 commit c8bbea5

4 files changed

Lines changed: 26 additions & 64 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
* DynamicBitmapText was missing the `letterSpacing` property, causing it to only render the first character in WebGL (thanks @Antriel)
99
* The Animation component didn't properly check for the animation state in its update, causing pause / resume to fail. Fix #3556 (thanks @Antriel @siolfyr)
1010
* The Scene Manager would never reach an `isBooted` state if you didn't add any Scenes into the Game Config. Fix #3553 (thanks @rgk)
11+
* Fixed issue in HTMLAudioSound where `mute` would get into a recursive loop.
12+
13+
### Updates
14+
15+
* Removed the following properties from BaseSound as they are no longer required. Each class that extends BaseSound implements them directly as getters: `mute`, `loop`, `seek` and `volume`.
1116

1217
### Examples, Documentation and TypeScript
1318

src/sound/BaseSound.js

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -144,51 +144,6 @@ var BaseSound = new Class({
144144

145145
this.config = Extend(this.config, config);
146146

147-
/**
148-
* Boolean indicating whether the sound is muted or not.
149-
* Gets or sets the muted state of this sound.
150-
*
151-
* @name Phaser.Sound.BaseSound#mute
152-
* @type {boolean}
153-
* @default false
154-
* @since 3.0.0
155-
*/
156-
this.mute = false;
157-
158-
/**
159-
* Gets or sets the volume of this sound,
160-
* a value between 0 (silence) and 1 (full volume).
161-
*
162-
* @name Phaser.Sound.BaseSound#volume
163-
* @type {number}
164-
* @default 1
165-
* @since 3.0.0
166-
*/
167-
this.volume = 1;
168-
169-
/**
170-
* Property representing the position of playback for this sound, in seconds.
171-
* Setting it to a specific value moves current playback to that position.
172-
* The value given is clamped to the range 0 to current marker duration.
173-
* Setting seek of a stopped sound has no effect.
174-
*
175-
* @name Phaser.Sound.BaseSound#seek
176-
* @type {number}
177-
* @default 0
178-
* @since 3.0.0
179-
*/
180-
this.seek = 0;
181-
182-
/**
183-
* Flag indicating whether or not the sound or current sound marker will loop.
184-
*
185-
* @name Phaser.Sound.BaseSound#loop
186-
* @type {boolean}
187-
* @default false
188-
* @since 3.0.0
189-
*/
190-
this.loop = false;
191-
192147
/**
193148
* Object containing markers definitions.
194149
*
@@ -290,7 +245,7 @@ var BaseSound = new Class({
290245
if (!this.markers[marker.name])
291246
{
292247
// eslint-disable-next-line no-console
293-
console.error('updateMarker - Marker with name \'' + marker.name + '\' does not exist for sound \'' + this.key + '\'!');
248+
console.warn('Audio Marker: ' + marker.name + ' missing in Sound: ' + this.key);
294249

295250
return false;
296251
}
@@ -349,9 +304,6 @@ var BaseSound = new Class({
349304

350305
if (typeof markerName !== 'string')
351306
{
352-
// eslint-disable-next-line no-console
353-
console.error('Sound marker name has to be a string!');
354-
355307
return false;
356308
}
357309

@@ -366,7 +318,7 @@ var BaseSound = new Class({
366318
if (!this.markers[markerName])
367319
{
368320
// eslint-disable-next-line no-console
369-
console.error('No marker with name \'' + markerName + '\' found for sound \'' + this.key + '\'!');
321+
console.warn('Marker: ' + markerName + ' missing in Sound: ' + this.key);
370322

371323
return false;
372324
}

src/sound/html5/HTML5AudioSound.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var HTML5AudioSound = new Class({
4747
if (!this.tags)
4848
{
4949
// eslint-disable-next-line no-console
50-
console.error('No audio loaded in cache with key: \'' + key + '\'!');
50+
console.warn('Audio cache entry missing: ' + key);
5151
return;
5252
}
5353

@@ -119,6 +119,7 @@ var HTML5AudioSound = new Class({
119119
{
120120
return false;
121121
}
122+
122123
if (!BaseSound.prototype.play.call(this, markerName, config))
123124
{
124125
return false;
@@ -610,7 +611,8 @@ var HTML5AudioSound = new Class({
610611
*/
611612

612613
/**
613-
* [description]
614+
* Boolean indicating whether the sound is muted or not.
615+
* Gets or sets the muted state of this sound.
614616
*
615617
* @name Phaser.Sound.HTML5AudioSound#mute
616618
* @type {boolean}
@@ -633,8 +635,6 @@ var HTML5AudioSound = new Class({
633635
return;
634636
}
635637

636-
this.setMute();
637-
638638
this.emit('mute', this, value);
639639
}
640640
},
@@ -664,7 +664,7 @@ var HTML5AudioSound = new Class({
664664
*/
665665

666666
/**
667-
* [description]
667+
* Gets or sets the volume of this sound, a value between 0 (silence) and 1 (full volume).
668668
*
669669
* @name Phaser.Sound.HTML5AudioSound#volume
670670
* @type {number}
@@ -687,8 +687,6 @@ var HTML5AudioSound = new Class({
687687
return;
688688
}
689689

690-
this.setVolume();
691-
692690
this.emit('volume', this, value);
693691
}
694692
},
@@ -839,7 +837,10 @@ var HTML5AudioSound = new Class({
839837
*/
840838

841839
/**
842-
* [description]
840+
* Property representing the position of playback for this sound, in seconds.
841+
* Setting it to a specific value moves current playback to that position.
842+
* The value given is clamped to the range 0 to current marker duration.
843+
* Setting seek of a stopped sound has no effect.
843844
*
844845
* @name Phaser.Sound.HTML5AudioSound#seek
845846
* @type {number}
@@ -919,7 +920,7 @@ var HTML5AudioSound = new Class({
919920
*/
920921

921922
/**
922-
* [description]
923+
* Flag indicating whether or not the sound or current sound marker will loop.
923924
*
924925
* @name Phaser.Sound.HTML5AudioSound#loop
925926
* @type {boolean}

src/sound/webaudio/WebAudioSound.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var WebAudioSound = new Class({
4545
if (!this.audioBuffer)
4646
{
4747
// eslint-disable-next-line no-console
48-
console.error('No audio loaded in cache with key: \'' + key + '\'!');
48+
console.warn('Audio cache entry missing: ' + key);
4949
return;
5050
}
5151

@@ -727,7 +727,8 @@ var WebAudioSound = new Class({
727727
*/
728728

729729
/**
730-
* [description]
730+
* Boolean indicating whether the sound is muted or not.
731+
* Gets or sets the muted state of this sound.
731732
*
732733
* @name Phaser.Sound.WebAudioSound#mute
733734
* @type {boolean}
@@ -776,7 +777,7 @@ var WebAudioSound = new Class({
776777
*/
777778

778779
/**
779-
* [description]
780+
* Gets or sets the volume of this sound, a value between 0 (silence) and 1 (full volume).
780781
*
781782
* @name Phaser.Sound.WebAudioSound#volume
782783
* @type {number}
@@ -824,7 +825,10 @@ var WebAudioSound = new Class({
824825
*/
825826

826827
/**
827-
* [description]
828+
* Property representing the position of playback for this sound, in seconds.
829+
* Setting it to a specific value moves current playback to that position.
830+
* The value given is clamped to the range 0 to current marker duration.
831+
* Setting seek of a stopped sound has no effect.
828832
*
829833
* @name Phaser.Sound.WebAudioSound#seek
830834
* @type {number}
@@ -902,7 +906,7 @@ var WebAudioSound = new Class({
902906
*/
903907

904908
/**
905-
* [description]
909+
* Flag indicating whether or not the sound or current sound marker will loop.
906910
*
907911
* @name Phaser.Sound.WebAudioSound#loop
908912
* @type {boolean}

0 commit comments

Comments
 (0)