@mebius-io/web 0.5.2 → 0.5.3
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/index.cjs +11 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js +11 -5
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.global.js
CHANGED
|
@@ -43416,6 +43416,7 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))} pos: ${this.timeli
|
|
|
43416
43416
|
// src/captions.ts
|
|
43417
43417
|
var TICK_MS = 100;
|
|
43418
43418
|
var STALE_MS = 5e3;
|
|
43419
|
+
var MAX_QUEUE_MS = 4e3;
|
|
43419
43420
|
var MebiusCaptions = class extends TypedEmitter {
|
|
43420
43421
|
/** @internal */
|
|
43421
43422
|
constructor(signaling, player, opts) {
|
|
@@ -43457,22 +43458,27 @@ Schedule: ${scheduleItems.map((seg) => segmentToString(seg))} pos: ${this.timeli
|
|
|
43457
43458
|
if (frame.type !== "caption" || !frame.segmentId) return;
|
|
43458
43459
|
const prev = this.pending.get(frame.segmentId);
|
|
43459
43460
|
if (prev && (frame.rev ?? 0) < (prev.rev ?? 0)) return;
|
|
43461
|
+
frame.receivedAtMs = Date.now();
|
|
43460
43462
|
this.pending.set(frame.segmentId, frame);
|
|
43461
43463
|
}
|
|
43462
43464
|
tick() {
|
|
43463
43465
|
const now2 = this.player.currentEpochMs();
|
|
43464
|
-
if (now2 == null) return;
|
|
43465
43466
|
for (const [id, frame] of this.pending) {
|
|
43466
43467
|
const due = frame.epochMs ?? 0;
|
|
43467
|
-
|
|
43468
|
-
|
|
43468
|
+
const waitedMs = Date.now() - (frame.receivedAtMs ?? 0);
|
|
43469
|
+
const dueNow = now2 == null ? true : due <= now2;
|
|
43470
|
+
if (!dueNow) {
|
|
43471
|
+
if (waitedMs < MAX_QUEUE_MS) continue;
|
|
43472
|
+
}
|
|
43473
|
+
if (waitedMs > STALE_MS && this.shown.has(id)) {
|
|
43469
43474
|
this.pending.delete(id);
|
|
43470
|
-
|
|
43475
|
+
this.shown.delete(id);
|
|
43476
|
+
this.emit("cleared", { segmentId: id });
|
|
43471
43477
|
continue;
|
|
43472
43478
|
}
|
|
43479
|
+
if (this.shown.has(id) && frame.state === "final") continue;
|
|
43473
43480
|
this.shown.add(id);
|
|
43474
43481
|
this.emit("segment", toSegment(id, frame, this.opts.lang));
|
|
43475
|
-
if (frame.state === "final") this.pending.delete(id);
|
|
43476
43482
|
}
|
|
43477
43483
|
}
|
|
43478
43484
|
};
|