@tsparticles/plugin-sounds 4.0.0-alpha.8 → 4.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/30.min.js +33 -0
  2. package/915.min.js +1 -0
  3. package/browser/Options/Classes/Sounds.js +5 -0
  4. package/browser/Options/Classes/SoundsAudio.js +2 -0
  5. package/browser/Options/Classes/SoundsEvent.js +5 -0
  6. package/browser/Options/Classes/SoundsIcon.js +5 -0
  7. package/browser/Options/Classes/SoundsIcons.js +5 -0
  8. package/browser/Options/Classes/SoundsMelody.js +3 -0
  9. package/browser/Options/Classes/SoundsNote.js +2 -0
  10. package/browser/Options/Classes/SoundsVolume.js +4 -0
  11. package/browser/SoundsPlugin.js +2 -1
  12. package/browser/SoundsPluginInstance.js +246 -237
  13. package/browser/index.js +1 -1
  14. package/cjs/Options/Classes/Sounds.js +5 -0
  15. package/cjs/Options/Classes/SoundsAudio.js +2 -0
  16. package/cjs/Options/Classes/SoundsEvent.js +5 -0
  17. package/cjs/Options/Classes/SoundsIcon.js +5 -0
  18. package/cjs/Options/Classes/SoundsIcons.js +5 -0
  19. package/cjs/Options/Classes/SoundsMelody.js +3 -0
  20. package/cjs/Options/Classes/SoundsNote.js +2 -0
  21. package/cjs/Options/Classes/SoundsVolume.js +4 -0
  22. package/cjs/SoundsPlugin.js +2 -1
  23. package/cjs/SoundsPluginInstance.js +246 -237
  24. package/cjs/index.js +1 -1
  25. package/dist_browser_SoundsPluginInstance_js.js +3 -3
  26. package/dist_browser_SoundsPlugin_js.js +12 -12
  27. package/esm/Options/Classes/Sounds.js +5 -0
  28. package/esm/Options/Classes/SoundsAudio.js +2 -0
  29. package/esm/Options/Classes/SoundsEvent.js +5 -0
  30. package/esm/Options/Classes/SoundsIcon.js +5 -0
  31. package/esm/Options/Classes/SoundsIcons.js +5 -0
  32. package/esm/Options/Classes/SoundsMelody.js +3 -0
  33. package/esm/Options/Classes/SoundsNote.js +2 -0
  34. package/esm/Options/Classes/SoundsVolume.js +4 -0
  35. package/esm/SoundsPlugin.js +2 -1
  36. package/esm/SoundsPluginInstance.js +246 -237
  37. package/esm/index.js +1 -1
  38. package/package.json +2 -2
  39. package/report.html +1 -1
  40. package/tsparticles.plugin.sounds.js +31 -19
  41. package/tsparticles.plugin.sounds.min.js +2 -2
  42. package/types/SoundsPlugin.d.ts +1 -1
  43. package/umd/Options/Classes/Sounds.js +5 -0
  44. package/umd/Options/Classes/SoundsAudio.js +2 -0
  45. package/umd/Options/Classes/SoundsEvent.js +5 -0
  46. package/umd/Options/Classes/SoundsIcon.js +5 -0
  47. package/umd/Options/Classes/SoundsIcons.js +5 -0
  48. package/umd/Options/Classes/SoundsMelody.js +3 -0
  49. package/umd/Options/Classes/SoundsNote.js +2 -0
  50. package/umd/Options/Classes/SoundsVolume.js +4 -0
  51. package/umd/SoundsPlugin.js +2 -1
  52. package/umd/SoundsPluginInstance.js +246 -237
  53. package/umd/index.js +1 -1
  54. package/296.min.js +0 -2
  55. package/296.min.js.LICENSE.txt +0 -1
  56. package/340.min.js +0 -2
  57. package/340.min.js.LICENSE.txt +0 -1
  58. package/tsparticles.plugin.sounds.min.js.LICENSE.txt +0 -1
@@ -15,6 +15,11 @@
15
15
  const SoundsIcons_js_1 = require("./SoundsIcons.js");
16
16
  const SoundsVolume_js_1 = require("./SoundsVolume.js");
