@ejfdelgado/ejflab-common 1.9.0 → 1.10.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.
package/package.json
CHANGED
package/src/ModuloSonido.js
CHANGED
|
@@ -9,6 +9,7 @@ await ModuloSonido.play('/assets/sounds/finish.mp3');
|
|
|
9
9
|
|
|
10
10
|
class ModuloSonido {
|
|
11
11
|
static sonidos = {};
|
|
12
|
+
static sincId = null;
|
|
12
13
|
static createAudio({ source, volume = 100, loop = false }) {
|
|
13
14
|
return new Promise((resolve, reject) => {
|
|
14
15
|
const audio = new Audio();
|
|
@@ -42,6 +43,9 @@ class ModuloSonido {
|
|
|
42
43
|
return await Promise.all(promesas);
|
|
43
44
|
};
|
|
44
45
|
|
|
46
|
+
static setSincId(id) {
|
|
47
|
+
ModuloSonido.sincId = id;
|
|
48
|
+
}
|
|
45
49
|
|
|
46
50
|
static async play(llave, loop = false, volume = 1) {
|
|
47
51
|
let ref = null;
|
|
@@ -55,6 +59,9 @@ class ModuloSonido {
|
|
|
55
59
|
&& ref.readyState > 2;
|
|
56
60
|
if (!isPlaying) {
|
|
57
61
|
ref.loop = loop;
|
|
62
|
+
if (ModuloSonido.sincId) {
|
|
63
|
+
ref.setSinkId(ModuloSonido.sincId);
|
|
64
|
+
}
|
|
58
65
|
ref.play();
|
|
59
66
|
}
|
|
60
67
|
};
|
package/src/MyThrottle.js
CHANGED
|
@@ -18,8 +18,18 @@ class CommandTimelineNext extends CommandBasic {
|
|
|
18
18
|
}
|
|
19
19
|
// Compute advance percentage
|
|
20
20
|
const percentage = (timeline.t - timeline.start) / (timeline.end - timeline.start);
|
|
21
|
-
SimpleObj.recreate(this.context.data,
|
|
22
|
-
|
|
21
|
+
SimpleObj.recreate(this.context.data, `scope.progress.${timeLineId}`, Math.ceil(percentage * 100));
|
|
22
|
+
// Compute the overall advance
|
|
23
|
+
const allProgress = SimpleObj.getValue(this.context.data, `scope.progress`, {});
|
|
24
|
+
const keysProgress = Object.keys(allProgress);
|
|
25
|
+
let sum = 0;
|
|
26
|
+
for (let i = 0; i < keysProgress.length; i++) {
|
|
27
|
+
const oneKey = keysProgress[i];
|
|
28
|
+
const progress = allProgress[oneKey];
|
|
29
|
+
sum += progress;
|
|
30
|
+
}
|
|
31
|
+
const average = sum / keysProgress.length;
|
|
32
|
+
SimpleObj.recreate(this.context.data, `scope.progressAvg`, Math.ceil(average));
|
|
23
33
|
}
|
|
24
34
|
}
|
|
25
35
|
|