@clockworkdog/cogs-client 2.11.0 → 2.11.2
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/dist/AudioPlayer.js +16 -27
- package/dist/CogsConnection.js +35 -53
- package/dist/DataStore.js +3 -8
- package/dist/VideoPlayer.js +18 -30
- package/dist/browser/index.mjs +170 -167
- package/dist/browser/index.umd.js +3 -3
- package/dist/index.js +9 -56
- package/dist/types/AllMediaClipStatesMessage.js +1 -2
- package/dist/types/AudioState.js +1 -2
- package/dist/types/CogsClientMessage.js +1 -2
- package/dist/types/CogsPluginManifest.js +1 -2
- package/dist/types/ManifestTypes.js +1 -2
- package/dist/types/MediaClipStateMessage.js +1 -2
- package/dist/types/MediaObjectFit.js +1 -2
- package/dist/types/ShowPhase.js +1 -3
- package/dist/types/VideoState.js +2 -5
- package/dist/types/utils.js +1 -2
- package/dist/utils/urls.js +4 -9
- package/package.json +4 -3
package/dist/browser/index.mjs
CHANGED
|
@@ -38,16 +38,16 @@ function ee(u) {
|
|
|
38
38
|
function te(u, n) {
|
|
39
39
|
var s = typeof Symbol == "function" && u[Symbol.iterator];
|
|
40
40
|
if (!s) return u;
|
|
41
|
-
var o = s.call(u), r, _ = [],
|
|
41
|
+
var o = s.call(u), r, _ = [], c;
|
|
42
42
|
try {
|
|
43
43
|
for (; (n === void 0 || n-- > 0) && !(r = o.next()).done; ) _.push(r.value);
|
|
44
44
|
} catch (v) {
|
|
45
|
-
|
|
45
|
+
c = { error: v };
|
|
46
46
|
} finally {
|
|
47
47
|
try {
|
|
48
48
|
r && !r.done && (s = o.return) && s.call(o);
|
|
49
49
|
} finally {
|
|
50
|
-
if (
|
|
50
|
+
if (c) throw c.error;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
return _;
|
|
@@ -118,7 +118,7 @@ var se = function() {
|
|
|
118
118
|
close: []
|
|
119
119
|
}, this._retryCount = -1, this._shouldReconnect = !0, this._connectLock = !1, this._binaryType = "blob", this._closeCalled = !1, this._messageQueue = [], this.onclose = null, this.onerror = null, this.onmessage = null, this.onopen = null, this._handleOpen = function(_) {
|
|
120
120
|
r._debug("open event");
|
|
121
|
-
var
|
|
121
|
+
var c = r._options.minUptime, v = c === void 0 ? A.minUptime : c;
|
|
122
122
|
clearTimeout(r._connectTimeout), r._uptimeTimeout = setTimeout(function() {
|
|
123
123
|
return r._acceptOpen();
|
|
124
124
|
}, v), r._ws.binaryType = r._binaryType, r._messageQueue.forEach(function(f) {
|
|
@@ -127,16 +127,16 @@ var se = function() {
|
|
|
127
127
|
return r._callEventListener(_, f);
|
|
128
128
|
});
|
|
129
129
|
}, this._handleMessage = function(_) {
|
|
130
|
-
r._debug("message event"), r.onmessage && r.onmessage(_), r._listeners.message.forEach(function(
|
|
131
|
-
return r._callEventListener(_,
|
|
130
|
+
r._debug("message event"), r.onmessage && r.onmessage(_), r._listeners.message.forEach(function(c) {
|
|
131
|
+
return r._callEventListener(_, c);
|
|
132
132
|
});
|
|
133
133
|
}, this._handleError = function(_) {
|
|
134
|
-
r._debug("error event", _.message), r._disconnect(void 0, _.message === "TIMEOUT" ? "timeout" : void 0), r.onerror && r.onerror(_), r._debug("exec error listeners"), r._listeners.error.forEach(function(
|
|
135
|
-
return r._callEventListener(_,
|
|
134
|
+
r._debug("error event", _.message), r._disconnect(void 0, _.message === "TIMEOUT" ? "timeout" : void 0), r.onerror && r.onerror(_), r._debug("exec error listeners"), r._listeners.error.forEach(function(c) {
|
|
135
|
+
return r._callEventListener(_, c);
|
|
136
136
|
}), r._connect();
|
|
137
137
|
}, this._handleClose = function(_) {
|
|
138
|
-
r._debug("close event"), r._clearTimeouts(), r._shouldReconnect && r._connect(), r.onclose && r.onclose(_), r._listeners.close.forEach(function(
|
|
139
|
-
return r._callEventListener(_,
|
|
138
|
+
r._debug("close event"), r._clearTimeouts(), r._shouldReconnect && r._connect(), r.onclose && r.onclose(_), r._listeners.close.forEach(function(c) {
|
|
139
|
+
return r._callEventListener(_, c);
|
|
140
140
|
});
|
|
141
141
|
}, this._url = n, this._protocols = s, this._options = o, this._options.startClosed && (this._shouldReconnect = !1), this._connect();
|
|
142
142
|
}
|
|
@@ -285,15 +285,15 @@ var se = function() {
|
|
|
285
285
|
var s, o, r = this._listeners[n.type];
|
|
286
286
|
if (r)
|
|
287
287
|
try {
|
|
288
|
-
for (var _ = ee(r),
|
|
289
|
-
var v =
|
|
288
|
+
for (var _ = ee(r), c = _.next(); !c.done; c = _.next()) {
|
|
289
|
+
var v = c.value;
|
|
290
290
|
this._callEventListener(n, v);
|
|
291
291
|
}
|
|
292
292
|
} catch (f) {
|
|
293
293
|
s = { error: f };
|
|
294
294
|
} finally {
|
|
295
295
|
try {
|
|
296
|
-
|
|
296
|
+
c && !c.done && (o = _.return) && o.call(_);
|
|
297
297
|
} finally {
|
|
298
298
|
if (s) throw s.error;
|
|
299
299
|
}
|
|
@@ -308,7 +308,7 @@ var se = function() {
|
|
|
308
308
|
n[s] = arguments[s];
|
|
309
309
|
this._options.debug && console.log.apply(console, ne(["RWS>"], n));
|
|
310
310
|
}, u.prototype._getNextDelay = function() {
|
|
311
|
-
var n = this._options, s = n.reconnectionDelayGrowFactor, o = s === void 0 ? A.reconnectionDelayGrowFactor : s, r = n.minReconnectionDelay, _ = r === void 0 ? A.minReconnectionDelay : r,
|
|
311
|
+
var n = this._options, s = n.reconnectionDelayGrowFactor, o = s === void 0 ? A.reconnectionDelayGrowFactor : s, r = n.minReconnectionDelay, _ = r === void 0 ? A.minReconnectionDelay : r, c = n.maxReconnectionDelay, v = c === void 0 ? A.maxReconnectionDelay : c, f = 0;
|
|
312
312
|
return this._retryCount > 0 && (f = _ * Math.pow(o, this._retryCount - 1), f > v && (f = v)), this._debug("next delay", f), f;
|
|
313
313
|
}, u.prototype._wait = function() {
|
|
314
314
|
var n = this;
|
|
@@ -330,7 +330,7 @@ var se = function() {
|
|
|
330
330
|
var n = this;
|
|
331
331
|
if (!(this._connectLock || !this._shouldReconnect)) {
|
|
332
332
|
this._connectLock = !0;
|
|
333
|
-
var s = this._options, o = s.maxRetries, r = o === void 0 ? A.maxRetries : o, _ = s.connectionTimeout,
|
|
333
|
+
var s = this._options, o = s.maxRetries, r = o === void 0 ? A.maxRetries : o, _ = s.connectionTimeout, c = _ === void 0 ? A.connectionTimeout : _, v = s.WebSocket, f = v === void 0 ? se() : v;
|
|
334
334
|
if (this._retryCount >= r) {
|
|
335
335
|
this._debug("max retries reached", this._retryCount, ">=", r);
|
|
336
336
|
return;
|
|
@@ -342,7 +342,7 @@ var se = function() {
|
|
|
342
342
|
}).then(function(y) {
|
|
343
343
|
n._closeCalled || (n._debug("connect", { url: y, protocols: n._protocols }), n._ws = n._protocols ? new f(y, n._protocols) : new f(y), n._ws.binaryType = n._binaryType, n._connectLock = !1, n._addListeners(), n._connectTimeout = setTimeout(function() {
|
|
344
344
|
return n._handleTimeout();
|
|
345
|
-
},
|
|
345
|
+
}, c));
|
|
346
346
|
});
|
|
347
347
|
}
|
|
348
348
|
}, u.prototype._handleTimeout = function() {
|
|
@@ -373,7 +373,7 @@ function ue(u) {
|
|
|
373
373
|
const n = typeof window < "u" ? window.location : void 0, s = `/assets/${encodeURIComponent(u)}`;
|
|
374
374
|
return `${n?.protocol}//${n?.hostname}:${X}${s}`;
|
|
375
375
|
}
|
|
376
|
-
async function
|
|
376
|
+
async function xe(u) {
|
|
377
377
|
const n = await fetch(u);
|
|
378
378
|
return URL.createObjectURL(new Blob([await n.arrayBuffer()]));
|
|
379
379
|
}
|
|
@@ -437,29 +437,26 @@ function pe() {
|
|
|
437
437
|
const _e = 5, fe = 1e4;
|
|
438
438
|
function he({ interval: u, send: n, onChange: s = le, syncSampleSize: o = _e, syncRequestTimeout: r = fe }) {
|
|
439
439
|
const _ = {};
|
|
440
|
-
async function
|
|
440
|
+
async function c() {
|
|
441
441
|
const C = [];
|
|
442
|
-
for (let
|
|
443
|
-
const
|
|
444
|
-
const
|
|
445
|
-
n({ timesync: { id:
|
|
446
|
-
const m = (g, w) =>
|
|
447
|
-
_[
|
|
442
|
+
for (let t = 0; t < o; t++) {
|
|
443
|
+
const i = new Promise((a) => {
|
|
444
|
+
const d = pe(), p = Date.now(), l = performance.now();
|
|
445
|
+
n({ timesync: { id: d } });
|
|
446
|
+
const m = (g, w) => a({ sentAt: l, receivedAt: g, serverNow: w, clientNow: p });
|
|
447
|
+
_[d] = { complete: m }, setTimeout(() => a(null), r);
|
|
448
448
|
});
|
|
449
|
-
C.push(
|
|
449
|
+
C.push(i), await i;
|
|
450
450
|
}
|
|
451
|
-
const
|
|
452
|
-
|
|
453
|
-
return l - c + m;
|
|
454
|
-
}), t = e.reduce((i, a) => i + a, 0) / e.length;
|
|
455
|
-
isNaN(t) || s(Date.now() + t);
|
|
451
|
+
const h = (await Promise.all(C)).filter((t) => t !== null), e = ve(h);
|
|
452
|
+
isNaN(e) || s(Date.now() + e);
|
|
456
453
|
}
|
|
457
454
|
const v = (C) => {
|
|
458
455
|
const h = performance.now(), e = _[C.timesync.id];
|
|
459
456
|
e && e.complete(h, C.timesync.now);
|
|
460
457
|
};
|
|
461
|
-
|
|
462
|
-
const f = setInterval(
|
|
458
|
+
c();
|
|
459
|
+
const f = setInterval(c, u);
|
|
463
460
|
return {
|
|
464
461
|
receive: v,
|
|
465
462
|
destroy: () => {
|
|
@@ -467,44 +464,50 @@ function he({ interval: u, send: n, onChange: s = le, syncSampleSize: o = _e, sy
|
|
|
467
464
|
}
|
|
468
465
|
};
|
|
469
466
|
}
|
|
470
|
-
|
|
467
|
+
function ve(u) {
|
|
468
|
+
return u.map(({ sentAt: n, receivedAt: s, clientNow: o, serverNow: r }) => {
|
|
469
|
+
const _ = (s - n) / 2;
|
|
470
|
+
return r - o - _;
|
|
471
|
+
}).reduce((n, s) => n + s, 0) / u.length;
|
|
472
|
+
}
|
|
473
|
+
class Oe {
|
|
471
474
|
constructor(n, { hostname: s = document.location.hostname, port: o = X } = {}, r, _) {
|
|
472
475
|
this.manifest = n, this.eventTarget = new EventTarget(), this.currentConfig = {}, this.currentState = {}, this._showPhase = J.Setup, this._timerState = null, this._mediaConfig = null, this.audioOutputs = void 0, this._selectedAudioOutput = "", this.currentState = { ...r }, this.store = new de(_ ?? {});
|
|
473
|
-
const { useReconnectingWebsocket:
|
|
476
|
+
const { useReconnectingWebsocket: c, path: v, pathParams: f } = me(document.location.href);
|
|
474
477
|
this.urlParams = new URLSearchParams(f), this.urlParams.set("screenWidth", window.screen.width.toString()), this.urlParams.set("screenHeight", window.screen.height.toString()), this.urlParams.set("screenPixelRatio", window.devicePixelRatio.toString());
|
|
475
478
|
const y = `ws://${s}:${o}${v}?${this.urlParams}`;
|
|
476
|
-
this.websocket =
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
this.websocket.addEventListener("message", ({ data: h }) => {
|
|
479
|
+
this.websocket = c ? new ae(y) : new WebSocket(y);
|
|
480
|
+
let C;
|
|
481
|
+
this.websocket.onopen = () => {
|
|
482
|
+
this.currentConfig = {}, this.currentState = {}, this.dispatchEvent(new ye()), this.setState(this.currentState), C = he({
|
|
483
|
+
interval: 6e4,
|
|
484
|
+
send: (h) => {
|
|
485
|
+
this.websocket.send(JSON.stringify(h));
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
}, this.websocket.addEventListener("message", ({ data: h }) => {
|
|
486
489
|
try {
|
|
487
490
|
const e = JSON.parse(h);
|
|
488
491
|
if (typeof e == "object" && e !== null && "timesync" in e) {
|
|
489
492
|
const t = e;
|
|
490
|
-
C
|
|
493
|
+
C?.receive(t);
|
|
491
494
|
}
|
|
492
495
|
} catch (e) {
|
|
493
496
|
console.error(e);
|
|
494
497
|
}
|
|
495
498
|
}), this.websocket.onclose = () => {
|
|
496
|
-
C
|
|
499
|
+
C?.destroy(), this.dispatchEvent(new ge());
|
|
497
500
|
}, this.websocket.addEventListener("message", ({ data: h }) => {
|
|
498
501
|
try {
|
|
499
502
|
const e = JSON.parse(h);
|
|
500
503
|
try {
|
|
501
504
|
if (e.config)
|
|
502
|
-
this.currentConfig = e.config, this.dispatchEvent(new
|
|
505
|
+
this.currentConfig = e.config, this.dispatchEvent(new Ce(this.currentConfig));
|
|
503
506
|
else if (e.updates)
|
|
504
|
-
this.currentState = { ...this.currentState, ...e.updates }, this.dispatchEvent(new
|
|
507
|
+
this.currentState = { ...this.currentState, ...e.updates }, this.dispatchEvent(new we(e.updates));
|
|
505
508
|
else if (e.event && e.event.key)
|
|
506
509
|
this.dispatchEvent(
|
|
507
|
-
new
|
|
510
|
+
new Ee(e.event.key, e.event.value)
|
|
508
511
|
);
|
|
509
512
|
else if (typeof e.message == "object") {
|
|
510
513
|
const t = e.message;
|
|
@@ -517,19 +520,19 @@ class xe {
|
|
|
517
520
|
};
|
|
518
521
|
break;
|
|
519
522
|
case "show_phase":
|
|
520
|
-
this._showPhase = t.phase, this.dispatchEvent(new
|
|
523
|
+
this._showPhase = t.phase, this.dispatchEvent(new Ae(t.phase));
|
|
521
524
|
break;
|
|
522
525
|
case "media_config_update":
|
|
523
526
|
this._mediaConfig = t;
|
|
524
527
|
for (const i of ["preferOptimizedAudio", "preferOptimizedVideo", "preferOptimizedImages"])
|
|
525
528
|
t[i] ? this.urlParams.set(i, "true") : this.urlParams.delete(i);
|
|
526
|
-
this.dispatchEvent(new
|
|
529
|
+
this.dispatchEvent(new Se(t));
|
|
527
530
|
break;
|
|
528
531
|
case "data_store_items":
|
|
529
532
|
this.store.handleDataStoreItemsMessage(t);
|
|
530
533
|
break;
|
|
531
534
|
}
|
|
532
|
-
this.dispatchEvent(new
|
|
535
|
+
this.dispatchEvent(new be(t));
|
|
533
536
|
}
|
|
534
537
|
} catch (t) {
|
|
535
538
|
console.warn("Error handling data", h, t);
|
|
@@ -629,8 +632,8 @@ class xe {
|
|
|
629
632
|
this.eventTarget.dispatchEvent(n);
|
|
630
633
|
}
|
|
631
634
|
}
|
|
632
|
-
function
|
|
633
|
-
const n = new URL(u), s = new URLSearchParams(n.searchParams), o = s.get("local_id"), r = s.get("simulator") === "true", _ = s.get("display") ?? "",
|
|
635
|
+
function me(u) {
|
|
636
|
+
const n = new URL(u), s = new URLSearchParams(n.searchParams), o = s.get("local_id"), r = s.get("simulator") === "true", _ = s.get("display") ?? "", c = n.pathname.startsWith("/plugin/") ? decodeURIComponent(n.pathname.split("/")[2]) : void 0;
|
|
634
637
|
if (o) {
|
|
635
638
|
const v = s.get("t") ?? "";
|
|
636
639
|
return s.delete("local_id"), {
|
|
@@ -651,9 +654,9 @@ function ve(u) {
|
|
|
651
654
|
path: `/display/${encodeURIComponent(_)}/${encodeURIComponent(v)}`
|
|
652
655
|
};
|
|
653
656
|
} else {
|
|
654
|
-
if (
|
|
657
|
+
if (c)
|
|
655
658
|
return {
|
|
656
|
-
path: `/plugin/${encodeURIComponent(
|
|
659
|
+
path: `/plugin/${encodeURIComponent(c)}`,
|
|
657
660
|
useReconnectingWebsocket: !0
|
|
658
661
|
};
|
|
659
662
|
{
|
|
@@ -665,48 +668,48 @@ function ve(u) {
|
|
|
665
668
|
}
|
|
666
669
|
}
|
|
667
670
|
}
|
|
668
|
-
class
|
|
671
|
+
class ye extends Event {
|
|
669
672
|
constructor() {
|
|
670
673
|
super("open"), this._cogsConnectionEventType = "open";
|
|
671
674
|
}
|
|
672
675
|
}
|
|
673
|
-
class
|
|
676
|
+
class ge extends Event {
|
|
674
677
|
constructor() {
|
|
675
678
|
super("close"), this._cogsConnectionEventType = "close";
|
|
676
679
|
}
|
|
677
680
|
}
|
|
678
|
-
class
|
|
681
|
+
class be extends Event {
|
|
679
682
|
constructor(n) {
|
|
680
683
|
super("message"), this.message = n, this._cogsConnectionEventType = "message";
|
|
681
684
|
}
|
|
682
685
|
}
|
|
683
|
-
class
|
|
686
|
+
class Ce extends Event {
|
|
684
687
|
constructor(n) {
|
|
685
688
|
super("config"), this.config = n, this._cogsConnectionEventType = "config";
|
|
686
689
|
}
|
|
687
690
|
}
|
|
688
|
-
class
|
|
691
|
+
class we extends Event {
|
|
689
692
|
constructor(n) {
|
|
690
693
|
super("state"), this.state = n, this._cogsConnectionEventType = "state";
|
|
691
694
|
}
|
|
692
695
|
}
|
|
693
|
-
class
|
|
696
|
+
class Ee extends Event {
|
|
694
697
|
constructor(n, s) {
|
|
695
698
|
super("event"), this.name = n, this.value = s, this._cogsConnectionEventType = "event";
|
|
696
699
|
}
|
|
697
700
|
}
|
|
698
|
-
class
|
|
701
|
+
class Se extends Event {
|
|
699
702
|
constructor(n) {
|
|
700
703
|
super("mediaConfig"), this.mediaConfig = n, this._cogsConnectionEventType = "mediaConfig";
|
|
701
704
|
}
|
|
702
705
|
}
|
|
703
|
-
class
|
|
706
|
+
class Ae extends Event {
|
|
704
707
|
constructor(n) {
|
|
705
708
|
super("showPhase"), this.showPhase = n, this._cogsConnectionEventType = "showPhase";
|
|
706
709
|
}
|
|
707
710
|
}
|
|
708
711
|
var j = {}, G;
|
|
709
|
-
function
|
|
712
|
+
function Te() {
|
|
710
713
|
return G || (G = 1, function(u) {
|
|
711
714
|
var n = {};
|
|
712
715
|
/*! howler.js v2.2.1 | (c) 2013-2020, James Simpson of GoldFire Studios | MIT License | howlerjs.com */
|
|
@@ -723,8 +726,8 @@ function Ae() {
|
|
|
723
726
|
if (t._volume = e, t._muted) return t;
|
|
724
727
|
t.usingWebAudio && t.masterGain.gain.setValueAtTime(e, o.ctx.currentTime);
|
|
725
728
|
for (var i = 0; i < t._howls.length; i++) if (!t._howls[i]._webAudio) for (var a = t._howls[i]._getSoundIds(), d = 0; d < a.length; d++) {
|
|
726
|
-
var
|
|
727
|
-
|
|
729
|
+
var p = t._howls[i]._soundById(a[d]);
|
|
730
|
+
p && p._node && (p._node.volume = p._volume * e);
|
|
728
731
|
}
|
|
729
732
|
return t;
|
|
730
733
|
}
|
|
@@ -733,8 +736,8 @@ function Ae() {
|
|
|
733
736
|
var t = this || o;
|
|
734
737
|
t.ctx || h(), t._muted = e, t.usingWebAudio && t.masterGain.gain.setValueAtTime(e ? 0 : t._volume, o.ctx.currentTime);
|
|
735
738
|
for (var i = 0; i < t._howls.length; i++) if (!t._howls[i]._webAudio) for (var a = t._howls[i]._getSoundIds(), d = 0; d < a.length; d++) {
|
|
736
|
-
var
|
|
737
|
-
|
|
739
|
+
var p = t._howls[i]._soundById(a[d]);
|
|
740
|
+
p && p._node && (p._node.muted = !!e || p._muted);
|
|
738
741
|
}
|
|
739
742
|
return t;
|
|
740
743
|
}, stop: function() {
|
|
@@ -782,8 +785,8 @@ function Ae() {
|
|
|
782
785
|
e.noAudio = !0;
|
|
783
786
|
break;
|
|
784
787
|
}
|
|
785
|
-
for (var d = 0; d < e._howls.length; d++) if (!e._howls[d]._webAudio) for (var
|
|
786
|
-
var m = e._howls[d]._soundById(
|
|
788
|
+
for (var d = 0; d < e._howls.length; d++) if (!e._howls[d]._webAudio) for (var p = e._howls[d]._getSoundIds(), l = 0; l < p.length; l++) {
|
|
789
|
+
var m = e._howls[d]._soundById(p[l]);
|
|
787
790
|
m && m._node && !m._node._unlocked && (m._node._unlocked = !0, m._node.load());
|
|
788
791
|
}
|
|
789
792
|
e._autoResume();
|
|
@@ -864,7 +867,7 @@ function Ae() {
|
|
|
864
867
|
else {
|
|
865
868
|
if (typeof e == "string" && i._state === "loaded" && !i._sprite[e]) return null;
|
|
866
869
|
if (e === void 0 && (e = "__default", !i._playLock)) {
|
|
867
|
-
for (var d = 0,
|
|
870
|
+
for (var d = 0, p = 0; p < i._sounds.length; p++) i._sounds[p]._paused && !i._sounds[p]._ended && (d++, a = i._sounds[p]._id);
|
|
868
871
|
d === 1 ? e = null : a = null;
|
|
869
872
|
}
|
|
870
873
|
}
|
|
@@ -946,8 +949,8 @@ function Ae() {
|
|
|
946
949
|
} }), i;
|
|
947
950
|
for (var a = i._getSoundIds(e), d = 0; d < a.length; d++) {
|
|
948
951
|
i._clearTimer(a[d]);
|
|
949
|
-
var
|
|
950
|
-
|
|
952
|
+
var p = i._soundById(a[d]);
|
|
953
|
+
p && (p._seek = p._start || 0, p._rateSeek = 0, p._paused = !0, p._ended = !0, i._stopFade(a[d]), p._node && (i._webAudio ? p._node.bufferSource && (p._node.bufferSource.stop === void 0 ? p._node.bufferSource.noteOff(0) : p._node.bufferSource.stop(0), i._cleanBuffer(p._node)) : isNaN(p._node.duration) && p._node.duration !== 1 / 0 || (p._node.currentTime = p._start || 0, p._node.pause(), p._node.duration === 1 / 0 && i._clearSound(p._node))), t || i._emit("stop", p._id));
|
|
951
954
|
}
|
|
952
955
|
return i;
|
|
953
956
|
}, mute: function(e, t) {
|
|
@@ -960,8 +963,8 @@ function Ae() {
|
|
|
960
963
|
i._muted = e;
|
|
961
964
|
}
|
|
962
965
|
for (var a = i._getSoundIds(t), d = 0; d < a.length; d++) {
|
|
963
|
-
var
|
|
964
|
-
|
|
966
|
+
var p = i._soundById(a[d]);
|
|
967
|
+
p && (p._muted = e, p._interval && i._stopFade(p._id), i._webAudio && p._node ? p._node.gain.setValueAtTime(e ? 0 : p._volume, o.ctx.currentTime) : p._node && (p._node.muted = !!o._muted || e), i._emit("mute", p._id));
|
|
965
968
|
}
|
|
966
969
|
return i;
|
|
967
970
|
}, volume: function() {
|
|
@@ -974,7 +977,7 @@ function Ae() {
|
|
|
974
977
|
i.volume.apply(i, a);
|
|
975
978
|
} }), i;
|
|
976
979
|
t === void 0 && (i._volume = e), t = i._getSoundIds(t);
|
|
977
|
-
for (var
|
|
980
|
+
for (var p = 0; p < t.length; p++) (d = i._soundById(t[p])) && (d._volume = e, a[2] || i._stopFade(t[p]), i._webAudio && d._node && !d._muted ? d._node.gain.setValueAtTime(e, o.ctx.currentTime) : d._node && !d._muted && (d._node.volume = e * o.volume()), i._emit("volume", d._id));
|
|
978
981
|
return i;
|
|
979
982
|
}, fade: function(e, t, i, a) {
|
|
980
983
|
var d = this;
|
|
@@ -982,22 +985,22 @@ function Ae() {
|
|
|
982
985
|
d.fade(e, t, i, a);
|
|
983
986
|
} }), d;
|
|
984
987
|
e = Math.min(Math.max(0, parseFloat(e)), 1), t = Math.min(Math.max(0, parseFloat(t)), 1), i = parseFloat(i), d.volume(e, a);
|
|
985
|
-
for (var
|
|
986
|
-
var m = d._soundById(
|
|
988
|
+
for (var p = d._getSoundIds(a), l = 0; l < p.length; l++) {
|
|
989
|
+
var m = d._soundById(p[l]);
|
|
987
990
|
if (m) {
|
|
988
|
-
if (a || d._stopFade(
|
|
991
|
+
if (a || d._stopFade(p[l]), d._webAudio && !m._muted) {
|
|
989
992
|
var g = o.ctx.currentTime, w = g + i / 1e3;
|
|
990
993
|
m._volume = e, m._node.gain.setValueAtTime(e, g), m._node.gain.linearRampToValueAtTime(t, w);
|
|
991
994
|
}
|
|
992
|
-
d._startFadeInterval(m, e, t, i,
|
|
995
|
+
d._startFadeInterval(m, e, t, i, p[l], a === void 0);
|
|
993
996
|
}
|
|
994
997
|
}
|
|
995
998
|
return d;
|
|
996
|
-
}, _startFadeInterval: function(e, t, i, a, d,
|
|
999
|
+
}, _startFadeInterval: function(e, t, i, a, d, p) {
|
|
997
1000
|
var l = this, m = t, g = i - t, w = Math.abs(g / 0.01), E = Math.max(4, w > 0 ? a / w : a), S = Date.now();
|
|
998
1001
|
e._fadeTo = i, e._interval = setInterval(function() {
|
|
999
1002
|
var O = (Date.now() - S) / a;
|
|
1000
|
-
S = Date.now(), m += g * O, m = Math.round(100 * m) / 100, m = g < 0 ? Math.max(i, m) : Math.min(i, m), l._webAudio ? e._volume = m : l.volume(m, e._id, !0),
|
|
1003
|
+
S = Date.now(), m += g * O, m = Math.round(100 * m) / 100, m = g < 0 ? Math.max(i, m) : Math.min(i, m), l._webAudio ? e._volume = m : l.volume(m, e._id, !0), p && (l._volume = m), (i < t && m <= i || i > t && m >= i) && (clearInterval(e._interval), e._interval = null, e._fadeTo = null, l.volume(i, e._id), l._emit("fade", e._id));
|
|
1001
1004
|
}, E);
|
|
1002
1005
|
}, _stopFade: function(e) {
|
|
1003
1006
|
var t = this, i = t._soundById(e);
|
|
@@ -1009,14 +1012,14 @@ function Ae() {
|
|
|
1009
1012
|
if (typeof d[0] != "boolean") return !!(i = a._soundById(parseInt(d[0], 10))) && i._loop;
|
|
1010
1013
|
e = d[0], a._loop = e;
|
|
1011
1014
|
} else d.length === 2 && (e = d[0], t = parseInt(d[1], 10));
|
|
1012
|
-
for (var
|
|
1015
|
+
for (var p = a._getSoundIds(t), l = 0; l < p.length; l++) (i = a._soundById(p[l])) && (i._loop = e, a._webAudio && i._node && i._node.bufferSource && (i._node.bufferSource.loop = e, e && (i._node.bufferSource.loopStart = i._start || 0, i._node.bufferSource.loopEnd = i._stop)));
|
|
1013
1016
|
return a;
|
|
1014
1017
|
}, rate: function() {
|
|
1015
1018
|
var e, t, i = this, a = arguments;
|
|
1016
1019
|
if (a.length === 0) t = i._sounds[0]._id;
|
|
1017
1020
|
else if (a.length === 1) {
|
|
1018
|
-
var d = i._getSoundIds(),
|
|
1019
|
-
|
|
1021
|
+
var d = i._getSoundIds(), p = d.indexOf(a[0]);
|
|
1022
|
+
p >= 0 ? t = parseInt(a[0], 10) : e = parseFloat(a[0]);
|
|
1020
1023
|
} else a.length === 2 && (e = parseFloat(a[0]), t = parseInt(a[1], 10));
|
|
1021
1024
|
var l;
|
|
1022
1025
|
if (typeof e != "number") return l = i._soundById(t), l ? l._rate : i._rate;
|
|
@@ -1034,8 +1037,8 @@ function Ae() {
|
|
|
1034
1037
|
var e, t, i = this, a = arguments;
|
|
1035
1038
|
if (a.length === 0) t = i._sounds[0]._id;
|
|
1036
1039
|
else if (a.length === 1) {
|
|
1037
|
-
var d = i._getSoundIds(),
|
|
1038
|
-
|
|
1040
|
+
var d = i._getSoundIds(), p = d.indexOf(a[0]);
|
|
1041
|
+
p >= 0 ? t = parseInt(a[0], 10) : i._sounds.length && (t = i._sounds[0]._id, e = parseFloat(a[0]));
|
|
1039
1042
|
} else a.length === 2 && (e = parseFloat(a[0]), t = parseInt(a[1], 10));
|
|
1040
1043
|
if (t === void 0) return i;
|
|
1041
1044
|
if (typeof e == "number" && (i._state !== "loaded" || i._playLock)) return i._queue.push({ event: "seek", action: function() {
|
|
@@ -1085,32 +1088,32 @@ function Ae() {
|
|
|
1085
1088
|
d = !1;
|
|
1086
1089
|
break;
|
|
1087
1090
|
}
|
|
1088
|
-
return
|
|
1091
|
+
return c && d && delete c[e._src], o.noAudio = !1, e._state = "unloaded", e._sounds = [], e = null, null;
|
|
1089
1092
|
}, on: function(e, t, i, a) {
|
|
1090
|
-
var d = this,
|
|
1091
|
-
return typeof t == "function" &&
|
|
1093
|
+
var d = this, p = d["_on" + e];
|
|
1094
|
+
return typeof t == "function" && p.push(a ? { id: i, fn: t, once: a } : { id: i, fn: t }), d;
|
|
1092
1095
|
}, off: function(e, t, i) {
|
|
1093
|
-
var a = this, d = a["_on" + e],
|
|
1094
|
-
if (typeof t == "number" && (i = t, t = null), t || i) for (
|
|
1095
|
-
var l = i === d[
|
|
1096
|
-
if (t === d[
|
|
1097
|
-
d.splice(
|
|
1096
|
+
var a = this, d = a["_on" + e], p = 0;
|
|
1097
|
+
if (typeof t == "number" && (i = t, t = null), t || i) for (p = 0; p < d.length; p++) {
|
|
1098
|
+
var l = i === d[p].id;
|
|
1099
|
+
if (t === d[p].fn && l || !t && l) {
|
|
1100
|
+
d.splice(p, 1);
|
|
1098
1101
|
break;
|
|
1099
1102
|
}
|
|
1100
1103
|
}
|
|
1101
1104
|
else if (e) a["_on" + e] = [];
|
|
1102
1105
|
else {
|
|
1103
1106
|
var m = Object.keys(a);
|
|
1104
|
-
for (
|
|
1107
|
+
for (p = 0; p < m.length; p++) m[p].indexOf("_on") === 0 && Array.isArray(a[m[p]]) && (a[m[p]] = []);
|
|
1105
1108
|
}
|
|
1106
1109
|
return a;
|
|
1107
1110
|
}, once: function(e, t, i) {
|
|
1108
1111
|
var a = this;
|
|
1109
1112
|
return a.on(e, t, i, 1), a;
|
|
1110
1113
|
}, _emit: function(e, t, i) {
|
|
1111
|
-
for (var a = this, d = a["_on" + e],
|
|
1114
|
+
for (var a = this, d = a["_on" + e], p = d.length - 1; p >= 0; p--) d[p].id && d[p].id !== t && e !== "load" || (setTimeout((function(l) {
|
|
1112
1115
|
l.call(this, t, i);
|
|
1113
|
-
}).bind(a, d[
|
|
1116
|
+
}).bind(a, d[p].fn), 0), d[p].once && a.off(e, d[p].fn, d[p].id));
|
|
1114
1117
|
return a._loadQueue(e), a;
|
|
1115
1118
|
}, _loadQueue: function(e) {
|
|
1116
1119
|
var t = this;
|
|
@@ -1166,7 +1169,7 @@ function Ae() {
|
|
|
1166
1169
|
return [e];
|
|
1167
1170
|
}, _refreshBuffer: function(e) {
|
|
1168
1171
|
var t = this;
|
|
1169
|
-
return e._node.bufferSource = o.ctx.createBufferSource(), e._node.bufferSource.buffer =
|
|
1172
|
+
return e._node.bufferSource = o.ctx.createBufferSource(), e._node.bufferSource.buffer = c[t._src], e._panner ? e._node.bufferSource.connect(e._panner) : e._node.bufferSource.connect(e._node), e._node.bufferSource.loop = e._loop, e._loop && (e._node.bufferSource.loopStart = e._start || 0, e._node.bufferSource.loopEnd = e._stop || 0), e._node.bufferSource.playbackRate.setValueAtTime(e._rate, o.ctx.currentTime), t;
|
|
1170
1173
|
}, _cleanBuffer: function(e) {
|
|
1171
1174
|
var t = this, i = o._navigator && o._navigator.vendor.indexOf("Apple") >= 0;
|
|
1172
1175
|
if (o._scratchBuffer && e.bufferSource && (e.bufferSource.onended = null, e.bufferSource.disconnect(0), i)) try {
|
|
@@ -1199,23 +1202,23 @@ function Ae() {
|
|
|
1199
1202
|
var e = this, t = e._parent;
|
|
1200
1203
|
t._duration === 1 / 0 && (t._duration = Math.ceil(10 * e._node.duration) / 10, t._sprite.__default[1] === 1 / 0 && (t._sprite.__default[1] = 1e3 * t._duration), t._ended(e)), e._node.removeEventListener("ended", e._endFn, !1);
|
|
1201
1204
|
} };
|
|
1202
|
-
var
|
|
1205
|
+
var c = {}, v = function(e) {
|
|
1203
1206
|
var t = e._src;
|
|
1204
|
-
if (
|
|
1207
|
+
if (c[t]) return e._duration = c[t].duration, void C(e);
|
|
1205
1208
|
if (/^data:[^;]+;base64,/.test(t)) {
|
|
1206
1209
|
for (var i = atob(t.split(",")[1]), a = new Uint8Array(i.length), d = 0; d < i.length; ++d) a[d] = i.charCodeAt(d);
|
|
1207
1210
|
y(a.buffer, e);
|
|
1208
1211
|
} else {
|
|
1209
|
-
var
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
}),
|
|
1213
|
-
var l = (
|
|
1214
|
-
if (l !== "0" && l !== "2" && l !== "3") return void e._emit("loaderror", null, "Failed loading audio file with status: " +
|
|
1215
|
-
y(
|
|
1216
|
-
},
|
|
1217
|
-
e._webAudio && (e._html5 = !0, e._webAudio = !1, e._sounds = [], delete
|
|
1218
|
-
}, f(
|
|
1212
|
+
var p = new XMLHttpRequest();
|
|
1213
|
+
p.open(e._xhr.method, t, !0), p.withCredentials = e._xhr.withCredentials, p.responseType = "arraybuffer", e._xhr.headers && Object.keys(e._xhr.headers).forEach(function(l) {
|
|
1214
|
+
p.setRequestHeader(l, e._xhr.headers[l]);
|
|
1215
|
+
}), p.onload = function() {
|
|
1216
|
+
var l = (p.status + "")[0];
|
|
1217
|
+
if (l !== "0" && l !== "2" && l !== "3") return void e._emit("loaderror", null, "Failed loading audio file with status: " + p.status + ".");
|
|
1218
|
+
y(p.response, e);
|
|
1219
|
+
}, p.onerror = function() {
|
|
1220
|
+
e._webAudio && (e._html5 = !0, e._webAudio = !1, e._sounds = [], delete c[t], e.load());
|
|
1221
|
+
}, f(p);
|
|
1219
1222
|
}
|
|
1220
1223
|
}, f = function(e) {
|
|
1221
1224
|
try {
|
|
@@ -1227,7 +1230,7 @@ function Ae() {
|
|
|
1227
1230
|
var i = function() {
|
|
1228
1231
|
t._emit("loaderror", null, "Decoding audio data failed.");
|
|
1229
1232
|
}, a = function(d) {
|
|
1230
|
-
d && t._sounds.length > 0 ? (
|
|
1233
|
+
d && t._sounds.length > 0 ? (c[t._src] = d, C(t, d)) : i();
|
|
1231
1234
|
};
|
|
1232
1235
|
typeof Promise < "u" && o.ctx.decodeAudioData.length === 1 ? o.ctx.decodeAudioData(e).then(a).catch(i) : o.ctx.decodeAudioData(e, a, i);
|
|
1233
1236
|
}, C = function(e, t) {
|
|
@@ -1252,9 +1255,9 @@ function Ae() {
|
|
|
1252
1255
|
})();
|
|
1253
1256
|
}(j)), j;
|
|
1254
1257
|
}
|
|
1255
|
-
var $ =
|
|
1256
|
-
const
|
|
1257
|
-
class
|
|
1258
|
+
var $ = Te();
|
|
1259
|
+
const ke = typeof navigator.standalone < "u";
|
|
1260
|
+
class Pe {
|
|
1258
1261
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1259
1262
|
constructor(n) {
|
|
1260
1263
|
this.cogsConnection = n, this.eventTarget = new EventTarget(), this.globalVolume = 1, this.audioClipPlayers = {}, this.sinkId = "", this.addEventListener("audioClipState", ({ detail: o }) => {
|
|
@@ -1289,9 +1292,9 @@ class Oe {
|
|
|
1289
1292
|
});
|
|
1290
1293
|
const s = () => {
|
|
1291
1294
|
const o = Object.entries(this.audioClipPlayers).map(([r, _]) => {
|
|
1292
|
-
const
|
|
1295
|
+
const c = Object.values(_.activeClips), v = c.some(
|
|
1293
1296
|
({ state: f }) => f.type === "playing" || f.type === "pausing" || f.type === "stopping" || f.type === "play_requested" || f.type === "pause_requested" || f.type === "stop_requested"
|
|
1294
|
-
) ? "playing" :
|
|
1297
|
+
) ? "playing" : c.some(({ state: f }) => f.type === "paused") ? "paused" : "stopped";
|
|
1295
1298
|
return [r, v];
|
|
1296
1299
|
});
|
|
1297
1300
|
n.sendInitialMediaClipStates({ mediaType: "audio", files: o });
|
|
@@ -1302,21 +1305,21 @@ class Oe {
|
|
|
1302
1305
|
this.globalVolume = n, $.Howler.volume(n), this.notifyStateListeners();
|
|
1303
1306
|
}
|
|
1304
1307
|
playAudioClip(n, { playId: s, volume: o, fade: r, loop: _ }) {
|
|
1305
|
-
n in this.audioClipPlayers || (this.audioClipPlayers[n] = this.createClip(n, { preload: !1, ephemeral: !0 })), this.updateAudioClipPlayer(n, (
|
|
1306
|
-
const v = Object.entries(
|
|
1308
|
+
n in this.audioClipPlayers || (this.audioClipPlayers[n] = this.createClip(n, { preload: !1, ephemeral: !0 })), this.updateAudioClipPlayer(n, (c) => {
|
|
1309
|
+
const v = Object.entries(c.activeClips).filter(([, { state: h }]) => h.type === "paused").map(([h]) => parseInt(h)), f = Object.entries(c.activeClips).filter(([, { state: h }]) => h.type === "pausing").map(([h]) => parseInt(h));
|
|
1307
1310
|
v.forEach((h) => {
|
|
1308
|
-
|
|
1311
|
+
c.player.play(h);
|
|
1309
1312
|
});
|
|
1310
|
-
const y = Object.entries(
|
|
1313
|
+
const y = Object.entries(c.activeClips).filter(([, { state: h }]) => h.type === "pause_requested").map(([h]) => parseInt(h)), C = v.length > 0 || f.length > 0 || y.length > 0 ? [] : [c.player.play()];
|
|
1311
1314
|
return f.forEach((h) => {
|
|
1312
|
-
|
|
1315
|
+
c.player.off("fade", void 0, h), c.player.loop(_, h), this.updateActiveAudioClip(n, h, (e) => ({ ...e, state: { type: "playing" } })), L(r) ? x(c.player, o, r * 1e3, h) : R(c.player, o, h);
|
|
1313
1316
|
}), [...v, ...y, ...C].forEach((h) => {
|
|
1314
|
-
|
|
1315
|
-
V(
|
|
1316
|
-
}),
|
|
1317
|
+
c.player.loop(_, h), c.player.off("play", void 0, h), c.player.off("pause", void 0, h), c.player.off("fade", void 0, h), c.player.off("end", void 0, h), c.player.off("stop", void 0, h), c.player.once("play", () => {
|
|
1318
|
+
V(c.player, this.sinkId);
|
|
1319
|
+
}), c.player.once("stop", () => this.handleStoppedClip(n, s, h), h), c.player.on(
|
|
1317
1320
|
"end",
|
|
1318
1321
|
() => {
|
|
1319
|
-
|
|
1322
|
+
c.activeClips[h]?.loop || this.handleStoppedClip(n, s, h);
|
|
1320
1323
|
},
|
|
1321
1324
|
h
|
|
1322
1325
|
);
|
|
@@ -1326,48 +1329,48 @@ class Oe {
|
|
|
1326
1329
|
loop: _,
|
|
1327
1330
|
volume: o
|
|
1328
1331
|
};
|
|
1329
|
-
|
|
1332
|
+
c.player.once(
|
|
1330
1333
|
"play",
|
|
1331
1334
|
() => {
|
|
1332
|
-
const t =
|
|
1335
|
+
const t = c.activeClips[h]?.state;
|
|
1333
1336
|
t?.type === "pause_requested" ? this.pauseAudioClip(n, { fade: t.fade }, h, !0) : t?.type === "stop_requested" ? this.stopAudioClip(n, { fade: t.fade }, h, !0) : this.updateActiveAudioClip(n, h, (i) => ({ ...i, state: { type: "playing" } }));
|
|
1334
1337
|
},
|
|
1335
1338
|
h
|
|
1336
|
-
), L(r) ? (
|
|
1339
|
+
), L(r) ? (c.player.volume(0, h), c.player.mute(!1, h), c.player.once(
|
|
1337
1340
|
"play",
|
|
1338
1341
|
() => {
|
|
1339
|
-
x(
|
|
1342
|
+
x(c.player, o, r * 1e3, h);
|
|
1340
1343
|
},
|
|
1341
1344
|
h
|
|
1342
|
-
)) : R(
|
|
1343
|
-
}),
|
|
1345
|
+
)) : R(c.player, o, h), c.activeClips = { ...c.activeClips, [h]: e };
|
|
1346
|
+
}), c;
|
|
1344
1347
|
}), this.notifyClipStateListeners(s, n, "playing");
|
|
1345
1348
|
}
|
|
1346
1349
|
pauseAudioClip(n, { fade: s }, o, r) {
|
|
1347
1350
|
Object.keys(this.audioClipPlayers[n]?.activeClips ?? {}).length !== 0 && this.updateAudioClipPlayer(n, (_) => (_.activeClips = Object.fromEntries(
|
|
1348
|
-
Object.entries(_.activeClips).map(([
|
|
1349
|
-
const f = parseInt(
|
|
1351
|
+
Object.entries(_.activeClips).map(([c, v]) => {
|
|
1352
|
+
const f = parseInt(c);
|
|
1350
1353
|
return (o === void 0 || o === f) && (r && v.state.type === "pause_requested" || v.state.type === "playing" || v.state.type === "pausing" ? L(s) ? (_.player.once(
|
|
1351
1354
|
"fade",
|
|
1352
1355
|
(y) => {
|
|
1353
1356
|
_.player.pause(y), this.updateActiveAudioClip(n, y, (C) => ({ ...C, state: { type: "paused" } })), this.notifyClipStateListeners(v.playId, n, "paused");
|
|
1354
1357
|
},
|
|
1355
1358
|
f
|
|
1356
|
-
), x(_.player, 0, s * 1e3, f), v.state = { type: "pausing" }) : (_.player.pause(f), v.state = { type: "paused" }, this.notifyClipStateListeners(v.playId, n, "paused")) : (v.state.type === "play_requested" || v.state.type === "pause_requested") && (v.state = { type: "pause_requested", fade: s })), [
|
|
1359
|
+
), x(_.player, 0, s * 1e3, f), v.state = { type: "pausing" }) : (_.player.pause(f), v.state = { type: "paused" }, this.notifyClipStateListeners(v.playId, n, "paused")) : (v.state.type === "play_requested" || v.state.type === "pause_requested") && (v.state = { type: "pause_requested", fade: s })), [c, v];
|
|
1357
1360
|
})
|
|
1358
1361
|
), _));
|
|
1359
1362
|
}
|
|
1360
1363
|
stopAudioClip(n, { fade: s }, o, r) {
|
|
1361
|
-
|
|
1362
|
-
Object.entries(_.activeClips).map(([
|
|
1363
|
-
const f = parseInt(
|
|
1364
|
+
Le("Stop audio clip", { activeClips: this.audioClipPlayers[n]?.activeClips }), Object.keys(this.audioClipPlayers[n]?.activeClips ?? {}).length !== 0 && this.updateAudioClipPlayer(n, (_) => (_.activeClips = Object.fromEntries(
|
|
1365
|
+
Object.entries(_.activeClips).map(([c, v]) => {
|
|
1366
|
+
const f = parseInt(c);
|
|
1364
1367
|
return (o === void 0 || o === f) && (r && v.state.type === "stop_requested" || v.state.type === "playing" || v.state.type === "pausing" || v.state.type === "paused" || v.state.type === "stopping" ? L(s) && v.state.type !== "paused" ? (_.player.off("fade", f), x(_.player, 0, s * 1e3, f), _.player.once(
|
|
1365
1368
|
"fade",
|
|
1366
1369
|
(y) => {
|
|
1367
1370
|
_.player.loop(!1, y), _.player.stop(y);
|
|
1368
1371
|
},
|
|
1369
1372
|
f
|
|
1370
|
-
), v.state = { type: "stopping" }) : (_.player.loop(!1, f), _.player.stop(f)) : (v.state.type === "play_requested" || v.state.type === "pause_requested" || v.state.type === "stop_requested") && (v.state = { type: "stop_requested", fade: s })), [
|
|
1373
|
+
), v.state = { type: "stopping" }) : (_.player.loop(!1, f), _.player.stop(f)) : (v.state.type === "play_requested" || v.state.type === "pause_requested" || v.state.type === "stop_requested") && (v.state = { type: "stop_requested", fade: s })), [c, v];
|
|
1371
1374
|
})
|
|
1372
1375
|
), _));
|
|
1373
1376
|
}
|
|
@@ -1382,12 +1385,12 @@ class Oe {
|
|
|
1382
1385
|
return;
|
|
1383
1386
|
}
|
|
1384
1387
|
Object.keys(this.audioClipPlayers[n]?.activeClips ?? {}).length !== 0 && this.updateAudioClipPlayer(n, (r) => (r.activeClips = Object.fromEntries(
|
|
1385
|
-
Object.entries(r.activeClips).map(([_,
|
|
1386
|
-
if (
|
|
1388
|
+
Object.entries(r.activeClips).map(([_, c]) => {
|
|
1389
|
+
if (c.state.type !== "pausing" && c.state.type !== "stopping") {
|
|
1387
1390
|
const v = parseInt(_);
|
|
1388
|
-
return L(o) ? x(r.player, s, o * 1e3, v) : R(r.player, s, v), [_, { ...
|
|
1391
|
+
return L(o) ? x(r.player, s, o * 1e3, v) : R(r.player, s, v), [_, { ...c, volume: s }];
|
|
1389
1392
|
} else
|
|
1390
|
-
return [_,
|
|
1393
|
+
return [_, c];
|
|
1391
1394
|
})
|
|
1392
1395
|
), r));
|
|
1393
1396
|
}
|
|
@@ -1432,9 +1435,9 @@ class Oe {
|
|
|
1432
1435
|
}
|
|
1433
1436
|
notifyStateListeners() {
|
|
1434
1437
|
const n = Object.entries(this.audioClipPlayers).reduce(
|
|
1435
|
-
(r, [_,
|
|
1436
|
-
config: { preload:
|
|
1437
|
-
activeClips:
|
|
1438
|
+
(r, [_, c]) => (r[_] = {
|
|
1439
|
+
config: { preload: c.config.preload, ephemeral: c.config.ephemeral },
|
|
1440
|
+
activeClips: c.activeClips
|
|
1438
1441
|
}, r),
|
|
1439
1442
|
{}
|
|
1440
1443
|
), s = Object.values(this.audioClipPlayers).some(
|
|
@@ -1482,10 +1485,10 @@ class Oe {
|
|
|
1482
1485
|
return s.config.preload !== o.preload && (r.player.unload(), r.player = this.createPlayer(n, o)), r;
|
|
1483
1486
|
}
|
|
1484
1487
|
}
|
|
1485
|
-
function
|
|
1488
|
+
function Le(...u) {
|
|
1486
1489
|
}
|
|
1487
1490
|
function L(u) {
|
|
1488
|
-
return !
|
|
1491
|
+
return !ke && typeof u == "number" && !isNaN(u) && u > 0;
|
|
1489
1492
|
}
|
|
1490
1493
|
function V(u, n) {
|
|
1491
1494
|
n !== void 0 && (u._html5 ? u._sounds?.forEach((s) => {
|
|
@@ -1500,7 +1503,7 @@ function x(u, n, s, o) {
|
|
|
1500
1503
|
}
|
|
1501
1504
|
var D = /* @__PURE__ */ ((u) => (u.Paused = "paused", u.Playing = "playing", u))(D || {});
|
|
1502
1505
|
const W = document.body;
|
|
1503
|
-
class
|
|
1506
|
+
class Ie {
|
|
1504
1507
|
constructor(n, s = W) {
|
|
1505
1508
|
this.cogsConnection = n, this.eventTarget = new EventTarget(), this.globalVolume = 1, this.videoClipPlayers = {}, this.sinkId = "", this.parentElement = s, this.addEventListener("videoClipState", ({ detail: r }) => {
|
|
1506
1509
|
n.sendMediaClipState(r);
|
|
@@ -1536,8 +1539,8 @@ class Pe {
|
|
|
1536
1539
|
}
|
|
1537
1540
|
});
|
|
1538
1541
|
const o = () => {
|
|
1539
|
-
const r = Object.entries(this.videoClipPlayers).map(([_,
|
|
1540
|
-
const v =
|
|
1542
|
+
const r = Object.entries(this.videoClipPlayers).map(([_, c]) => {
|
|
1543
|
+
const v = c.videoElement.paused ? c.videoElement.currentTime === 0 || c.videoElement.currentTime === c.videoElement.duration ? "paused" : "stopped" : "playing";
|
|
1541
1544
|
return [_, v];
|
|
1542
1545
|
});
|
|
1543
1546
|
n.sendInitialMediaClipStates({ mediaType: "video", files: r });
|
|
@@ -1558,7 +1561,7 @@ class Pe {
|
|
|
1558
1561
|
}), this.globalVolume = n, this.notifyStateListeners();
|
|
1559
1562
|
}
|
|
1560
1563
|
playVideoClip(n, { playId: s, volume: o, loop: r, fit: _ }) {
|
|
1561
|
-
this.videoClipPlayers[n] || (this.videoClipPlayers[n] = this.createClipPlayer(n, { preload: "none", ephemeral: !0, fit: _ })), this.pendingClip && this.updateVideoClipPlayer(this.pendingClip.path, (
|
|
1564
|
+
this.videoClipPlayers[n] || (this.videoClipPlayers[n] = this.createClipPlayer(n, { preload: "none", ephemeral: !0, fit: _ })), this.pendingClip && this.updateVideoClipPlayer(this.pendingClip.path, (c) => (c.videoElement.load(), c)), this.activeClip?.path !== n && (this.pendingClip = { path: n, playId: s, actionOncePlaying: "play" }), this.updateVideoClipPlayer(n, (c) => (c.volume = o, P(c.videoElement, o * this.globalVolume), c.videoElement.loop = r, c.videoElement.style.objectFit = _, c.videoElement.currentTime === c.videoElement.duration && (c.videoElement.currentTime = 0), c.videoElement.play(), this.activeClip || (c.videoElement.style.display = "block"), c));
|
|
1562
1565
|
}
|
|
1563
1566
|
pauseVideoClip() {
|
|
1564
1567
|
if (this.pendingClip && (this.pendingClip.actionOncePlaying = "pause"), this.activeClip) {
|
|
@@ -1693,24 +1696,24 @@ function Q(u, n) {
|
|
|
1693
1696
|
function P(u, n) {
|
|
1694
1697
|
u.volume = n, u.muted = n === 0;
|
|
1695
1698
|
}
|
|
1696
|
-
const
|
|
1699
|
+
const je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1697
1700
|
__proto__: null
|
|
1698
1701
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1699
1702
|
export {
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1703
|
+
Pe as CogsAudioPlayer,
|
|
1704
|
+
Ce as CogsConfigChangedEvent,
|
|
1705
|
+
Oe as CogsConnection,
|
|
1706
|
+
ge as CogsConnectionCloseEvent,
|
|
1707
|
+
ye as CogsConnectionOpenEvent,
|
|
1708
|
+
Ee as CogsIncomingEvent,
|
|
1709
|
+
Se as CogsMediaConfigChangedEvent,
|
|
1710
|
+
be as CogsMessageEvent,
|
|
1711
|
+
Ae as CogsShowPhaseChangedEvent,
|
|
1712
|
+
we as CogsStateChangedEvent,
|
|
1713
|
+
Ie as CogsVideoPlayer,
|
|
1711
1714
|
F as DataStoreItemEvent,
|
|
1712
1715
|
q as DataStoreItemsEvent,
|
|
1713
|
-
|
|
1716
|
+
je as ManifestTypes,
|
|
1714
1717
|
ue as assetUrl,
|
|
1715
|
-
|
|
1718
|
+
xe as preloadUrl
|
|
1716
1719
|
};
|