17
17
  class Sounds {
18
+ autoPlay;
19
+ enable;
20
+ events;
21
+ icons;
22
+ volume;
18
23
  constructor() {
19
24
  this.autoPlay = true;
20
25
  this.enable = false;
@@ -12,6 +12,8 @@
12
12
  exports.SoundsAudio = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  class SoundsAudio {
15
+ loop;
16
+ source;
15
17
  constructor() {
16
18
  this.loop = false;
17
19
  this.source = "";
@@ -15,6 +15,11 @@
15
15
  const SoundsMelody_js_1 = require("./SoundsMelody.js");
16
16
  const SoundsNote_js_1 = require("./SoundsNote.js");
17
17
  class SoundsEvent {
18
+ audio;
19
+ event;
20
+ filter;
21
+ melodies;
22
+ notes;
18
23
  constructor() {
19
24
  this.event = [];
20
25
  this.notes = [];
@@ -12,6 +12,11 @@
12
12
  exports.SoundsIcon = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  class SoundsIcon {
15
+ height;
16
+ path;
17
+ style;
18
+ svg;
19
+ width;
15
20
  constructor() {
16
21
  this.width = 24;
17
22
  this.height = 24;
@@ -13,6 +13,11 @@
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  const SoundsIcon_js_1 = require("./SoundsIcon.js");
15
15
  class SoundsIcons {
16
+ enable;
17
+ mute;
18
+ unmute;
19
+ volumeDown;
20
+ volumeUp;
16
21
  constructor() {
17
22
  this.mute = new SoundsIcon_js_1.SoundsIcon();
18
23
  this.unmute = new SoundsIcon_js_1.SoundsIcon();
@@ -13,6 +13,9 @@
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  const SoundsNote_js_1 = require("./SoundsNote.js");
15
15
  class SoundsMelody {
16
+ loop;
17
+ melodies;
18
+ notes;
16
19
  constructor() {
17
20
  this.loop = false;
18
21
  this.melodies = [];
@@ -12,6 +12,8 @@
12
12
  exports.SoundsNote = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  class SoundsNote {
15
+ duration;
16
+ value;
15
17
  constructor() {
16
18
  this.duration = 500;
17
19
  this.value = [];
@@ -12,6 +12,10 @@
12
12
  exports.SoundsVolume = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  class SoundsVolume {
15
+ max;
16
+ min;
17
+ step;
18
+ value;
15
19
  constructor() {
16
20
  this.value = 100;
17
21
  this.max = 100;
@@ -53,8 +53,9 @@ var __importStar = (this && this.__importStar) || (function () {
53
53
  (0, utils_js_1.unmuteWindow)();
54
54
  };
55
55
  class SoundsPlugin {
56
+ id = "sounds";
57
+ _engine;
56
58
  constructor(engine) {
57
- this.id = "sounds";
58
59
  this._engine = engine;
59
60
  const listenerOptions = {
60
61
  capture: true,
@@ -43,242 +43,17 @@
43
43
  icon.style.cssText += style;
44
44
  }
45
45
  class SoundsPluginInstance {
46
+ _audioMap;
47
+ _audioSources;
48
+ _container;
49
+ _engine;
50
+ _gain;
51
+ _muteImg;
52
+ _unmuteImg;
53
+ _volume;
54
+ _volumeDownImg;
55
+ _volumeUpImg;
46
56
  constructor(container, engine) {
47
- this._addBuffer = audioCtx => {
48
- const buffer = audioCtx.createBufferSource();
49
- this._audioSources.push(buffer);
50
- return buffer;
51
- };
52
- this._addOscillator = audioCtx => {
53
- const oscillator = audioCtx.createOscillator();
54
- this._audioSources.push(oscillator);
55
- return oscillator;
56
- };
57
- this._initEvents = () => {
58
- const container = this._container, soundsOptions = container.actualOptions.sounds;
59
- if (!soundsOptions?.enable || !container.canvas.element) {
60
- return;
61
- }
62
- for (const event of soundsOptions.events) {
63
- const cb = (args) => {
64
- if (!args) {
65
- return;
66
- }
67
- void (async () => {
68
- const filterNotValid = event.filter && !event.filter(args);
69
- if (this._container !== args.container) {
70
- return;
71
- }
72
- if (!!this._container.muted || this._container.destroyed) {
73
- (0, engine_1.executeOnSingleOrMultiple)(event.event, item => {
74
- this._engine.removeEventListener(item, cb);
75
- });
76
- return;
77
- }
78
- if (filterNotValid) {
79
- return;
80
- }
81
- const defaultNoteIndex = 0;
82
- if (event.audio) {
83
- const audio = (0, engine_1.itemFromSingleOrMultiple)(event.audio);
84
- if (!audio) {
85
- return;
86
- }
87
- this._playBuffer(audio);
88
- }
89
- else if (event.melodies) {
90
- const melody = (0, engine_1.itemFromArray)(event.melodies);
91
- if (!melody) {
92
- return;
93
- }
94
- if (melody.melodies.length) {
95
- await Promise.allSettled(melody.melodies.map(m => this._playNote(m.notes, defaultNoteIndex, melody.loop)));
96
- }
97
- else {
98
- await this._playNote(melody.notes, defaultNoteIndex, melody.loop);
99
- }
100
- }
101
- else if (event.notes) {
102
- const note = (0, engine_1.itemFromArray)(event.notes);
103
- if (!note) {
104
- return;
105
- }
106
- await this._playNote([note], defaultNoteIndex, false);
107
- }
108
- })();
109
- };
110
- (0, engine_1.executeOnSingleOrMultiple)(event.event, item => {
111
- this._engine.addEventListener(item, cb);
112
- });
113
- }
114
- };
115
- this._mute = async () => {
116
- const container = this._container, audioContext = this._getAudioContext();
117
- for (const source of this._audioSources) {
118
- this._removeAudioSource(source);
119
- }
120
- if (this._gain) {
121
- this._gain.disconnect();
122
- }
123
- await audioContext.close();
124
- container.audioContext = undefined;
125
- this._engine.dispatchEvent(enums_js_1.SoundsEventType.mute, { container: this._container });
126
- };
127
- this._playBuffer = audio => {
128
- const audioBuffer = this._audioMap.get(audio.source);
129
- if (!audioBuffer) {
130
- return;
131
- }
132
- const audioCtx = this._container.audioContext;
133
- if (!audioCtx) {
134
- return;
135
- }
136
- const source = this._addBuffer(audioCtx);
137
- source.loop = audio.loop;
138
- source.buffer = audioBuffer;
139
- source.connect(this._gain ?? audioCtx.destination);
140
- source.start();
141
- };
142
- this._playFrequency = async (frequency, duration) => {
143
- if (!this._gain || this._container.muted) {
144
- return;
145
- }
146
- const audioContext = this._getAudioContext(), oscillator = this._addOscillator(audioContext);
147
- oscillator.connect(this._gain);
148
- oscillator.type = "sine";
149
- oscillator.frequency.value = frequency;
150
- oscillator.start();
151
- return new Promise(resolve => {
152
- setTimeout(() => {
153
- this._removeAudioSource(oscillator);
154
- resolve();
155
- }, duration);
156
- });
157
- };
158
- this._playMuteSound = () => {
159
- if (this._container.muted) {
160
- return;
161
- }
162
- const audioContext = this._getAudioContext(), gain = audioContext.createGain();
163
- gain.connect(audioContext.destination);
164
- gain.gain.value = 0;
165
- const oscillator = audioContext.createOscillator();
166
- oscillator.connect(gain);
167
- oscillator.type = "sine";
168
- oscillator.frequency.value = 1;
169
- oscillator.start();
170
- setTimeout(() => {
171
- oscillator.stop();
172
- oscillator.disconnect();
173
- gain.disconnect();
174
- });
175
- };
176
- this._playNote = async (notes, noteIdx, loop) => {
177
- if (this._container.muted) {
178
- return;
179
- }
180
- const note = notes[noteIdx];
181
- if (!note) {
182
- return;
183
- }
184
- const value = note.value, promises = (0, engine_1.executeOnSingleOrMultiple)(value, async (_, idx) => {
185
- return this._playNoteValue(notes, noteIdx, idx);
186
- });
187
- await ((0, engine_1.isArray)(promises) ? Promise.allSettled(promises) : promises);
188
- const indexOffset = 1;
189
- let nextNoteIdx = noteIdx + indexOffset;
190
- if (loop && nextNoteIdx >= notes.length) {
191
- nextNoteIdx = nextNoteIdx % notes.length;
192
- }
193
- await this._playNote(notes, nextNoteIdx, loop);
194
- };
195
- this._playNoteValue = async (notes, noteIdx, valueIdx) => {
196
- const note = notes[noteIdx];
197
- if (!note) {
198
- return;
199
- }
200
- const value = (0, engine_1.itemFromSingleOrMultiple)(note.value, valueIdx, true);
201
- if (!value) {
202
- return;
203
- }
204
- try {
205
- const freq = (0, utils_js_1.getNoteFrequency)(value);
206
- if (!(0, engine_1.isNumber)(freq)) {
207
- return;
208
- }
209
- await this._playFrequency(freq, note.duration);
210
- }
211
- catch (e) {
212
- (0, engine_1.getLogger)().error(e);
213
- }
214
- };
215
- this._removeAudioSource = source => {
216
- source.stop();
217
- source.disconnect();
218
- const deleteCount = 1;
219
- this._audioSources.splice(this._audioSources.indexOf(source), deleteCount);
220
- };
221
- this._unmute = () => {
222
- const container = this._container, options = container.actualOptions, soundsOptions = options.sounds;
223
- if (!soundsOptions) {
224
- return;
225
- }
226
- const audioContext = this._getAudioContext(), gain = audioContext.createGain();
227
- gain.connect(audioContext.destination);
228
- gain.gain.value = soundsOptions.volume.value / engine_1.percentDenominator;
229
- this._gain = gain;
230
- this._initEvents();
231
- this._engine.dispatchEvent(enums_js_1.SoundsEventType.unmute, { container: this._container });
232
- };
233
- this._updateMuteIcons = () => {
234
- const container = this._container, soundsOptions = container.actualOptions.sounds;
235
- if (!soundsOptions?.enable || !soundsOptions.icons.enable) {
236
- return;
237
- }
238
- const muteImg = this._muteImg, unmuteImg = this._unmuteImg;
239
- if (muteImg) {
240
- muteImg.style.display = container.muted ? "block" : "none";
241
- }
242
- if (unmuteImg) {
243
- unmuteImg.style.display = container.muted ? "none" : "block";
244
- }
245
- };
246
- this._updateMuteStatus = async () => {
247
- const container = this._container, audioContext = this._getAudioContext();
248
- if (container.muted) {
249
- await audioContext.suspend();
250
- await this._mute();
251
- }
252
- else {
253
- await audioContext.resume();
254
- this._unmute();
255
- this._playMuteSound();
256
- }
257
- };
258
- this._updateVolume = async () => {
259
- const container = this._container, soundsOptions = container.actualOptions.sounds;
260
- if (!soundsOptions?.enable) {
261
- return;
262
- }
263
- (0, engine_1.clamp)(this._volume, soundsOptions.volume.min, soundsOptions.volume.max);
264
- let stateChanged = false;
265
- if (this._volume <= minVolume && !container.muted) {
266
- this._volume = 0;
267
- container.muted = true;
268
- stateChanged = true;
269
- }
270
- else if (this._volume > minVolume && container.muted) {
271
- container.muted = false;
272
- stateChanged = true;
273
- }
274
- if (stateChanged) {
275
- this._updateMuteIcons();
276
- await this._updateMuteStatus();
277
- }
278
- if (this._gain?.gain) {
279
- this._gain.gain.value = this._volume / engine_1.percentDenominator;
280
- }
281
- };
282
57
  this._container = container;
283
58
  this._engine = engine;
284
59
  this._volume = 0;
@@ -296,8 +71,7 @@
296
71
  removeEventListener(constants_js_1.touchStartEvent, firstClickHandler);
297
72
  (0, utils_js_1.unmuteWindow)();
298
73
  void this.unmute();
299
- };
300
- const listenerOptions = {
74
+ }, listenerOptions = {
301
75
  capture: true,
302
76
  once: true,
303
77
  };
@@ -432,11 +206,246 @@
432
206
  this._volume += soundsOptions.volume.step;
433
207
  await this._updateVolume();
434
208
  }
209
+ _addBuffer = audioCtx => {
210
+ const buffer = audioCtx.createBufferSource();
211
+ this._audioSources.push(buffer);
212
+ return buffer;
213
+ };
214
+ _addOscillator = audioCtx => {
215
+ const oscillator = audioCtx.createOscillator();
216
+ this._audioSources.push(oscillator);
217
+ return oscillator;
218
+ };
435
219
  _getAudioContext() {
436
220
  const container = this._container;
437
221
  container.audioContext ??= new AudioContext();
438
222
  return container.audioContext;
439
223
  }
224
+ _initEvents = () => {
225
+ const container = this._container, soundsOptions = container.actualOptions.sounds;
226
+ if (!soundsOptions?.enable || !container.canvas.element) {
227
+ return;
228
+ }
229
+ for (const event of soundsOptions.events) {
230
+ const cb = (args) => {
231
+ if (!args) {
232
+ return;
233
+ }
234
+ void (async () => {
235
+ const filterNotValid = event.filter && !event.filter(args);
236
+ if (this._container !== args.container) {
237
+ return;
238
+ }
239
+ if (!!this._container.muted || this._container.destroyed) {
240
+ (0, engine_1.executeOnSingleOrMultiple)(event.event, item => {
241
+ this._engine.removeEventListener(item, cb);
242
+ });
243
+ return;
244
+ }
245
+ if (filterNotValid) {
246
+ return;
247
+ }
248
+ const defaultNoteIndex = 0;
249
+ if (event.audio) {
250
+ const audio = (0, engine_1.itemFromSingleOrMultiple)(event.audio);
251
+ if (!audio) {
252
+ return;
253
+ }
254
+ this._playBuffer(audio);
255
+ }
256
+ else if (event.melodies) {
257
+ const melody = (0, engine_1.itemFromArray)(event.melodies);
258
+ if (!melody) {
259
+ return;
260
+ }
261
+ if (melody.melodies.length) {
262
+ await Promise.allSettled(melody.melodies.map(m => this._playNote(m.notes, defaultNoteIndex, melody.loop)));
263
+ }
264
+ else {
265
+ await this._playNote(melody.notes, defaultNoteIndex, melody.loop);
266
+ }
267
+ }
268
+ else if (event.notes) {
269
+ const note = (0, engine_1.itemFromArray)(event.notes);
270
+ if (!note) {
271
+ return;
272
+ }
273
+ await this._playNote([note], defaultNoteIndex, false);
274
+ }
275
+ })();
276
+ };
277
+ (0, engine_1.executeOnSingleOrMultiple)(event.event, item => {
278
+ this._engine.addEventListener(item, cb);
279
+ });
280
+ }
281
+ };
282
+ _mute = async () => {
283
+ const container = this._container, audioContext = this._getAudioContext();
284
+ for (const source of this._audioSources) {
285
+ this._removeAudioSource(source);
286
+ }
287
+ if (this._gain) {
288
+ this._gain.disconnect();
289
+ }
290
+ await audioContext.close();
291
+ container.audioContext = undefined;
292
+ this._engine.dispatchEvent(enums_js_1.SoundsEventType.mute, { container: this._container });
293
+ };
294
+ _playBuffer = audio => {
295
+ const audioBuffer = this._audioMap.get(audio.source);
296
+ if (!audioBuffer) {
297
+ return;
298
+ }
299
+ const audioCtx = this._container.audioContext;
300
+ if (!audioCtx) {
301
+ return;
302
+ }
303
+ const source = this._addBuffer(audioCtx);
304
+ source.loop = audio.loop;
305
+ source.buffer = audioBuffer;
306
+ source.connect(this._gain ?? audioCtx.destination);
307
+ source.start();
308
+ };
309
+ _playFrequency = async (frequency, duration) => {
310
+ if (!this._gain || this._container.muted) {
311
+ return;
312
+ }
313
+ const audioContext = this._getAudioContext(), oscillator = this._addOscillator(audioContext);
314
+ oscillator.connect(this._gain);
315
+ oscillator.type = "sine";
316
+ oscillator.frequency.value = frequency;
317
+ oscillator.start();
318
+ return new Promise(resolve => {
319
+ setTimeout(() => {
320
+ this._removeAudioSource(oscillator);
321
+ resolve();
322
+ }, duration);
323
+ });
324
+ };
325
+ _playMuteSound = () => {
326
+ if (this._container.muted) {
327
+ return;
328
+ }
329
+ const audioContext = this._getAudioContext(), gain = audioContext.createGain();
330
+ gain.connect(audioContext.destination);
331
+ gain.gain.value = 0;
332
+ const oscillator = audioContext.createOscillator();
333
+ oscillator.connect(gain);
334
+ oscillator.type = "sine";
335
+ oscillator.frequency.value = 1;
336
+ oscillator.start();
337
+ setTimeout(() => {
338
+ oscillator.stop();
339
+ oscillator.disconnect();
340
+ gain.disconnect();
341
+ });
342
+ };
343
+ _playNote = async (notes, noteIdx, loop) => {
344
+ if (this._container.muted) {
345
+ return;
346
+ }
347
+ const note = notes[noteIdx];
348
+ if (!note) {
349
+ return;
350
+ }
351
+ const value = note.value, promises = (0, engine_1.executeOnSingleOrMultiple)(value, async (_, idx) => {
352
+ return this._playNoteValue(notes, noteIdx, idx);
353
+ });
354
+ await ((0, engine_1.isArray)(promises) ? Promise.allSettled(promises) : promises);
355
+ const indexOffset = 1;
356
+ let nextNoteIdx = noteIdx + indexOffset;
357
+ if (loop && nextNoteIdx >= notes.length) {
358
+ nextNoteIdx = nextNoteIdx % notes.length;
359
+ }
360
+ await this._playNote(notes, nextNoteIdx, loop);
361
+ };
362
+ _playNoteValue = async (notes, noteIdx, valueIdx) => {
363
+ const note = notes[noteIdx];
364
+ if (!note) {
365
+ return;
366
+ }
367
+ const value = (0, engine_1.itemFromSingleOrMultiple)(note.value, valueIdx, true);
368
+ if (!value) {
369
+ return;
370
+ }
371
+ try {
372
+ const freq = (0, utils_js_1.getNoteFrequency)(value);
373
+ if (!(0, engine_1.isNumber)(freq)) {
374
+ return;
375
+ }
376
+ await this._playFrequency(freq, note.duration);
377
+ }
378
+ catch (e) {
379
+ (0, engine_1.getLogger)().error(e);
380
+ }
381
+ };
382
+ _removeAudioSource = source => {
383
+ source.stop();
384
+ source.disconnect();
385
+ const deleteCount = 1;
386
+ this._audioSources.splice(this._audioSources.indexOf(source), deleteCount);
387
+ };
388
+ _unmute = () => {
389
+ const container = this._container, options = container.actualOptions, soundsOptions = options.sounds;
390
+ if (!soundsOptions) {
391
+ return;
392
+ }
393
+ const audioContext = this._getAudioContext(), gain = audioContext.createGain();
394
+ gain.connect(audioContext.destination);
395
+ gain.gain.value = soundsOptions.volume.value / engine_1.percentDenominator;
396
+ this._gain = gain;
397
+ this._initEvents();
398
+ this._engine.dispatchEvent(enums_js_1.SoundsEventType.unmute, { container: this._container });
399
+ };
400
+ _updateMuteIcons = () => {
401
+ const container = this._container, soundsOptions = container.actualOptions.sounds;
402
+ if (!soundsOptions?.enable || !soundsOptions.icons.enable) {
403
+ return;
404
+ }
405
+ const muteImg = this._muteImg, unmuteImg = this._unmuteImg;
406
+ if (muteImg) {
407
+ muteImg.style.display = container.muted ? "block" : "none";
408
+ }
409
+ if (unmuteImg) {
410
+ unmuteImg.style.display = container.muted ? "none" : "block";
411
+ }
412
+ };
413
+ _updateMuteStatus = async () => {
414
+ const container = this._container, audioContext = this._getAudioContext();
415
+ if (container.muted) {
416
+ await audioContext.suspend();
417
+ await this._mute();
418
+ }
419
+ else {
420
+ await audioContext.resume();
421
+ this._unmute();
422
+ this._playMuteSound();
423
+ }
424
+ };
425
+ _updateVolume = async () => {
426
+ const container = this._container, soundsOptions = container.actualOptions.sounds;
427
+ if (!soundsOptions?.enable) {
428
+ return;
429
+ }
430
+ (0, engine_1.clamp)(this._volume, soundsOptions.volume.min, soundsOptions.volume.max);
431
+ let stateChanged = false;
432
+ if (this._volume <= minVolume && !container.muted) {
433
+ this._volume = 0;
434
+ container.muted = true;
435
+ stateChanged = true;
436
+ }
437
+ else if (this._volume > minVolume && container.muted) {
438
+ container.muted = false;
439
+ stateChanged = true;
440
+ }
441
+ if (stateChanged) {
442
+ this._updateMuteIcons();
443
+ await this._updateMuteStatus();
444
+ }
445
+ if (this._gain?.gain) {
446
+ this._gain.gain.value = this._volume / engine_1.percentDenominator;
447
+ }
448
+ };
440
449
  }
441
450
  exports.SoundsPluginInstance = SoundsPluginInstance;
442
451
  });
package/umd/index.js CHANGED
@@ -45,7 +45,7 @@ var __importStar = (this && this.__importStar) || (function () {
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
46
  exports.loadSoundsPlugin = loadSoundsPlugin;
47
47
  async function loadSoundsPlugin(engine) {
48
- engine.checkVersion("4.0.0-alpha.8");
48
+ engine.checkVersion("4.0.0-beta.0");
49
49
  await engine.register(async (e) => {
50
50
  const { SoundsPlugin } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./SoundsPlugin.js"))) : new Promise((resolve_1, reject_1) => { require(["./SoundsPlugin.js"], resolve_1, reject_1); }).then(__importStar));
51
51
  e.addPlugin(new SoundsPlugin(engine));
package/296.min.js DELETED
@@ -1,2 +0,0 @@
1
- /*! For license information please see 296.min.js.LICENSE.txt */
2
- (this.webpackChunk_tsparticles_plugin_sounds=this.webpackChunk_tsparticles_plugin_sounds||[]).push([[296],{193(s,t,e){e.d(t,{m:()=>i,s:()=>n});const i="pointerdown",n="touchstart"},296(s,t,e){e.d(t,{SoundsPlugin:()=>w});var i=e(193),n=e(303);class o{constructor(){this.loop=!1,this.source=""}load(s){(0,n.isNull)(s)||((0,n.isObject)(s)?(void 0!==s.loop&&(this.loop=s.loop),void 0!==s.source&&(this.source=s.source)):this.source=s)}}class l{constructor(){this.duration=500,this.value=[]}load(s){(0,n.isNull)(s)||(void 0!==s.duration&&(this.duration=s.duration),void 0!==s.value&&(this.value=s.value))}}class c{constructor(){this.loop=!1,this.melodies=[],this.notes=[]}load(s){(0,n.isNull)(s)||(void 0!==s.loop&&(this.loop=s.loop),void 0!==s.melodies&&(this.melodies=s.melodies.map((s=>{const t=new c;return t.load(s),t}))),void 0!==s.notes&&(this.notes=s.notes.map((s=>{const t=new l;return t.load(s),t}))))}}class a{constructor(){this.event=[],this.notes=[]}load(s){if(!(0,n.isNull)(s)&&(void 0!==s.event&&(this.event=s.event),void 0!==s.audio&&((0,n.isArray)(s.audio)?this.audio=s.audio.map((s=>{const t=new o;return t.load(s),t})):(this.audio=new o,this.audio.load(s.audio))),void 0!==s.notes&&(this.notes=s.notes.map((s=>{const t=new l;return t.load(s),t}))),void 0!==s.melodies&&(this.melodies=s.melodies.map((s=>{const t=new c;return t.load(s),t}))),s.filter))if((0,n.isString)(s.filter)){const t=globalThis[s.filter];(0,n.isFunction)(t)&&(this.filter=t)}else this.filter=s.filter}}class h{constructor(){this.width=24,this.height=24,this.style=""}load(s){(0,n.isNull)(s)||(void 0!==s.path&&(this.path=s.path),void 0!==s.svg&&(this.svg=s.svg),void 0!==s.width&&(this.width=s.width),void 0!==s.height&&(this.height=s.height))}}class d{constructor(){this.mute=new h,this.unmute=new h,this.volumeDown=new h,this.volumeUp=new h,this.enable=!1,this.mute.svg='<?xml version="1.0"?>\n<svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"\n xml:space="preserve" xmlns="http://www.w3.org/2000/svg"\n xmlns:xlink="http://www.w3.org/1999/xlink">\n <g id="Layer_1">\n <path fill="#fff" d="M19.707,5.293c-0.391-0.391-1.023-0.391-1.414,0l-1.551,1.551c-0.345-0.688-0.987-1.02-1.604-1.02c-0.449,0-0.905,0.152-1.356,0.453l-2.672,1.781C10.357,8.561,8.904,9,8,9c-1.654,0-3,1.346-3,3v2c0,1.237,0.754,2.302,1.826,2.76l-1.533,1.533c-0.391,0.391-0.391,1.023,0,1.414C5.488,19.902,5.744,20,6,20s0.512-0.098,0.707-0.293l2.527-2.527c0.697,0.174,1.416,0.455,1.875,0.762l2.672,1.781c0.451,0.301,0.907,0.453,1.356,0.453C16.035,20.176,17,19.495,17,18V9.414l2.707-2.707C20.098,6.316,20.098,5.684,19.707,5.293z M14.891,7.941c0.038-0.025,0.073-0.046,0.104-0.062C14.998,7.914,15,7.954,15,8v1.293l-2,2V9.202L14.891,7.941z M7,12c0-0.552,0.448-1,1-1c1.211,0,2.907-0.495,4-1.146v2.439l-2.83,2.83C8.757,15.046,8.356,15,8,15c-0.552,0-1-0.448-1-1V12z M10.301,15.406L12,13.707v2.439C11.519,15.859,10.925,15.604,10.301,15.406z M14.994,18.12c-0.03-0.016-0.065-0.036-0.104-0.062L13,16.798v-4.091l2-2V18C15,18.046,14.998,18.086,14.994,18.12z"/>\n </g>\n</svg>',this.unmute.svg='<?xml version="1.0"?>\n<svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"\n xml:space="preserve" xmlns="http://www.w3.org/2000/svg"\n xmlns:xlink="http://www.w3.org/1999/xlink">\n <g id="Layer_1">\n <path fill="#fff" d="M17.138,5.824c-0.449,0-0.905,0.152-1.356,0.453l-2.672,1.781C12.357,8.561,10.904,9,10,9c-1.654,0-3,1.346-3,3v2c0,1.654,1.346,3,3,3c0.904,0,2.357,0.439,3.109,0.941l2.672,1.781c0.451,0.301,0.907,0.453,1.356,0.453C18.035,20.176,19,19.495,19,18V8C19,6.505,18.035,5.824,17.138,5.824z M14,16.146C12.907,15.495,11.211,15,10,15c-0.552,0-1-0.448-1-1v-2c0-0.552,0.448-1,1-1c1.211,0,2.907-0.495,4-1.146V16.146z M17,18c0,0.046-0.002,0.086-0.006,0.12c-0.03-0.016-0.065-0.036-0.104-0.062L15,16.798V9.202l1.891-1.261c0.038-0.025,0.073-0.046,0.104-0.062C16.998,7.914,17,7.954,17,8V18z"/>\n </g>\n</svg>',this.volumeDown.svg='<?xml version="1.0"?>\n<svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"\n xml:space="preserve" xmlns="http://www.w3.org/2000/svg"\n xmlns:xlink="http://www.w3.org/1999/xlink">\n <g id="Layer_1">\n <path fill="#fff" d="M15.138,5.824c-0.449,0-0.905,0.152-1.356,0.453l-2.672,1.781C10.357,8.561,8.904,9,8,9c-1.654,0-3,1.346-3,3v2c0,1.654,1.346,3,3,3c0.904,0,2.357,0.439,3.109,0.941l2.672,1.781c0.451,0.301,0.907,0.453,1.356,0.453C16.035,20.176,17,19.495,17,18V8C17,6.505,16.035,5.824,15.138,5.824z M8,15c-0.552,0-1-0.448-1-1v-2c0-0.552,0.448-1,1-1c1.211,0,2.907-0.495,4-1.146v6.293C10.907,15.495,9.211,15,8,15z M15,18c0,0.046-0.002,0.086-0.006,0.12c-0.03-0.016-0.065-0.036-0.104-0.062L13,16.798V9.202l1.891-1.261c0.038-0.025,0.073-0.046,0.104-0.062C14.998,7.914,15,7.954,15,8V18z"/>\n <path fill="#fff" d="M18.292,10.294c-0.39,0.391-0.39,1.023,0.002,1.414c0.345,0.345,0.535,0.803,0.535,1.291c0,0.489-0.19,0.948-0.536,1.294c-0.391,0.39-0.391,1.023,0,1.414C18.488,15.902,18.744,16,19,16s0.512-0.098,0.707-0.293c0.724-0.723,1.122-1.685,1.122-2.708s-0.398-1.984-1.123-2.707C19.317,9.903,18.683,9.901,18.292,10.294z"/>\n </g>\n</svg>',this.volumeUp.svg='<?xml version="1.0"?>\n<svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"\n xml:space="preserve" xmlns="http://www.w3.org/2000/svg"\n xmlns:xlink="http://www.w3.org/1999/xlink">\n <g id="Layer_1">\n <path fill="#fff" d="M16.706,10.292c-0.389-0.389-1.023-0.391-1.414,0.002c-0.39,0.391-0.39,1.023,0.002,1.414c0.345,0.345,0.535,0.803,0.535,1.291c0,0.489-0.19,0.948-0.536,1.294c-0.391,0.39-0.391,1.023,0,1.414C15.488,15.902,15.744,16,16,16s0.512-0.098,0.707-0.293c0.724-0.723,1.122-1.685,1.122-2.708S17.431,11.015,16.706,10.292z"/>\n <path fill="#fff" d="M18.706,8.292c-0.391-0.389-1.023-0.39-1.414,0.002c-0.39,0.391-0.39,1.024,0.002,1.414c0.879,0.877,1.363,2.044,1.364,3.287c0.001,1.246-0.484,2.417-1.365,3.298c-0.391,0.391-0.391,1.023,0,1.414C17.488,17.902,17.744,18,18,18s0.512-0.098,0.707-0.293c1.259-1.259,1.952-2.933,1.951-4.713C20.657,11.217,19.964,9.547,18.706,8.292z"/>\n <path fill="#fff" d="M20.706,6.292c-0.391-0.389-1.023-0.39-1.414,0.002c-0.39,0.391-0.39,1.024,0.002,1.414c1.412,1.409,2.191,3.285,2.192,5.284c0.002,2.002-0.777,3.885-2.193,5.301c-0.391,0.391-0.391,1.023,0,1.414C19.488,19.902,19.744,20,20,20s0.512-0.098,0.707-0.293c1.794-1.794,2.781-4.18,2.779-6.717C23.485,10.457,22.497,8.078,20.706,6.292z"/>\n <path fill="#fff" d="M12.138,5.824c-0.449,0-0.905,0.152-1.356,0.453L8.109,8.059C7.357,8.561,5.904,9,5,9c-1.654,0-3,1.346-3,3v2c0,1.654,1.346,3,3,3c0.904,0,2.357,0.439,3.109,0.941l2.672,1.781c0.451,0.301,0.907,0.453,1.356,0.453C13.035,20.176,14,19.495,14,18V8C14,6.505,13.035,5.824,12.138,5.824z M5,15c-0.552,0-1-0.448-1-1v-2c0-0.552,0.448-1,1-1c1.211,0,2.907-0.495,4-1.146v6.293C7.907,15.495,6.211,15,5,15z M12,18c0,0.046-0.002,0.086-0.006,0.12c-0.03-0.016-0.065-0.036-0.104-0.062L10,16.798V9.202l1.891-1.261c0.038-0.025,0.073-0.046,0.104-0.062C11.998,7.914,12,7.954,12,8V18z"/>\n </g>\n</svg>'}load(s){(0,n.isNull)(s)||(void 0!==s.enable&&(this.enable=s.enable),this.mute.load(s.mute),this.unmute.load(s.unmute),this.volumeDown.load(s.volumeDown),this.volumeUp.load(s.volumeUp))}}class v{constructor(){this.value=100,this.max=100,this.min=0,this.step=10}load(s){(0,n.isNull)(s)||((0,n.isObject)(s)?(void 0!==s.max&&(this.max=s.max),void 0!==s.min&&(this.min=s.min),void 0!==s.step&&(this.step=s.step),void 0!==s.value&&(this.value=s.value)):this.value=s)}}class u{constructor(){this.autoPlay=!0,this.enable=!1,this.events=[],this.icons=new d,this.volume=new v}load(s){(0,n.isNull)(s)||(void 0!==s.autoPlay&&(this.autoPlay=s.autoPlay),void 0!==s.enable&&(this.enable=s.enable),void 0!==s.events&&(this.events=s.events.map((s=>{const t=new a;return t.load(s),t}))),this.icons.load(s.icons),void 0!==s.volume&&this.volume.load(s.volume))}}var r=e(669);const p=()=>{removeEventListener(i.m,p),removeEventListener(i.s,p),(0,r.XK)()};class w{constructor(s){this.id="sounds",this._engine=s;const t={capture:!0,once:!0};addEventListener(i.m,p,t),addEventListener(i.s,p,t)}async getPlugin(s){const{SoundsPluginInstance:t}=await e.e(340).then(e.bind(e,340));return new t(s,this._engine)}loadOptions(s,t,e){if(!this.needsPlugin(t)&&!this.needsPlugin(e))return;let i=t.sounds;void 0===i?.load&&(t.sounds=i=new u),i.load(e?.sounds)}needsPlugin(s){return s?.sounds?.enable??!1}}},669(s,t,e){e.d(t,{E3:()=>l,XK:()=>c,jE:()=>n});const i=new Map;function n(s){const t=/(([A-G]b?)(\d))|pause/i.exec(s);if(!t?.length)return;const e=t[2]??t[0],n=i.get(e);return n?n[parseInt(t[3]??"0")]:void 0}i.set("C",[16.35,32.7,65.41,130.81,261.63,523.25,1046.5,2093,4186.01]),i.set("Db",[17.32,34.65,69.3,138.59,277.18,554.37,1108.73,2217.46,4434.92]),i.set("D",[18.35,36.71,73.42,146.83,293.66,587.33,1174.66,2349.32,4698.63]),i.set("Eb",[19.45,38.89,77.78,155.56,311.13,622.25,1244.51,2489.02,4978.03]),i.set("E",[20.6,41.2,82.41,164.81,329.63,659.25,1318.51,2637.02,5274.04]),i.set("F",[21.83,43.65,87.31,174.61,349.23,698.46,1396.91,2793.83,5587.65]),i.set("Gb",[23.12,46.25,92.5,185,369.99,739.99,1479.98,2959.96,5919.91]),i.set("G",[24.5,49,98,196,392,783.99,1567.98,3135.96,6271.93]),i.set("Ab",[25.96,51.91,103.83,207.65,415.3,830.61,1661.22,3322.44,6644.88]),i.set("A",[27.5,55,110,220,440,880,1760,3520,7040]),i.set("Bb",[29.14,58.27,116.54,233.08,466.16,932.33,1864.66,3729.31,7458.62]),i.set("B",[30.87,61.74,123.47,246.94,493.88,987.77,1975.53,3951.07,7902.13]),i.set("pause",[0]);let o=!0;const l=()=>o,c=()=>{o=!1}}}]);
@@ -1 +0,0 @@
1
- /*! tsParticles Sounds Plugin v4.0.0-alpha.8 by Matteo Bruni */
package/340.min.js DELETED
@@ -1,2 +0,0 @@
1
- /*! For license information please see 340.min.js.LICENSE.txt */
2
- (this.webpackChunk_tsparticles_plugin_sounds=this.webpackChunk_tsparticles_plugin_sounds||[]).push([[340],{340(t,e,n){n.d(e,{SoundsPluginInstance:()=>l});var i,s,o=n(303);!function(t){t.mute="soundsMuted",t.unmute="soundsUnmuted"}(i||(i={})),function(t){t.Block="block",t.None="none"}(s||(s={}));var a=n(669),u=n(193);function c(t){const e=(0,o.safeDocument)().createElement("img"),{clickCb:n,container:i,display:s,iconOptions:a,margin:u,options:c,pos:r,rightOffsets:l}=t,{width:h,path:d,style:m,svg:_}=a;!function(t,e,n,i,s,o,a,u){t.style.userSelect="none",t.style.position="absolute",t.style.top=`${(e+a).toString()}px`,t.style.left=`${(n-a-o).toString()}px`,t.style.display=i,t.style.zIndex=(s+1).toString(),t.style.cssText+=u}(e,r.top+u,r.right-(u*(l.length+1)+h+l.reduce(((t,e)=>t+e),0)),s,c.fullScreen.zIndex+1,h,u,m),e.src=d??(_?`data:image/svg+xml;base64,${btoa(_)}`:"");return(i.canvas.element?.parentNode??(0,o.safeDocument)().body).append(e),e.addEventListener("click",(()=>{n()})),e}function r(t){t&&t.remove()}class l{constructor(t,e){this._addBuffer=t=>{const e=t.createBufferSource();return this._audioSources.push(e),e},this._addOscillator=t=>{const e=t.createOscillator();return this._audioSources.push(e),e},this._initEvents=()=>{const t=this._container,e=t.actualOptions.sounds;if(e?.enable&&t.canvas.element)for(const t of e.events){const e=n=>{n&&(async()=>{const i=t.filter&&!t.filter(n);if(this._container!==n.container)return;if(this._container.muted||this._container.destroyed)return void(0,o.executeOnSingleOrMultiple)(t.event,(t=>{this._engine.removeEventListener(t,e)}));if(i)return;if(t.audio){const e=(0,o.itemFromSingleOrMultiple)(t.audio);if(!e)return;this._playBuffer(e)}else if(t.melodies){const e=(0,o.itemFromArray)(t.melodies);if(!e)return;e.melodies.length?await Promise.allSettled(e.melodies.map((t=>this._playNote(t.notes,0,e.loop)))):await this._playNote(e.notes,0,e.loop)}else if(t.notes){const e=(0,o.itemFromArray)(t.notes);if(!e)return;await this._playNote([e],0,!1)}})()};(0,o.executeOnSingleOrMultiple)(t.event,(t=>{this._engine.addEventListener(t,e)}))}},this._mute=async()=>{const t=this._container,e=this._getAudioContext();for(const t of this._audioSources)this._removeAudioSource(t);this._gain&&this._gain.disconnect(),await e.close(),t.audioContext=void 0,this._engine.dispatchEvent(i.mute,{container:this._container})},this._playBuffer=t=>{const e=this._audioMap.get(t.source);if(!e)return;const n=this._container.audioContext;if(!n)return;const i=this._addBuffer(n);i.loop=t.loop,i.buffer=e,i.connect(this._gain??n.destination),i.start()},this._playFrequency=async(t,e)=>{if(!this._gain||this._container.muted)return;const n=this._getAudioContext(),i=this._addOscillator(n);return i.connect(this._gain),i.type="sine",i.frequency.value=t,i.start(),new Promise((t=>{setTimeout((()=>{this._removeAudioSource(i),t()}),e)}))},this._playMuteSound=()=>{if(this._container.muted)return;const t=this._getAudioContext(),e=t.createGain();e.connect(t.destination),e.gain.value=0;const n=t.createOscillator();n.connect(e),n.type="sine",n.frequency.value=1,n.start(),setTimeout((()=>{n.stop(),n.disconnect(),e.disconnect()}))},this._playNote=async(t,e,n)=>{if(this._container.muted)return;const i=t[e];if(!i)return;const s=i.value,a=(0,o.executeOnSingleOrMultiple)(s,(async(n,i)=>this._playNoteValue(t,e,i)));await((0,o.isArray)(a)?Promise.allSettled(a):a);let u=e+1;n&&u>=t.length&&(u%=t.length),await this._playNote(t,u,n)},this._playNoteValue=async(t,e,n)=>{const i=t[e];if(!i)return;const s=(0,o.itemFromSingleOrMultiple)(i.value,n,!0);if(s)try{const t=(0,a.jE)(s);if(!(0,o.isNumber)(t))return;await this._playFrequency(t,i.duration)}catch(t){(0,o.getLogger)().error(t)}},this._removeAudioSource=t=>{t.stop(),t.disconnect();this._audioSources.splice(this._audioSources.indexOf(t),1)},this._unmute=()=>{const t=this._container.actualOptions.sounds;if(!t)return;const e=this._getAudioContext(),n=e.createGain();n.connect(e.destination),n.gain.value=t.volume.value/o.percentDenominator,this._gain=n,this._initEvents(),this._engine.dispatchEvent(i.unmute,{container:this._container})},this._updateMuteIcons=()=>{const t=this._container,e=t.actualOptions.sounds;if(!e?.enable||!e.icons.enable)return;const n=this._muteImg,i=this._unmuteImg;n&&(n.style.display=t.muted?"block":"none"),i&&(i.style.display=t.muted?"none":"block")},this._updateMuteStatus=async()=>{const t=this._container,e=this._getAudioContext();t.muted?(await e.suspend(),await this._mute()):(await e.resume(),this._unmute(),this._playMuteSound())},this._updateVolume=async()=>{const t=this._container,e=t.actualOptions.sounds;if(!e?.enable)return;(0,o.clamp)(this._volume,e.volume.min,e.volume.max);let n=!1;this._volume<=0&&!t.muted?(this._volume=0,t.muted=!0,n=!0):this._volume>0&&t.muted&&(t.muted=!1,n=!0),n&&(this._updateMuteIcons(),await this._updateMuteStatus()),this._gain?.gain&&(this._gain.gain.value=this._volume/o.percentDenominator)},this._container=t,this._engine=e,this._volume=0,this._audioSources=[],this._audioMap=new Map}async init(){const t=this._container.actualOptions.sounds;if(!t?.enable)return;if(t.autoPlay&&(0,a.E3)()){const t=()=>{removeEventListener(u.m,t),removeEventListener(u.s,t),(0,a.XK)(),this.unmute()},e={capture:!0,once:!0};addEventListener(u.m,t,e),addEventListener(u.s,t,e)}this._volume=t.volume.value;const e=t.events;this._audioMap=new Map;for(const t of e){if(!t.audio)continue;const e=(0,o.executeOnSingleOrMultiple)(t.audio,(async t=>{const e=await fetch(t.source);if(!e.ok)return;const n=await e.arrayBuffer(),i=this._getAudioContext(),s=await i.decodeAudioData(n);this._audioMap.set(t.source,s)}));e instanceof Promise?await e:await Promise.allSettled(e)}}async mute(){this._container.muted||await this.toggleMute()}async start(){const t=this._container,e=t.actualOptions,n=e.sounds;if(!n?.enable||!t.canvas.element)return;t.muted=!0;const i=t.canvas.element,o={top:i.offsetTop,right:i.offsetLeft+i.offsetWidth},{mute:u,unmute:r,volumeDown:l,volumeUp:h}=n.icons,d=async()=>{await this.toggleMute()},m=n.icons.enable?s.Block:s.None;this._muteImg=c({container:t,options:e,pos:o,display:m,iconOptions:u,margin:10,rightOffsets:[l.width,h.width],clickCb:d}),this._unmuteImg=c({container:t,options:e,pos:o,display:s.None,iconOptions:r,margin:10,rightOffsets:[l.width,h.width],clickCb:d}),this._volumeDownImg=c({container:t,options:e,pos:o,display:m,iconOptions:l,margin:10,rightOffsets:[h.width],clickCb:async()=>{await this.volumeDown()}}),this._volumeUpImg=c({container:t,options:e,pos:o,display:m,iconOptions:h,margin:10,rightOffsets:[],clickCb:async()=>{await this.volumeUp()}}),!(0,a.E3)()&&n.autoPlay&&await this.unmute()}stop(){this._container.muted=!0,(async()=>{await this._mute(),r(this._muteImg),r(this._unmuteImg),r(this._volumeDownImg),r(this._volumeUpImg)})()}async toggleMute(){const t=this._container;t.muted=!t.muted,this._updateMuteIcons(),await this._updateMuteStatus()}async unmute(){this._container.muted&&await this.toggleMute()}async volumeDown(){const t=this._container,e=t.actualOptions.sounds;e?.enable&&(t.muted&&(this._volume=0),this._volume-=e.volume.step,await this._updateVolume())}async volumeUp(){const t=this._container.actualOptions.sounds;t?.enable&&(this._volume+=t.volume.step,await this._updateVolume())}_getAudioContext(){const t=this._container;return t.audioContext??=new AudioContext,t.audioContext}}}}]);