@sentinel-nvr/web 0.7.0 → 0.9.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.
@@ -267,6 +267,9 @@ var WebRtcSession = class {
267
267
  // src/player/controller.ts
268
268
  var MSCls = window.ManagedMediaSource || window.MediaSource;
269
269
  var SWAP_MS = 2600;
270
+ var MARK_CAP_MS = 12e3;
271
+ var LIFT_FRAMES = 2;
272
+ var LIFT_FADE_MS = 120;
270
273
  var SCRUB_OFF_DELAY_MS = 1500;
271
274
  var TARGET_FLOOR_MS = 120;
272
275
  var TARGET_MIN_STEP_MS = 250;
@@ -319,6 +322,13 @@ var PlayerController = class {
319
322
  swapT = 0;
320
323
  posterFor = 0;
321
324
  scrubOffT = 0;
325
+ // marked seek: width the new position arrives with (0 = timer path), send time (telemetry); presented width / frames at session start
326
+ swapW = 0;
327
+ swapAt = 0;
328
+ shownW = 0;
329
+ sessFrames0 = 0;
330
+ liftTok = null;
331
+ // a pending lift (frames → fade → hide); any new still cancels it
322
332
  scrubMoves = 0;
323
333
  rwTargetBusy = false;
324
334
  rwPendingTarget = null;
@@ -398,7 +408,7 @@ var PlayerController = class {
398
408
  if (!this.live && !this.rw?.active) this.setLabel("loading");
399
409
  });
400
410
  for (const n of ["loadeddata", "playing", "canplay", "seeked"]) on(n, () => {
401
- if (v.videoWidth) this.freezeHide();
411
+ if (v.videoWidth && !v.srcObject && !this.posterUntilSeek) this.freezeLift();
402
412
  if (!this.live && this.label === "loading") this.setLabel("playing");
403
413
  if (this.L.stallT) {
404
414
  clearTimeout(this.L.stallT);
@@ -415,7 +425,10 @@ var PlayerController = class {
415
425
  });
416
426
  on("play", () => this.emit());
417
427
  on("loadedmetadata", () => this.setAspect(this.v.videoWidth, this.v.videoHeight));
418
- on("resize", () => this.setAspect(this.v.videoWidth, this.v.videoHeight));
428
+ on("resize", () => {
429
+ this.setAspect(this.v.videoWidth, this.v.videoHeight);
430
+ if (this.v.videoWidth && !this.v.requestVideoFrameCallback) this.markerCheck(this.v.videoWidth);
431
+ });
419
432
  on("volumechange", () => this.emit());
420
433
  on("error", () => {
421
434
  const e = v.error;
@@ -536,7 +549,14 @@ var PlayerController = class {
536
549
  /** Wall-clock position of the picture on screen (Scrypted's getRecordingStreamCurrentTime). */
537
550
  currentTs() {
538
551
  if (this.rw?.active) {
539
- if (this.rwPosTs != null) return this.rwPosTs + (Date.now() - this.rwPosAt) * (this.rwRate || 1);
552
+ if (this.rwPosTs != null) {
553
+ const v = this.rwPosTs + (Date.now() - this.rwPosAt) * (this.rwRate || 1);
554
+ if ((this.rwScrub || this.scrubMoves > 0) && this.rwLastTarget) {
555
+ const lo = Math.min(this.rwPosTs, this.rwLastTarget), hi = Math.max(this.rwPosTs, this.rwLastTarget);
556
+ return Math.min(hi, Math.max(lo, v));
557
+ }
558
+ return v;
559
+ }
540
560
  if (this.rwBase != null && this.v.currentTime > 0) return this.rwStartMs + (this.v.currentTime - this.rwBase) * 1e3 * (this.rwRate || 1);
541
561
  return this.rwStartMs;
542
562
  }
@@ -553,9 +573,14 @@ var PlayerController = class {
553
573
  if (!v.requestVideoFrameCallback) return;
554
574
  const tok = {};
555
575
  this.fc.tok = tok;
556
- const tick = () => {
576
+ const tick = (_now, md) => {
557
577
  if (this.fc.tok !== tok) return;
558
578
  this.fc.n++;
579
+ const w = md && md.width || this.v.videoWidth;
580
+ if (w) {
581
+ this.shownW = w;
582
+ this.markerCheck(w);
583
+ }
559
584
  try {
560
585
  v.requestVideoFrameCallback(tick);
561
586
  } catch {
@@ -566,6 +591,10 @@ var PlayerController = class {
566
591
  } catch {
567
592
  }
568
593
  }
594
+ /** a presented frame of width w: is it the first frame of the marked seek's new position? */
595
+ markerCheck(w) {
596
+ if (this.swapPending && this.swapW && w === this.swapW) this.swapVisible("marker");
597
+ }
569
598
  presentedFrames() {
570
599
  if (this.v.requestVideoFrameCallback) return this.fc.n;
571
600
  try {
@@ -576,19 +605,59 @@ var PlayerController = class {
576
605
  }
577
606
  freezeArm(hold) {
578
607
  if (this.freezeT) clearTimeout(this.freezeT);
579
- this.freezeT = window.setTimeout(() => this.freezeHide(), hold ? 9e4 : 5e3);
608
+ this.freezeT = window.setTimeout(() => this.freezeHide(), 9e4);
580
609
  const v = this.v;
581
610
  if (hold && v.requestVideoFrameCallback) {
582
611
  const tok = {};
583
612
  this.freezeTok = tok;
584
613
  try {
585
614
  v.requestVideoFrameCallback(() => {
586
- if (this.freezeTok === tok && this.v.videoWidth) this.freezeHide();
615
+ if (this.freezeTok === tok && this.v.videoWidth) this.freezeLift();
587
616
  });
588
617
  } catch {
589
618
  }
590
619
  }
591
620
  }
621
+ /** a still is shown (again): cancel a pending lift, full opacity */
622
+ stillUp() {
623
+ this.liftTok = null;
624
+ this.fz.classList.remove("nvr-stage__freeze--fade");
625
+ this.fz.classList.remove("hidden");
626
+ }
627
+ /** New content is being presented → lift the still after LIFT_FRAMES more presented frames with a short fade (see
628
+ * LIFT_FRAMES). `frames` 0 = fade right away (MJPEG image loaded). A lift already under way is not restarted. */
629
+ freezeLift(frames = LIFT_FRAMES) {
630
+ if (!this.posterUp() || this.liftTok) return;
631
+ const tok = {};
632
+ this.liftTok = tok;
633
+ const v = this.v;
634
+ const fade = () => {
635
+ if (this.liftTok !== tok) return;
636
+ this.fz.classList.add("nvr-stage__freeze--fade");
637
+ window.setTimeout(() => {
638
+ if (this.liftTok === tok) this.freezeHide();
639
+ }, LIFT_FADE_MS);
640
+ };
641
+ if (frames > 0 && v.requestVideoFrameCallback) {
642
+ let n = 0;
643
+ const tick = () => {
644
+ if (this.liftTok !== tok) return;
645
+ if (++n >= frames) fade();
646
+ else {
647
+ try {
648
+ v.requestVideoFrameCallback(tick);
649
+ } catch {
650
+ fade();
651
+ }
652
+ }
653
+ };
654
+ try {
655
+ v.requestVideoFrameCallback(tick);
656
+ } catch {
657
+ fade();
658
+ }
659
+ } else window.setTimeout(fade, frames > 0 ? 100 : 0);
660
+ }
592
661
  /** copy the current video picture onto the freeze canvas (false = nothing to copy yet) */
593
662
  drawVideo() {
594
663
  const v = this.v, fc = this.fz;
@@ -596,40 +665,58 @@ var PlayerController = class {
596
665
  if (fc.width !== v.videoWidth) fc.width = v.videoWidth;
597
666
  if (fc.height !== v.videoHeight) fc.height = v.videoHeight;
598
667
  fc.getContext("2d").drawImage(v, 0, 0, fc.width, fc.height);
599
- fc.classList.remove("hidden");
668
+ this.stillUp();
600
669
  fc.dataset.src = "video";
601
670
  return true;
602
671
  }
672
+ /** Freeze the current picture. A still that is already visible stays (redrawing would copy from an element whose stream
673
+ * may already be gone → black) — it is only re-armed. */
603
674
  freezeShow(hold = false) {
604
675
  try {
676
+ if (this.posterUp()) {
677
+ if (!this.posterUntilSeek) this.freezeArm(hold);
678
+ return;
679
+ }
605
680
  if (this.drawVideo()) this.freezeArm(hold);
606
681
  } catch {
607
682
  }
608
683
  }
609
- /** poster/freeze stays until the seek's picture is visible (swapVisible), 6 s safety net */
684
+ /** poster/freeze stays until the seek's picture is visible (swapVisible); safety net MARK_CAP_MS */
610
685
  holdUntilSwap() {
611
686
  if (this.freezeT) clearTimeout(this.freezeT);
612
687
  this.freezeTok = null;
688
+ if (this.posterUp()) this.stillUp();
613
689
  this.posterUntilSeek = true;
614
- this.freezeT = window.setTimeout(() => this.swapVisible(), 6e3);
690
+ this.freezeT = window.setTimeout(() => this.swapVisible("cap"), MARK_CAP_MS);
615
691
  }
616
- /** Event click inside a running relay session: the current picture stands still at once (the old position must not keep
617
- * playing while the event frame loads); the event frame replaces it, the picture at the target lifts it. */
692
+ /** A jump inside a running relay session: the current picture stands still at once (the old position must not keep playing
693
+ * while the new one crosses the pipeline); an already visible still (event frame) is kept. Lifted by swapVisible. */
618
694
  freezeCurrent() {
619
695
  if (!this.rw?.active || !this.rw.id) return;
620
696
  try {
621
- if (this.drawVideo()) this.holdUntilSwap();
697
+ if (this.posterUp() || this.drawVideo()) this.holdUntilSwap();
622
698
  } catch {
623
699
  }
624
700
  }
625
701
  /** the picture of the last seek is on screen: lift a held poster, report playing */
626
- swapVisible() {
702
+ swapVisible(how = "timer") {
627
703
  if (this.swapT) {
628
704
  clearTimeout(this.swapT);
629
705
  this.swapT = 0;
630
706
  }
707
+ const was = this.swapPending;
631
708
  this.swapPending = false;
632
- if (this.posterUntilSeek) this.freezeHide();
709
+ this.swapW = 0;
710
+ if (was && this.swapAt) rlog("swap", { how, ms: Date.now() - this.swapAt, w: this.shownW });
711
+ this.swapAt = 0;
712
+ if (this.posterUntilSeek) {
713
+ this.posterUntilSeek = false;
714
+ if (this.freezeT) {
715
+ clearTimeout(this.freezeT);
716
+ this.freezeT = 0;
717
+ }
718
+ this.freezeLift();
719
+ }
633
720
  if (this.label === "loading" && this.rw?.active) this.setLabel("playing");
634
721
  }
635
722
  /** seek answered: the new picture is on screen SWAP_MS later (plus proof of a presented frame) */
@@ -651,7 +738,7 @@ var PlayerController = class {
651
738
  fc.width = img.naturalWidth;
652
739
  fc.height = img.naturalHeight;
653
740
  fc.getContext("2d").drawImage(img, 0, 0);
654
- fc.classList.remove("hidden");
741
+ this.stillUp();
655
742
  fc.dataset.src = kind;
656
743
  this.setAspect(img.naturalWidth, img.naturalHeight);
657
744
  if (untilSeek) this.holdUntilSwap();
@@ -666,17 +753,20 @@ var PlayerController = class {
666
753
  clearTimeout(this.freezeT);
667
754
  this.freezeT = 0;
668
755
  }
756
+ this.liftTok = null;
669
757
  this.posterUntilSeek = false;
670
758
  this.fz.classList.add("hidden");
759
+ this.fz.classList.remove("nvr-stage__freeze--fade");
671
760
  delete this.fz.dataset.src;
672
761
  }
673
762
  posterUp() {
674
763
  return !this.fz.classList.contains("hidden");
675
764
  }
765
+ /** scrub on MSE: the still stays while the gesture runs (lifted by the seek's `seeked`/`playing`) */
676
766
  freezeHold() {
677
767
  if (this.freezeT) {
678
768
  clearTimeout(this.freezeT);
679
- this.freezeT = window.setTimeout(() => this.freezeHide(), 5e3);
769
+ this.freezeT = window.setTimeout(() => this.freezeHide(), 9e4);
680
770
  }
681
771
  }
682
772
  /** Event click: the stored frame is the poster until the seek lands. */
@@ -687,9 +777,9 @@ var PlayerController = class {
687
777
  img.crossOrigin = "anonymous";
688
778
  img.onload = () => {
689
779
  if (this.camId !== cam || this.posterFor !== ts || this.destroyed) return;
690
- const inSession = !!this.rw?.active && !!this.rw.id;
691
- if (inSession && !this.swapPending) return;
692
- this.freezeFromImage(img, true, inSession, "event");
780
+ const firstFramePending = !!this.rw?.active && this.presentedFrames() <= this.sessFrames0;
781
+ if (this.swapPending) this.freezeFromImage(img, true, true, "event");
782
+ else if (firstFramePending || !this.rw?.active) this.freezeFromImage(img, true, false, "event");
693
783
  };
694
784
  img.src = this.api.url(`api/evframe?camera=${encodeURIComponent(cam)}&ts=${ts}`);
695
785
  }
@@ -994,7 +1084,10 @@ var PlayerController = class {
994
1084
  this.v.pause();
995
1085
  } catch {
996
1086
  }
997
- this.freezeHide();
1087
+ this.img.onload = () => {
1088
+ this.img.onload = null;
1089
+ if (this.live) this.freezeLift(0);
1090
+ };
998
1091
  this.transport = "mjpeg";
999
1092
  this.setLabel("liveMjpeg");
1000
1093
  this.setMjpeg(true);
@@ -1005,8 +1098,11 @@ var PlayerController = class {
1005
1098
  return !this.recWebrtcDisabled && !!(window.RTCPeerConnection && window.WebSocket);
1006
1099
  }
1007
1100
  recWebrtcTeardown() {
1101
+ const seekStill = this.posterUntilSeek && this.posterUp();
1008
1102
  this.posterUntilSeek = false;
1009
1103
  this.swapPending = false;
1104
+ this.swapW = 0;
1105
+ if (seekStill) this.freezeArm(true);
1010
1106
  if (this.swapT) {
1011
1107
  clearTimeout(this.swapT);
1012
1108
  this.swapT = 0;
@@ -1097,10 +1193,15 @@ var PlayerController = class {
1097
1193
  if (this.rw === s && this.rwPending) {
1098
1194
  const p = this.rwPending;
1099
1195
  this.rwPending = null;
1100
- if (Math.abs(p.ts - this.rwStartMs) > 1500) this.recRelaySeek(p.ts, p.rate, p.srate);
1196
+ if (Math.abs(p.ts - this.rwStartMs) > 1500) {
1197
+ if (p.mark) this.freezeCurrent();
1198
+ this.recRelaySeek(p.ts, p.rate, p.srate, p.mark);
1199
+ }
1101
1200
  }
1102
1201
  }
1103
1202
  });
1203
+ this.sessFrames0 = this.presentedFrames();
1204
+ this.shownW = 0;
1104
1205
  this.rw = s;
1105
1206
  s.start();
1106
1207
  this.startRelayPoll();
@@ -1120,27 +1221,36 @@ var PlayerController = class {
1120
1221
  this.recWebrtcDisabled = true;
1121
1222
  this.playAt(ts, {});
1122
1223
  }
1123
- /** Hard server-side seek, coalesced: one in flight, latest wins, 150 ms floor. */
1124
- recRelaySeek(ts, rate = 1, srate = 1) {
1224
+ /** Hard server-side seek, coalesced: one in flight, latest wins, 150 ms floor. `mark` = a user jump with a still picture
1225
+ * (see SWAP_MS): the server answers with the marker width the new position arrives with. */
1226
+ recRelaySeek(ts, rate = 1, srate = 1, mark = false) {
1125
1227
  const s = this.rw;
1126
1228
  if (!s?.id) return;
1127
1229
  if (this.rwSeekBusy) {
1128
- this.rwPending = { ts, rate, srate };
1230
+ this.rwPending = { ts, rate, srate, mark: mark || !!this.rwPending?.mark };
1129
1231
  return;
1130
1232
  }
1131
- if (this.rwLastSeekTs === ts && this.rwRate === rate && this.rwSrate === srate && Date.now() - this.rwLastSeekAt < 1e3) return;
1233
+ if (!mark && this.rwLastSeekTs === ts && this.rwRate === rate && this.rwSrate === srate && Date.now() - this.rwLastSeekAt < 1e3) return;
1132
1234
  const wait = 150 - (Date.now() - this.rwLastSeekAt);
1133
1235
  if (wait > 0) {
1134
1236
  this.rwSeekBusy = true;
1135
- this.rwPending = { ts, rate, srate };
1237
+ this.rwPending = { ts, rate, srate, mark: mark || !!this.rwPending?.mark };
1136
1238
  window.setTimeout(() => {
1137
1239
  this.rwSeekBusy = false;
1138
1240
  const p = this.rwPending;
1139
1241
  this.rwPending = null;
1140
- if (p && this.rw?.id) this.recRelaySeek(p.ts, p.rate, p.srate);
1242
+ if (p && this.rw?.id) this.recRelaySeek(p.ts, p.rate, p.srate, p.mark);
1141
1243
  }, wait);
1142
1244
  return;
1143
1245
  }
1246
+ if (mark) {
1247
+ this.rwScrub = false;
1248
+ if (this.scrubOffT) {
1249
+ clearTimeout(this.scrubOffT);
1250
+ this.scrubOffT = 0;
1251
+ }
1252
+ this.scrubMoves = 0;
1253
+ }
1144
1254
  this.rwStartMs = ts;
1145
1255
  this.rwSrate = srate;
1146
1256
  this.rwRate = this.rwScrub ? srate : rate;
@@ -1158,22 +1268,53 @@ var PlayerController = class {
1158
1268
  this.seekAt = Date.now();
1159
1269
  this.cmdSeq++;
1160
1270
  this.swapPending = true;
1271
+ this.swapW = 0;
1272
+ this.swapAt = Date.now();
1161
1273
  if (this.swapT) {
1162
1274
  clearTimeout(this.swapT);
1163
1275
  this.swapT = 0;
1164
1276
  }
1165
- const done = (ok) => {
1277
+ const seq = this.cmdSeq;
1278
+ const done = (ok, w) => {
1166
1279
  this.rwSeekBusy = false;
1167
1280
  if (!ok) {
1168
1281
  this.relayRecover();
1169
1282
  return;
1170
1283
  }
1171
- if (this.swapPending) this.swapArm();
1284
+ if (this.swapPending && seq === this.cmdSeq) {
1285
+ if (w) {
1286
+ this.swapW = w;
1287
+ if (this.shownW === w) this.swapVisible("marker");
1288
+ } else this.swapArm();
1289
+ }
1172
1290
  const p = this.rwPending;
1173
1291
  this.rwPending = null;
1174
- if (p && this.rw?.id) this.recRelaySeek(p.ts, p.rate, p.srate);
1292
+ if (p && this.rw?.id) this.recRelaySeek(p.ts, p.rate, p.srate, p.mark);
1175
1293
  };
1176
- this.api.control(`api/relay-seek?session=${encodeURIComponent(s.id)}&start=${Math.round(ts)}&rate=${rate}&srate=${srate}`).then((ok) => done(ok));
1294
+ const q = `api/relay-seek?session=${encodeURIComponent(s.id)}&start=${Math.round(ts)}&rate=${rate}&srate=${srate}` + (mark ? `&mark=1&avoid=${this.shownW || this.v.videoWidth || 0}` : "");
1295
+ fetch(this.api.url(q), { cache: "no-store" }).then((r) => {
1296
+ if (!r.ok) return done(false, 0);
1297
+ if (r.status === 200) return r.json().then((j) => done(true, Number(j?.w) || 0), () => done(true, 0));
1298
+ return done(true, 0);
1299
+ }).catch(() => done(false, 0));
1300
+ }
1301
+ /** Speed button: the server changes its base rate in place (api/relay-speed) — no reposition, no "loading", no still.
1302
+ * Servers without the endpoint (404) get the former seek to the displayed position. */
1303
+ recRelaySpeed(r) {
1304
+ const s = this.rw;
1305
+ if (!s?.id) return;
1306
+ const c = this.currentTs();
1307
+ if (c != null) {
1308
+ this.rwPosTs = c;
1309
+ this.rwPosAt = Date.now();
1310
+ }
1311
+ if (!this.rwScrub) this.rwRate = r;
1312
+ this.cmdSeq++;
1313
+ this.wdGrace = Date.now() + 5e3;
1314
+ this.cad.lastNew = Date.now();
1315
+ this.api.control(`api/relay-speed?session=${encodeURIComponent(s.id)}&rate=${r}`).then((ok) => {
1316
+ if (!ok && this.rw === s && s.id) this.recRelaySeek(c ?? this.rwStartMs, r);
1317
+ });
1177
1318
  }
1178
1319
  /** Scrub target (timeline centre), coalesced: one in flight, latest wins, 120 ms floor, 250 ms minimum step. */
1179
1320
  recRelayTarget(ts) {
@@ -1198,7 +1339,6 @@ var PlayerController = class {
1198
1339
  }
1199
1340
  this.rwLastTarget = ts;
1200
1341
  this.rwLastTargetAt = Date.now();
1201
- this.cmdSeq++;
1202
1342
  this.wdGrace = Date.now() + 8e3;
1203
1343
  this.cad.lastNew = Date.now();
1204
1344
  this.rwTargetBusy = true;
@@ -1273,7 +1413,7 @@ var PlayerController = class {
1273
1413
  this.wdLastCt = q;
1274
1414
  this.wdLastAt = Date.now();
1275
1415
  this.recoveries = 0;
1276
- if (!this.posterUntilSeek) this.freezeHide();
1416
+ if (!this.posterUntilSeek) this.freezeLift();
1277
1417
  if (this.label === "loading" && !this.swapPending) this.setLabel("playing");
1278
1418
  } else if (this.rwScrub) this.wdLastAt = Date.now();
1279
1419
  else if (Date.now() - this.wdLastAt > 4e3 && Date.now() > this.wdGrace) {
@@ -1309,7 +1449,7 @@ var PlayerController = class {
1309
1449
  this.wdDead = 0;
1310
1450
  this.rwPosTs = d.t;
1311
1451
  this.rwPosAt = Date.now();
1312
- if (this.rwScrub && typeof d.r === "number" && isFinite(d.r) && d.r) this.rwRate = d.r;
1452
+ if ((this.rwScrub || this.scrubMoves > 0) && typeof d.r === "number" && isFinite(d.r) && d.r) this.rwRate = d.r;
1313
1453
  this.emit();
1314
1454
  } else if (d && d.t <= 0) {
1315
1455
  if (++this.wdDead >= 3) {
@@ -1407,8 +1547,11 @@ var PlayerController = class {
1407
1547
  }
1408
1548
  this.recPaused = false;
1409
1549
  const t0 = Math.max(ts, this.clips[idx0].startTime);
1410
- if (this.rw?.active && this.rw.id) this.recRelaySeek(t0, this.rate || 1, opts.srate || 1);
1411
- else if (this.rw?.active && !this.live) this.rwPending = { ts: t0, rate: this.rate || 1, srate: opts.srate || 1 };
1550
+ const jump = !opts.scrub;
1551
+ if (this.rw?.active && this.rw.id) {
1552
+ if (jump) this.freezeCurrent();
1553
+ this.recRelaySeek(t0, this.rate || 1, opts.srate || 1, jump);
1554
+ } else if (this.rw?.active && !this.live) this.rwPending = { ts: t0, rate: this.rate || 1, srate: opts.srate || 1, mark: jump };
1412
1555
  else {
1413
1556
  if (this.live) {
1414
1557
  this.freezeShow(true);
@@ -1775,11 +1918,12 @@ var PlayerController = class {
1775
1918
  if (this.rw?.active) {
1776
1919
  this.recPausedTs = this.currentTs();
1777
1920
  this.freezeShow();
1921
+ this.recWebrtcTeardown();
1778
1922
  if (this.freezeT) {
1779
1923
  clearTimeout(this.freezeT);
1780
1924
  this.freezeT = 0;
1781
1925
  }
1782
- this.recWebrtcTeardown();
1926
+ this.freezeTok = null;
1783
1927
  try {
1784
1928
  this.v.pause();
1785
1929
  } catch {
@@ -1802,8 +1946,7 @@ var PlayerController = class {
1802
1946
  const rates = [1, 2, 4, 8];
1803
1947
  this.rate = rates[(rates.indexOf(this.rate) + 1) % rates.length] ?? 1;
1804
1948
  if (this.rw?.active && this.rw.id) {
1805
- const c = this.currentTs();
1806
- this.recRelaySeek(c ?? this.rwStartMs, this.rate);
1949
+ this.recRelaySpeed(this.rate);
1807
1950
  this.v.muted = !this.soundOn || this.rate !== 1;
1808
1951
  } else this.v.playbackRate = this.rate;
1809
1952
  this.emit();
@@ -1964,8 +2107,13 @@ var PlayerController = class {
1964
2107
  if (this.transport === "mjpeg") this.img.removeAttribute("src");
1965
2108
  } else if (this.rw?.active) {
1966
2109
  this.hiddenTs = this.currentTs();
1967
- this.freezeShow(true);
2110
+ this.freezeShow();
1968
2111
  this.recWebrtcTeardown();
2112
+ if (this.freezeT) {
2113
+ clearTimeout(this.freezeT);
2114
+ this.freezeT = 0;
2115
+ }
2116
+ this.freezeTok = null;
1969
2117
  }
1970
2118
  } else {
1971
2119
  if (this.live) this.goLive();
@@ -1985,4 +2133,4 @@ export {
1985
2133
  WebRtcSession,
1986
2134
  PlayerController
1987
2135
  };
1988
- //# sourceMappingURL=chunk-ECFTCXR4.js.map
2136
+ //# sourceMappingURL=chunk-Z22KWFHI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/player/rlog.ts","../src/player/webrtc.ts","../src/player/controller.ts"],"sourcesContent":["/**\n * Client telemetry → the plugin's `api/clientlog` → its server log as `[client]`\n * lines (phones have no console; this is how playback problems on a device get\n * diagnosed). `brand` tags which host emitted the line (e.g. 'sentinel', 'hapulse').\n */\n\nimport type { SentinelClient } from '../api';\n\nlet brand = 'web';\n\nlet client: SentinelClient | null = null;\n\nexport function setRlogClient(c: SentinelClient | null, b?: string): void {\n client = c;\n if (b) brand = b;\n}\n\nexport function rlog(tag: string, data?: Record<string, unknown>): void {\n if (!client) return;\n let line: string;\n try {\n line = JSON.stringify({ tag, b: brand, d: data ?? null, ua: navigator.userAgent.slice(0, 80) });\n } catch {\n line = JSON.stringify({ tag, b: brand });\n }\n client.postText('api/clientlog', line);\n}\n","/**\n * WebRTC session over the plugin's WebSocket signaling (docs/API.md §6).\n * Battle-tested flow: options first, createLocalDescription/setRemoteDescription\n * RPCs, trickle ICE, stream composed from ALL receivers (Safari attached an\n * audio-only stream forever when the audio track arrived first), fresh offer on\n * renegotiation, dec-check after connect with a one-time TURN-relay retry on a\n * media blackhole. The API client is injected (hosts may run on another origin).\n */\nimport type { SentinelClient } from '../api';\nimport { rlog } from './rlog';\n\nexport interface SessionCallbacks {\n onStream: (ms: MediaStream) => void;\n onFail: (reason: string) => void;\n onSessionId?: (id: string) => void;\n}\nexport interface SessionOptions { camId: string; mode: 'live' | 'recorded'; startMs?: number; compat?: boolean; forceRelay?: boolean; kind?: string; }\n\nlet forceRelayGlobal = false;\n\nexport function mobileClient(): boolean {\n return /iPhone|iPod|Android|Mobile/i.test(navigator.userAgent) || (navigator.maxTouchPoints > 1 && Math.min(screen.width || 9999, screen.height || 9999) < 920);\n}\nfunction rtcOptions() {\n let capabilities: unknown;\n try { capabilities = RTCRtpReceiver.getCapabilities ? { audio: RTCRtpReceiver.getCapabilities('audio'), video: RTCRtpReceiver.getCapabilities('video') } : undefined; } catch { /* none */ }\n return { userAgent: navigator.userAgent, capabilities, screen: { devicePixelRatio: window.devicePixelRatio || 1, width: screen.width || 1920, height: screen.height || 1080 } };\n}\n\nexport class WebRtcSession {\n ws: WebSocket | undefined; pc: RTCPeerConnection | undefined; id: string | undefined; active = false;\n private connectT: number | undefined; private trackSig = ''; private api: SentinelClient; private opts: SessionOptions; private cb: SessionCallbacks;\n constructor(api: SentinelClient, opts: SessionOptions, cb: SessionCallbacks) { this.api = api; this.opts = opts; this.cb = cb; }\n get connected(): boolean { const s = this.pc?.iceConnectionState; return s === 'connected' || s === 'completed'; }\n\n start(): void {\n const params: Record<string, string> = {};\n if (this.opts.mode === 'recorded') { params.mode = 'recorded'; params.start = String(Math.round(this.opts.startMs || 0)); }\n if (this.opts.compat ?? mobileClient()) params.compat = '1';\n let ws: WebSocket;\n try { ws = new WebSocket(this.api.signalingUrl(this.opts.camId, params)); } catch { this.cb.onFail('ws'); return; }\n this.ws = ws; this.active = true;\n this.connectT = window.setTimeout(() => {\n if (this.active && this.ws === ws && !this.connected) {\n rlog('connect-timeout', { kind: this.opts.mode, ice: this.pc?.iceConnectionState });\n if (!forceRelayGlobal) { forceRelayGlobal = true; rlog('retry-relay-only', { kind: this.opts.mode }); this.stop(); this.start(); return; }\n this.fail('timeout');\n }\n }, 12000);\n ws.onopen = () => { try { ws.send(JSON.stringify({ type: 'options', options: rtcOptions() })); } catch { /* ignore */ } };\n ws.onerror = () => { if (this.active && this.ws === ws && !this.pc) this.fail('ws-error'); };\n ws.onclose = () => { if (this.active && this.ws === ws && !this.connected) this.fail('ws-closed'); };\n ws.onmessage = (ev) => {\n let msg: any; try { msg = JSON.parse(ev.data); } catch { return; }\n if (msg.type === 'createLocalDescription') this.createLocal(ws, msg);\n else if (msg.type === 'setRemoteDescription') this.setRemote(ws, msg);\n else if (msg.type === 'addIceCandidate') this.pc?.addIceCandidate(msg.candidate).catch(() => { /* ignore */ });\n else if (msg.type === 'sessionStarted') { this.id = msg.id; this.cb.onSessionId?.(msg.id); }\n else if (msg.type === 'error') { if (this.active && this.ws === ws) this.fail(msg.reason || 'error'); }\n };\n }\n\n stop(): void {\n this.active = false;\n if (this.connectT) { clearTimeout(this.connectT); this.connectT = undefined; }\n try { if (this.ws) { this.ws.onmessage = null; this.ws.onclose = null; this.ws.onerror = null; this.ws.close(); } } catch { /* ignore */ }\n try { if (this.pc) { this.pc.ontrack = null; this.pc.oniceconnectionstatechange = null; this.pc.onicecandidate = null; this.pc.close(); } } catch { /* ignore */ }\n this.ws = undefined; this.pc = undefined; this.id = undefined; this.trackSig = '';\n }\n\n private fail(reason: string): void { if (!this.active) return; this.stop(); this.cb.onFail(reason); }\n\n private ensurePc(setup: any): RTCPeerConnection {\n if (this.pc) return this.pc;\n let cfg: RTCConfiguration = (setup && setup.configuration) || { iceServers: [{ urls: 'stun:stun.l.google.com:19302' }] };\n if (forceRelayGlobal) cfg = { ...cfg, iceTransportPolicy: 'relay' };\n const pc = new RTCPeerConnection(cfg);\n this.pc = pc;\n if (setup?.datachannel) { try { const dc = pc.createDataChannel(setup.datachannel.label, setup.datachannel.dict); dc.binaryType = 'arraybuffer'; } catch { /* ignore */ } }\n if (setup?.audio) { try { pc.addTransceiver('audio', { direction: setup.audio.direction || 'recvonly' }); } catch { /* ignore */ } }\n if (setup?.video) { try { pc.addTransceiver('video', { direction: setup.video.direction || 'recvonly' }); } catch { /* ignore */ } }\n pc.ontrack = () => {\n if (!this.active || this.pc !== pc) return;\n const ms = new MediaStream();\n pc.getReceivers().forEach(r => { if (r.track) ms.addTrack(r.track); });\n if (!ms.getVideoTracks().length) return; // audio-first: wait for the video event\n const sig = ms.getTracks().map(t => t.id).sort().join(',');\n if (this.trackSig === sig) return;\n this.trackSig = sig;\n this.cb.onStream(ms);\n };\n pc.oniceconnectionstatechange = () => {\n if (!this.active || this.pc !== pc) return;\n const st = pc.iceConnectionState;\n if (st === 'connected' || st === 'completed') {\n if (this.connectT) { clearTimeout(this.connectT); this.connectT = undefined; }\n window.setTimeout(() => {\n if (!this.active || this.pc !== pc) return;\n pc.getStats().then(s => {\n let dec = -1, recv = -1, vBytes = -1, aBytes = -1;\n s.forEach((r: any) => {\n if (r.type === 'inbound-rtp' && (r.kind || r.mediaType) === 'video') { dec = r.framesDecoded || 0; recv = r.framesReceived ?? -1; vBytes = r.bytesReceived || 0; }\n if (r.type === 'inbound-rtp' && (r.kind || r.mediaType) === 'audio') aBytes = r.bytesReceived || 0;\n });\n if (dec <= 0) {\n rlog('dec-check-fail', { kind: this.opts.mode, dec, recv, vBytes, aBytes, relayForced: forceRelayGlobal });\n if (!forceRelayGlobal && vBytes <= 0 && aBytes <= 0) { forceRelayGlobal = true; rlog('retry-relay-only', { kind: this.opts.mode }); this.stop(); this.start(); return; }\n this.fail('no-decode');\n }\n else rlog('dec-ok', { kind: this.opts.mode, dec, relayForced: forceRelayGlobal });\n }).catch(() => { /* ignore */ });\n }, this.opts.mode === 'live' ? 5000 : 9000);\n }\n if (st === 'failed') { rlog('ice-failed', { kind: this.opts.mode }); this.fail('ice-failed'); }\n };\n return pc;\n }\n\n private createLocal(ws: WebSocket, msg: any): void {\n const pc = this.ensurePc(msg.setup);\n const mid = this.connected;\n if (mid) rlog('reneg', { dtype: msg.dtype, kind: this.opts.mode });\n const reply = (desc: RTCSessionDescriptionInit) => { try { ws.send(JSON.stringify({ type: 'response', reqId: msg.reqId, description: { type: desc.type, sdp: desc.sdp } })); } catch { /* ignore */ } };\n pc.onicecandidate = (ev) => { if (ev.candidate) { try { ws.send(JSON.stringify({ type: 'iceCandidate', candidate: JSON.parse(JSON.stringify(ev.candidate)) })); } catch { /* ignore */ } } };\n const p = msg.dtype === 'offer'\n ? pc.createOffer({ offerToReceiveAudio: !!msg.setup?.audio, offerToReceiveVideo: !!msg.setup?.video }).then(o => pc.setLocalDescription(o).then(() => reply(o)))\n : pc.createAnswer().then(a => pc.setLocalDescription(a).then(() => reply(a)));\n p.catch(e => { rlog('createLocal-fail', { dtype: msg.dtype, name: e?.name, mid }); if (!mid) this.fail('createLocal'); });\n }\n\n private setRemote(ws: WebSocket, msg: any): void {\n const pc = this.ensurePc(msg.setup);\n const mid = this.connected;\n pc.setRemoteDescription(msg.description)\n .then(() => { try { ws.send(JSON.stringify({ type: 'response', reqId: msg.reqId, ok: true })); } catch { /* ignore */ } })\n .catch(e => { rlog('sRD-fail', { name: e?.name, mid }); try { ws.send(JSON.stringify({ type: 'response', reqId: msg.reqId, ok: false })); } catch { /* ignore */ } if (!mid) this.fail('sRD'); });\n }\n}\n","/**\n * PlayerController — the whole playback brain of the NVR. Framework-free: it owns\n * a <video>, a freeze <canvas> and an MJPEG <img> inside a stage element, and\n * reports state through `onState`; the host only renders what it says.\n *\n * Host seams: the API client is injected; status labels are i18n KEY suffixes\n * (`nvr.player.<label>`) the host translates; `storagePrefix` namespaces the\n * remembered stage aspect per camera; `brand` tags telemetry lines. The MSE paths\n * are gated on `SentinelClient.corsMedia`; posters load with crossOrigin so the\n * freeze canvas stays untainted. The host CSS must define a `.hidden` class.\n *\n * Paths: LIVE = WebRTC (sink) → MSE live (fMP4, no audio) → MJPEG <img>.\n * RECORDED = WebRTC relay (server-seekable, scrub time-lapse in place) →\n * MSE fallback (progressive segments, trick-play chase) → native <video src>.\n */\nimport type { SentinelClip as Clip, SentinelClient } from '../api';\nimport { rlog, setRlogClient } from './rlog';\nimport { WebRtcSession, mobileClient } from './webrtc';\n\n/** `label` is an i18n key suffix: nvr.player.<label> */\nexport type PlayerLabel = 'live' | 'liveWebrtc' | 'liveMse' | 'liveMjpeg' | 'loading' | 'playing' | 'paused' | 'scrub' | 'noRecording' | '';\nexport interface PlayerState {\n live: boolean; label: PlayerLabel; playhead: number | null; rate: number; sound: boolean; paused: boolean;\n transport: 'webrtc' | 'mse' | 'mjpeg' | 'relay' | 'native' | 'none'; muted: boolean;\n}\nexport interface PlayerRefs { video: HTMLVideoElement; freeze: HTMLCanvasElement; img: HTMLImageElement; stage: HTMLElement; }\nexport interface PlayerOptions {\n onState: (s: PlayerState) => void;\n onClipsRefresh: () => Promise<Clip[]>;\n /** localStorage key prefix for the remembered stage aspect per camera (default 'snvr-ar-'). */\n storagePrefix?: string;\n /** telemetry brand tag written into api/clientlog lines (default 'web'). */\n brand?: string;\n}\ntype Opts = PlayerOptions;\n\nconst MSCls: typeof MediaSource | undefined = (window as any).ManagedMediaSource || window.MediaSource;\n/** Seek → picture. After a jump the OLD position keeps playing until the new one has crossed the pipeline (measured 24.09.2026,\n * sink passthrough: 1.3–1.4 s on the LAN, more on slow links). A still picture (event frame / frozen picture) covers that and\n * is lifted on the EXACT first frame of the new position: the server restarts its transcoder with a marker width it names in\n * the relay-seek answer ({w}); the first presented frame of that width (rVFC metadata / `resize`) is the new position.\n * Servers without markers (plain 204): lifted SWAP_MS after the answer plus one presented frame. MARK_CAP_MS = safety net. */\nconst SWAP_MS = 2600;\nconst MARK_CAP_MS = 12000;\n/** Lifting a still: wait this many further presented frames after the \"new content\" signal, then fade it out. iOS/Safari\n * draw video on a separate layer that may still be empty for a moment after the frame callback — hiding the still at\n * once let the grey stage background flash through (user 25.09.2026, iPhone). ~100 ms + 120 ms fade at 20 fps. */\nconst LIFT_FRAMES = 2;\nconst LIFT_FADE_MS = 120;\n/** Scrub profile (640 all-intra) → normal (1280) only after the gesture has been quiet this long: a scroll–pause–scroll pattern\n * restarted the transcoder twice per pause (server log: profile switch every 1–2 s, 30 restarts in one session). */\nconst SCRUB_OFF_DELAY_MS = 1500;\n/** hold mid-gesture: seek only if the playhead is further than this from the centre; idle: land if further than this */\n/** Scrub by TARGET (since 0.7.0): while the user scrubs, the client sends the timeline centre (api/relay-target, coalesced) and\n * the server's feeder steers its cursor onto it and stops there. No client-side rate estimate, no hold/landing seeks — those\n * overshot by (reaction time × rate) and then jumped back, and every seek shows 2.4 s of stale stream first. */\nconst TARGET_FLOOR_MS = 120, TARGET_MIN_STEP_MS = 250;\n\nexport class PlayerController {\n private v!: HTMLVideoElement; private fz!: HTMLCanvasElement; private img!: HTMLImageElement; private stage!: HTMLElement;\n private api: SentinelClient; private opts: Opts;\n camId = ''; camName = ''; clips: Clip[] = []; codecs: string | null = null; rangeStart = 0; rangeEnd = 0;\n live = false; rate = 1; soundOn = false; recPaused = false; recPausedTs: number | null = null;\n recWebrtcDisabled = false; label: PlayerLabel = ''; transport: PlayerState['transport'] = 'none';\n // relay session (RW)\n private rw: WebRtcSession | undefined; private rwStartMs = 0; private rwBase: number | null = null; private rwPosTs: number | null = null; private rwPosAt = 0;\n private rwRate = 1; private rwSrate = 1; private rwScrub = false; private rwSeekBusy = false; private rwPending: { ts: number; rate: number; srate: number; mark?: boolean } | null = null;\n private rwLastSeekTs: number | null = null; private rwLastSeekAt = 0;\n private relayPoll: number | undefined; private wdLastCt = -1; private wdLastAt = 0; private wdDead = 0; private wdGrace = 0; private wdResumeLogged = false; private recoveries = 0;\n private posterUntilSeek = false; private seekTarget = 0;\n // seek → visible swap (see SWAP_MS); posterFor = event the pending poster belongs to; scrubOffT = delayed profile switch\n private swapPending = false; private swapFrames = -1; private swapT = 0; private posterFor = 0; private scrubOffT = 0;\n // marked seek: width the new position arrives with (0 = timer path), send time (telemetry); presented width / frames at session start\n private swapW = 0; private swapAt = 0; private shownW = 0; private sessFrames0 = 0;\n private liftTok: object | null = null; // a pending lift (frames → fade → hide); any new still cancels it\n private scrubMoves = 0; private rwTargetBusy = false; private rwPendingTarget: number | null = null; private rwLastTarget = 0; private rwLastTargetAt = 0;\n // relay-pos answers are only valid for the command generation they were asked under; a poll sent BEFORE a\n // seek/rate change and answered after it would drag the playhead back to the old position (and the\n // auto-follow timeline with it → visible back-and-forth). seekAt: the server may still report the pre-swap\n // position for a moment after a seek — ignore far-off values in that window.\n private cmdSeq = 0; private seekAt = 0;\n // live session (W) + live MSE (L)\n private w: WebRtcSession | undefined; private L = { active: false, ms: null as MediaSource | null, sb: null as SourceBuffer | null, abort: null as AbortController | null, queue: [] as Uint8Array[], restarts: 0, lastTrim: 0, stallT: 0 };\n // recorded MSE (M)\n private M = { ms: null as MediaSource | null, sb: null as SourceBuffer | null, base: 0, nextIdx: -1, end: 0, active: false, feeding: false, abort: null as AbortController | null, q: [] as Uint8Array[], segFirst: false, segOff: 0, pendingSeek: null as number | null, mmsGo: true };\n private CH = { active: false, target: 0, timer: 0 };\n private curClipId: string | null = null; private playIndex = -1; private lastLoad = 0; private pendingTs: number | null = null; private pendingT: number | undefined;\n // frame counter / freeze\n private fc = { n: 0, tok: {} as object }; private freezeT = 0; private freezeTok: object | null = null;\n private cad = { t: 0, last: -1, lastNew: 0, stalls: 0, maxStall: 0, frames0: -1, t0: 0, gapMax: 0 };\n private stallTimer = 0; private destroyed = false; private liveRestartT = 0;\n private unlisten: (() => void)[] = [];\n\n private arPrefix: string;\n constructor(api: SentinelClient, opts: Opts) { this.api = api; this.opts = opts; this.arPrefix = opts.storagePrefix ?? 'snvr-ar-'; setRlogClient(api, opts.brand); }\n\n attach(r: PlayerRefs): void {\n this.v = r.video; this.fz = r.freeze; this.img = r.img; this.stage = r.stage;\n const v = this.v;\n const on = (n: string, f: () => void) => { v.addEventListener(n, f); this.unlisten.push(() => v.removeEventListener(n, f)); };\n on('timeupdate', () => { if (this.live) return; if (this.rw?.active && this.rwBase == null && v.currentTime > 0) this.rwBase = v.currentTime; const ts = this.currentTs(); if (ts == null) return; if (this.M.active || this.rw?.active) { const i = this.clipIndexFor(ts); if (i >= 0) this.playIndex = i; } this.feed(); this.emit(); });\n on('waiting', () => { if (this.live) { if (this.L.active && !this.L.stallT) this.L.stallT = window.setTimeout(() => { this.L.stallT = 0; if (this.live && this.L.active && v.readyState < 3) this.liveRestart(); }, 4000); return; } if (!this.rw?.active) this.setLabel('loading'); if (!this.M.active || this.stallTimer) return; this.stallTimer = window.setTimeout(() => { this.stallTimer = 0; this.handleStall(); }, 600); });\n on('seeking', () => { if (!this.live && !this.rw?.active) this.setLabel('loading'); });\n for (const n of ['loadeddata', 'playing', 'canplay', 'seeked']) on(n, () => { if (v.videoWidth && !v.srcObject && !this.posterUntilSeek) this.freezeLift(); /* WebRTC: presented frames decide (rVFC), not these events */ if (!this.live && this.label === 'loading') this.setLabel('playing'); if (this.L.stallT) { clearTimeout(this.L.stallT); this.L.stallT = 0; } this.emit(); });\n on('pause', () => { if (this.L.stallT) { clearTimeout(this.L.stallT); this.L.stallT = 0; } this.emit(); });\n on('play', () => this.emit());\n // the stage box follows the picture's real aspect where the layout uses it (mobile: no letterbox bars for 4:3 cameras)\n on('loadedmetadata', () => this.setAspect(this.v.videoWidth, this.v.videoHeight));\n on('resize', () => { this.setAspect(this.v.videoWidth, this.v.videoHeight); if (this.v.videoWidth && !(this.v as any).requestVideoFrameCallback) this.markerCheck(this.v.videoWidth); });\n on('volumechange', () => this.emit());\n on('error', () => { const e = v.error; rlog('video-error', { code: e?.code, msg: e?.message?.slice(0, 120), src: v.getAttribute('src') ? 'src' : 'srcObject' }); });\n on('ended', () => { if (this.live || this.M.active || this.rw?.active) return; const n = this.playIndex + 1; if (n < this.clips.length) { const c = this.clips[n]!; this.curClipId = c.id; this.playIndex = n; v.src = this.api.url(`api/segment?id=${encodeURIComponent(c.videoId || c.id)}`); v.load(); v.onloadedmetadata = () => { v.playbackRate = this.rate; try { v.currentTime = 0; } catch { /* ignore */ } this.safePlay(); }; this.setLabel('playing'); } });\n this.pendingT = window.setInterval(() => { if (this.pendingTs != null && Date.now() - this.lastLoad >= 200) { const t = this.pendingTs; this.pendingTs = null; this.playAt(t, { scrub: true }); } }, 120);\n const vis = () => this.onVisibility(); document.addEventListener('visibilitychange', vis); this.unlisten.push(() => document.removeEventListener('visibilitychange', vis));\n const edge = window.setInterval(() => { if (this.live && this.L.active) this.liveEdge(); }, 1000); this.unlisten.push(() => clearInterval(edge));\n }\n\n destroy(): void {\n this.destroyed = true;\n // no path may (re)start a stream on a destroyed controller: the 1-s live\n // restart timer, a pending async load in the host, a visibility change …\n this.live = false; this.recPaused = false;\n if (this.liveRestartT) { clearTimeout(this.liveRestartT); this.liveRestartT = 0; }\n this.recWebrtcTeardown(); this.webrtcTeardown(); this.mseTeardown(); this.liveTeardown(); this.chaseAbort();\n if (this.pendingT) clearInterval(this.pendingT);\n for (const u of this.unlisten) u();\n try { this.v.pause(); this.v.srcObject = null; this.v.removeAttribute('src'); } catch { /* ignore */ }\n }\n\n setCamera(camId: string, name: string): void {\n if (camId !== this.camId) { this.recWebrtcDisabled = false; this.recoveries = 0; }\n this.camId = camId; this.camName = name;\n // last known picture aspect of this camera: the stage has the right shape before any poster/video arrives\n let ar = ''; try { ar = localStorage.getItem(this.arPrefix + camId) || ''; } catch { /* ignore */ }\n if (ar) this.stage.style.setProperty('--stage-ar', ar); else this.stage.style.removeProperty('--stage-ar');\n }\n /** picture aspect → stage box (mobile layout uses it); posters and video both report it */\n private setAspect(w: number, h: number): void {\n if (!w || !h) return;\n const ar = `${w} / ${h}`;\n if (this.stage.style.getPropertyValue('--stage-ar') === ar) return;\n this.stage.style.setProperty('--stage-ar', ar);\n try { localStorage.setItem(this.arPrefix + this.camId, ar); } catch { /* ignore */ }\n }\n /** clips of the loaded range (several days, sorted), codec string, and the range the timeline spans */\n setClips(clips: Clip[], codecs: string | null, rangeStart: number, rangeEnd: number): void { this.clips = clips; this.codecs = codecs; this.rangeStart = rangeStart; this.rangeEnd = rangeEnd; }\n\n // ---- state ---------------------------------------------------------------------\n private setLabel(l: PlayerLabel): void { this.label = l; this.emit(); }\n private emit(): void {\n if (this.destroyed) return;\n this.opts.onState({ live: this.live, label: this.label, playhead: this.live ? null : this.currentTs(), rate: this.rate, sound: this.soundOn, paused: this.recPaused || (this.v.paused && !this.live && !this.rw?.active), transport: this.transport, muted: this.v.muted });\n }\n clipIndexFor(ts: number): number { for (let i = 0; i < this.clips.length; i++) { const c = this.clips[i]!; if (ts >= c.startTime && ts < c.startTime + (c.duration || 60000)) return i; } return -1; }\n private nearNow(ts: number): boolean { return Date.now() - ts < 8000; }\n private clampRange(ts: number): number { return Math.min(Math.max(ts, this.rangeStart), Math.min(this.rangeEnd - 1, Date.now())); }\n\n /** Wall-clock position of the picture on screen (Scrypted's getRecordingStreamCurrentTime). */\n currentTs(): number | null {\n if (this.rw?.active) {\n if (this.rwPosTs != null) {\n const v = this.rwPosTs + (Date.now() - this.rwPosAt) * (this.rwRate || 1);\n // while the server steers onto a target its rate changes every 100 ms — never extrapolate past the target\n if ((this.rwScrub || this.scrubMoves > 0) && this.rwLastTarget) { const lo = Math.min(this.rwPosTs, this.rwLastTarget), hi = Math.max(this.rwPosTs, this.rwLastTarget); return Math.min(hi, Math.max(lo, v)); }\n return v;\n }\n if (this.rwBase != null && this.v.currentTime > 0) return this.rwStartMs + (this.v.currentTime - this.rwBase) * 1000 * (this.rwRate || 1);\n return this.rwStartMs;\n }\n if (this.recPaused) return this.recPausedTs;\n if (this.live) return null;\n if (this.M.active) return this.M.base + this.v.currentTime * 1000;\n const pc = this.playIndex >= 0 ? this.clips[this.playIndex] : undefined; if (pc) return pc.startTime + this.v.currentTime * 1000;\n return null;\n }\n\n // ---- presented frames / freeze / poster -----------------------------------------\n private fcArm(): void {\n const v: any = this.v; if (!v.requestVideoFrameCallback) return; const tok = {}; this.fc.tok = tok;\n const tick = (_now: number, md?: { width?: number }) => {\n if (this.fc.tok !== tok) return; this.fc.n++;\n const w = (md && md.width) || this.v.videoWidth; if (w) { this.shownW = w; this.markerCheck(w); }\n try { v.requestVideoFrameCallback(tick); } catch { /* ignore */ }\n };\n try { v.requestVideoFrameCallback(tick); } catch { /* ignore */ }\n }\n /** a presented frame of width w: is it the first frame of the marked seek's new position? */\n private markerCheck(w: number): void { if (this.swapPending && this.swapW && w === this.swapW) this.swapVisible('marker'); }\n presentedFrames(): number { if ((this.v as any).requestVideoFrameCallback) return this.fc.n; try { return this.v.getVideoPlaybackQuality().totalVideoFrames; } catch { return -1; } }\n private freezeArm(hold: boolean): void {\n if (this.freezeT) clearTimeout(this.freezeT);\n this.freezeT = window.setTimeout(() => this.freezeHide(), 90000); // safety net only — a still stays until the video really runs\n const v: any = this.v;\n if (hold && v.requestVideoFrameCallback) { const tok = {}; this.freezeTok = tok; try { v.requestVideoFrameCallback(() => { if (this.freezeTok === tok && this.v.videoWidth) this.freezeLift(); }); } catch { /* ignore */ } }\n }\n /** a still is shown (again): cancel a pending lift, full opacity */\n private stillUp(): void { this.liftTok = null; this.fz.classList.remove('nvr-stage__freeze--fade'); this.fz.classList.remove('hidden'); }\n /** New content is being presented → lift the still after LIFT_FRAMES more presented frames with a short fade (see\n * LIFT_FRAMES). `frames` 0 = fade right away (MJPEG image loaded). A lift already under way is not restarted. */\n private freezeLift(frames = LIFT_FRAMES): void {\n if (!this.posterUp() || this.liftTok) return;\n const tok = {}; this.liftTok = tok; const v: any = this.v;\n const fade = () => {\n if (this.liftTok !== tok) return;\n this.fz.classList.add('nvr-stage__freeze--fade');\n window.setTimeout(() => { if (this.liftTok === tok) this.freezeHide(); }, LIFT_FADE_MS);\n };\n if (frames > 0 && v.requestVideoFrameCallback) {\n let n = 0;\n const tick = () => { if (this.liftTok !== tok) return; if (++n >= frames) fade(); else { try { v.requestVideoFrameCallback(tick); } catch { fade(); } } };\n try { v.requestVideoFrameCallback(tick); } catch { fade(); }\n } else window.setTimeout(fade, frames > 0 ? 100 : 0);\n }\n /** copy the current video picture onto the freeze canvas (false = nothing to copy yet) */\n private drawVideo(): boolean {\n const v = this.v, fc = this.fz;\n if (!v.videoWidth || !v.videoHeight || v.readyState < 2) return false;\n if (fc.width !== v.videoWidth) fc.width = v.videoWidth;\n if (fc.height !== v.videoHeight) fc.height = v.videoHeight;\n fc.getContext('2d')!.drawImage(v, 0, 0, fc.width, fc.height);\n this.stillUp(); fc.dataset.src = 'video';\n return true;\n }\n /** Freeze the current picture. A still that is already visible stays (redrawing would copy from an element whose stream\n * may already be gone → black) — it is only re-armed. */\n freezeShow(hold = false): void {\n try { if (this.posterUp()) { if (!this.posterUntilSeek) this.freezeArm(hold); return; } if (this.drawVideo()) this.freezeArm(hold); } catch { /* ignore */ }\n }\n /** poster/freeze stays until the seek's picture is visible (swapVisible); safety net MARK_CAP_MS */\n private holdUntilSwap(): void {\n if (this.freezeT) clearTimeout(this.freezeT); this.freezeTok = null;\n if (this.posterUp()) this.stillUp(); // a lift in progress is cancelled — this still now waits for the jump\n this.posterUntilSeek = true; this.freezeT = window.setTimeout(() => this.swapVisible('cap'), MARK_CAP_MS);\n }\n /** A jump inside a running relay session: the current picture stands still at once (the old position must not keep playing\n * while the new one crosses the pipeline); an already visible still (event frame) is kept. Lifted by swapVisible. */\n freezeCurrent(): void {\n if (!this.rw?.active || !this.rw.id) return; // no session yet: playAt's own freeze/poster path applies\n try { if (this.posterUp() || this.drawVideo()) this.holdUntilSwap(); } catch { /* ignore */ }\n }\n /** the picture of the last seek is on screen: lift a held poster, report playing */\n private swapVisible(how: 'marker' | 'timer' | 'cap' = 'timer'): void {\n if (this.swapT) { clearTimeout(this.swapT); this.swapT = 0; }\n const was = this.swapPending; this.swapPending = false; this.swapW = 0;\n if (was && this.swapAt) rlog('swap', { how, ms: Date.now() - this.swapAt, w: this.shownW });\n this.swapAt = 0;\n if (this.posterUntilSeek) { this.posterUntilSeek = false; if (this.freezeT) { clearTimeout(this.freezeT); this.freezeT = 0; } this.freezeLift(); }\n if (this.label === 'loading' && this.rw?.active) this.setLabel('playing');\n }\n /** seek answered: the new picture is on screen SWAP_MS later (plus proof of a presented frame) */\n private swapArm(): void {\n if (this.swapT) clearTimeout(this.swapT);\n this.swapFrames = this.presentedFrames();\n const check = () => { this.swapT = 0; if (!this.swapPending || !this.rw?.active) return; if (this.presentedFrames() > this.swapFrames) this.swapVisible(); else this.swapT = window.setTimeout(check, 100); };\n this.swapT = window.setTimeout(check, SWAP_MS);\n }\n freezeFromImage(img: HTMLImageElement, hold: boolean, untilSeek = false, kind = 'image'): boolean {\n try {\n if (!img.naturalWidth || !img.naturalHeight) return false;\n const fc = this.fz; fc.width = img.naturalWidth; fc.height = img.naturalHeight; fc.getContext('2d')!.drawImage(img, 0, 0); this.stillUp(); fc.dataset.src = kind;\n this.setAspect(img.naturalWidth, img.naturalHeight);\n if (untilSeek) this.holdUntilSwap(); // stays until the seek's picture is visible (see startRelayPoll)\n else this.freezeArm(hold);\n return true;\n } catch { return false; }\n }\n freezeHide(): void { if (this.freezeT) { clearTimeout(this.freezeT); this.freezeT = 0; } this.liftTok = null; this.posterUntilSeek = false; this.fz.classList.add('hidden'); this.fz.classList.remove('nvr-stage__freeze--fade'); delete this.fz.dataset.src; }\n private posterUp(): boolean { return !this.fz.classList.contains('hidden'); }\n /** scrub on MSE: the still stays while the gesture runs (lifted by the seek's `seeked`/`playing`) */\n freezeHold(): void { if (this.freezeT) { clearTimeout(this.freezeT); this.freezeT = window.setTimeout(() => this.freezeHide(), 90000); } }\n /** Event click: the stored frame is the poster until the seek lands. */\n posterEvent(ts: number): void {\n const cam = this.camId; this.posterFor = ts; const img = new Image(); img.crossOrigin = 'anonymous';\n img.onload = () => {\n if (this.camId !== cam || this.posterFor !== ts || this.destroyed) return;\n const firstFramePending = !!this.rw?.active && this.presentedFrames() <= this.sessFrames0;\n if (this.swapPending) this.freezeFromImage(img, true, true, 'event'); // a jump is under way → until its picture\n else if (firstFramePending || !this.rw?.active) this.freezeFromImage(img, true, false, 'event'); // new session → until its first frame\n // else: the target picture is already on screen — don't cover it\n };\n img.src = this.api.url(`api/evframe?camera=${encodeURIComponent(cam)}&ts=${ts}`);\n }\n /** Camera opened: a picture in front of the black stage until live plays — the overview tile's snapshot when the host\n * remembers one (browser cache → instant), else a fresh api/snapshot (1–3 s). */\n posterFromSnapshot(tileUrl?: string): void {\n const cam = this.camId;\n const load = (src: string, fresh: boolean) => {\n const img = new Image(); img.crossOrigin = 'anonymous';\n img.onload = () => { if (this.camId !== cam || this.rw?.active || this.recPaused || this.posterUp()) return; if (this.v.readyState >= 2 && this.v.videoWidth && !this.v.paused) return; this.freezeFromImage(img, true, false, 'snapshot'); };\n if (!fresh) img.onerror = () => load(this.api.url(`api/snapshot?camera=${encodeURIComponent(cam)}`) + `&_=${Date.now()}`, true);\n img.src = src;\n };\n if (tileUrl) load(tileUrl, false); else load(this.api.url(`api/snapshot?camera=${encodeURIComponent(cam)}`) + `&_=${Date.now()}`, true);\n }\n private posterShow(ts: number): void { try { if (this.posterUp()) return; if (this.v.readyState >= 2 && this.v.videoWidth) return; const i = this.clipIndexFor(ts); const c = i >= 0 ? this.clips[i] : undefined; if (!c?.thumbnailId) return; const cam = this.camId; const img = new Image(); img.crossOrigin = 'anonymous'; img.onload = () => { if (this.camId !== cam || this.destroyed) return; if (!this.posterUp()) this.freezeFromImage(img, true, false, 'thumb'); }; img.src = this.api.url(`api/thumb?id=${encodeURIComponent(c.thumbnailId)}`); } catch { /* ignore */ } }\n\n private safePlay(): void {\n let pr: Promise<void>; try { pr = this.v.play(); } catch { return; }\n pr.then(() => this.emit()).catch((e1) => { this.v.muted = true; this.v.play().then(() => this.emit()).catch((e2) => rlog('play-fail', { e1: e1?.name, e2: e2?.name, rs: this.v.readyState, paused: this.v.paused })); });\n }\n\n // ---- LIVE ---------------------------------------------------------------------------\n goLive(): void {\n if (!this.camId || this.destroyed) return;\n this.chaseAbort();\n this.freezeShow(true);\n this.exitLiveState(); this.recWebrtcTeardown(); this.recPaused = false; this.live = true; this.playIndex = -1; this.curClipId = null; this.L.restarts = 0;\n this.setLabel('live');\n if (document.visibilityState === 'hidden') return;\n if (window.RTCPeerConnection && window.WebSocket) this.liveStartWebrtc();\n else if (this.liveMseOk()) this.liveStartMse();\n else { try { this.v.pause(); } catch { /* ignore */ } this.liveFallbackImg(); }\n }\n private exitLiveState(): void { if (this.live) { this.live = false; this.webrtcTeardown(); this.liveTeardown(); try { this.v.srcObject = null; } catch { /* ignore */ } this.setMjpeg(false); } }\n private setMjpeg(on: boolean): void { this.img.classList.toggle('hidden', !on); this.v.classList.toggle('hidden', on); if (!on) this.img.removeAttribute('src'); }\n private webrtcTeardown(): void { this.w?.stop(); this.w = undefined; }\n private liveStartWebrtc(): void {\n if (this.destroyed) return;\n this.v.onloadedmetadata = null;\n this.webrtcTeardown(); this.recWebrtcTeardown(); this.mseTeardown(); this.liveTeardown();\n try { this.v.pause(); } catch { /* ignore */ } try { this.v.srcObject = null; } catch { /* ignore */ } this.v.removeAttribute('src');\n this.setMjpeg(false);\n const s = new WebRtcSession(this.api, { camId: this.camId, mode: 'live' }, {\n onStream: (ms) => { if (!this.live || this.w !== s) return; this.setMjpeg(false); this.v.muted = !this.soundOn; try { this.v.removeAttribute('src'); } catch { /* ignore */ } try { this.v.srcObject = ms; } catch { /* ignore */ } this.fcArm(); this.safePlay(); this.transport = 'webrtc'; this.setLabel('liveWebrtc'); },\n onFail: () => { if (this.w === s) this.liveFallbackMse(); },\n });\n this.w = s; this.transport = 'webrtc'; s.start();\n }\n private liveFallbackMse(): void { this.webrtcTeardown(); if (!this.live) return; try { this.v.srcObject = null; } catch { /* ignore */ } if (this.liveMseOk()) this.liveStartMse(); else this.liveFallbackImg(); }\n private liveCodec(): string | null { return this.codecs ? (this.codecs.split(',')[0] ?? null) : null; }\n private liveMseOk(): boolean { try { const c = this.liveCodec(); return !!(this.api.corsMedia && MSCls && c && MSCls.isTypeSupported(`video/mp4; codecs=\"${c}\"`)); } catch { return false; } }\n private liveTeardown(): void { const L = this.L; L.active = false; L.queue = []; if (L.stallT) { clearTimeout(L.stallT); L.stallT = 0; } try { L.abort?.abort(); } catch { /* ignore */ } L.abort = null; if (L.sb && L.ms && L.ms.readyState === 'open') { try { L.sb.abort(); } catch { /* ignore */ } } L.sb = null; L.ms = null; }\n private liveAppend(): void { const L = this.L; if (!L.active || !L.sb || L.sb.updating || !L.queue.length) return; const buf = L.queue.shift()!; try { L.sb.appendBuffer(buf as BufferSource); } catch { this.liveRestart(); } }\n private liveTrim(): void { const L = this.L; if (!L.sb || L.sb.updating) return; try { const b = this.v.buffered; if (b.length && this.v.currentTime - b.start(0) > 30) L.sb.remove(0, this.v.currentTime - 10); } catch { /* ignore */ } }\n private liveEdge(): void { try { const b = this.v.buffered; if (!b.length) return; const end = b.end(b.length - 1); if (end - this.v.currentTime > 2.5) this.v.currentTime = end - 0.7; if (this.v.paused) this.safePlay(); } catch { /* ignore */ } }\n private liveRestart(): void { if (!this.live || !this.L.active) return; this.liveTeardown(); this.L.restarts++; if (this.L.restarts > 5) { this.liveFallbackImg(); return; } if (this.liveRestartT) clearTimeout(this.liveRestartT); this.liveRestartT = window.setTimeout(() => { this.liveRestartT = 0; if (this.live && !this.destroyed) this.liveStartMse(); }, 1000); }\n private liveStartMse(): void {\n if (this.destroyed) return;\n this.v.onloadedmetadata = null;\n this.liveTeardown(); this.mseTeardown();\n const L = this.L; L.active = true; this.transport = 'mse'; this.setLabel('liveMse'); this.setMjpeg(false);\n const ms = new MSCls!(); L.ms = ms; L.lastTrim = Date.now();\n if ((window as any).ManagedMediaSource && ms instanceof (window as any).ManagedMediaSource) { try { (this.v as any).disableRemotePlayback = true; } catch { /* ignore */ } }\n const u = URL.createObjectURL(ms);\n ms.addEventListener('sourceopen', () => {\n URL.revokeObjectURL(u); if (L.ms !== ms) return;\n let sb: SourceBuffer; try { sb = ms.addSourceBuffer(`video/mp4; codecs=\"${this.liveCodec()}\"`); } catch { this.liveFallbackImg(); return; }\n sb.mode = 'segments';\n sb.addEventListener('updateend', () => { if (Date.now() - L.lastTrim > 10000) { L.lastTrim = Date.now(); this.liveTrim(); } this.liveAppend(); });\n sb.addEventListener('error', () => this.liveRestart());\n L.sb = sb; L.abort = new AbortController();\n fetch(this.api.url(`api/livemse?camera=${encodeURIComponent(this.camId)}`), { credentials: 'same-origin', signal: L.abort.signal })\n .then(r => { if (!r.ok || !r.body) throw new Error(String(r.status)); const rd = r.body.getReader(); const loop = () => { rd.read().then(x => { if (!L.active || L.ms !== ms) return; if (x.done) { this.liveRestart(); return; } L.queue.push(x.value); this.liveAppend(); loop(); }).catch(() => { if (L.active && L.ms === ms) this.liveRestart(); }); }; loop(); })\n .catch(() => { if (L.active && L.ms === ms) this.liveFallbackImg(); });\n });\n try { this.v.srcObject = null; } catch { /* ignore */ }\n this.v.src = u; this.v.playbackRate = 1; this.v.muted = true; this.safePlay();\n }\n private liveFallbackImg(): void { this.liveTeardown(); if (!this.live) return; try { this.v.pause(); } catch { /* ignore */ } this.img.onload = () => { this.img.onload = null; if (this.live) this.freezeLift(0); }; this.transport = 'mjpeg'; this.setLabel('liveMjpeg'); this.setMjpeg(true); this.img.src = this.api.url(`api/live?camera=${encodeURIComponent(this.camId)}`) + `&_=${Date.now()}`; }\n\n // ---- RECORDED via relay -----------------------------------------------------------------\n private recWebrtcOk(): boolean { return !this.recWebrtcDisabled && !!(window.RTCPeerConnection && window.WebSocket); }\n private recWebrtcTeardown(): void { const seekStill = this.posterUntilSeek && this.posterUp(); this.posterUntilSeek = false; this.swapPending = false; this.swapW = 0; if (seekStill) this.freezeArm(true); /* still over a jump → now until the NEXT stream's first frame */ if (this.swapT) { clearTimeout(this.swapT); this.swapT = 0; } if (this.scrubOffT) { clearTimeout(this.scrubOffT); this.scrubOffT = 0; } this.rwTargetBusy = false; this.rwPendingTarget = null; this.rwLastTarget = 0; this.stopRelayPoll(); this.rw?.stop(); this.rw = undefined; this.rwBase = null; this.rwPosTs = null; this.rwScrub = false; this.rwSeekBusy = false; this.rwPending = null; this.rwLastSeekTs = null; this.rwSrate = 1; this.rwRate = 1; }\n private recWebrtcStart(ts: number): void {\n if (this.destroyed) return;\n this.v.onloadedmetadata = null;\n this.freezeShow(true); this.posterShow(ts);\n this.live = false;\n this.recWebrtcTeardown(); this.webrtcTeardown(); this.mseTeardown(); this.liveTeardown();\n try { this.v.pause(); } catch { /* ignore */ } try { this.v.removeAttribute('src'); this.v.srcObject = null; } catch { /* ignore */ }\n this.setMjpeg(false); this.transport = 'relay';\n this.setLabel('loading');\n this.rwStartMs = ts; this.rwBase = null; this.rwRate = this.rate; this.rwSrate = 1; this.seekTarget = ts; // event poster clears when relay-pos reaches here\n const compat = mobileClient();\n if (compat) rlog('rec-compat-start', { ts: Math.round(ts) });\n const s = new WebRtcSession(this.api, { camId: this.camId, mode: 'recorded', startMs: ts, compat }, {\n onStream: (ms) => {\n if (this.rw !== s || this.live) return;\n try { s.pc?.getReceivers().forEach(r => { try { (r as any).jitterBufferTarget = 500; } catch { /* ignore */ } try { (r as any).playoutDelayHint = 0.5; } catch { /* ignore */ } }); } catch { /* ignore */ }\n this.setMjpeg(false); this.v.muted = !this.soundOn || this.rate !== 1;\n try { this.v.removeAttribute('src'); } catch { /* ignore */ } try { this.v.srcObject = ms; } catch { /* ignore */ }\n this.fcArm(); this.rwBase = null; this.safePlay(); this.setLabel('playing');\n },\n onFail: () => { if (this.rw === s) this.recFallbackMse(ts); },\n onSessionId: () => { if (this.rw === s && this.rwPending) { const p = this.rwPending; this.rwPending = null; if (Math.abs(p.ts - this.rwStartMs) > 1500) { if (p.mark) this.freezeCurrent(); this.recRelaySeek(p.ts, p.rate, p.srate, p.mark); } } },\n });\n this.sessFrames0 = this.presentedFrames(); this.shownW = 0;\n this.rw = s; s.start(); this.startRelayPoll(); this.emit();\n }\n /** Relay failed: retry the relay up to twice (transient WS/ICE hiccups), only then fall back to MSE for the rest of this camera. */\n private recFallbackMse(ts: number): void {\n this.recWebrtcTeardown();\n if (this.live || this.destroyed) return;\n this.recoveries++;\n if (this.recoveries <= 2) { rlog('relay-retry', { n: this.recoveries }); this.recWebrtcStart(ts); return; }\n rlog('rec-fallback-mse', { mseOk: this.mseSupported(), after: this.recoveries }); this.recWebrtcDisabled = true; this.playAt(ts, {});\n }\n /** Hard server-side seek, coalesced: one in flight, latest wins, 150 ms floor. `mark` = a user jump with a still picture\n * (see SWAP_MS): the server answers with the marker width the new position arrives with. */\n private recRelaySeek(ts: number, rate = 1, srate = 1, mark = false): void {\n const s = this.rw; if (!s?.id) return;\n if (this.rwSeekBusy) { this.rwPending = { ts, rate, srate, mark: mark || !!this.rwPending?.mark }; return; }\n if (!mark && this.rwLastSeekTs === ts && this.rwRate === rate && this.rwSrate === srate && Date.now() - this.rwLastSeekAt < 1000) return;\n const wait = 150 - (Date.now() - this.rwLastSeekAt);\n if (wait > 0) { this.rwSeekBusy = true; this.rwPending = { ts, rate, srate, mark: mark || !!this.rwPending?.mark }; window.setTimeout(() => { this.rwSeekBusy = false; const p = this.rwPending; this.rwPending = null; if (p && this.rw?.id) this.recRelaySeek(p.ts, p.rate, p.srate, p.mark); }, wait); return; }\n if (mark) { this.rwScrub = false; if (this.scrubOffT) { clearTimeout(this.scrubOffT); this.scrubOffT = 0; } this.scrubMoves = 0; } // the server leaves the scrub profile for a marked seek\n this.rwStartMs = ts; this.rwSrate = srate; this.rwRate = this.rwScrub ? srate : rate; this.rwLastSeekTs = ts; this.rwLastSeekAt = Date.now();\n this.cad.lastNew = Date.now(); this.wdLastCt = -1; this.wdLastAt = Date.now(); this.wdGrace = Date.now() + 5000;\n this.rwPosTs = ts; this.rwPosAt = Date.now();\n this.setLabel(this.rwScrub ? 'scrub' : 'loading'); // scrubbing seeks constantly — no \"loading\" flicker there\n this.rwSeekBusy = true;\n this.seekTarget = ts; this.seekAt = Date.now(); this.cmdSeq++;\n this.swapPending = true; this.swapW = 0; this.swapAt = Date.now(); if (this.swapT) { clearTimeout(this.swapT); this.swapT = 0; }\n const seq = this.cmdSeq;\n const done = (ok: boolean, w: number) => {\n this.rwSeekBusy = false; if (!ok) { this.relayRecover(); return; }\n if (this.swapPending && seq === this.cmdSeq) {\n if (w) { this.swapW = w; if (this.shownW === w) this.swapVisible('marker'); } // marker path (see SWAP_MS)\n else this.swapArm(); // server without markers: timer\n }\n const p = this.rwPending; this.rwPending = null; if (p && this.rw?.id) this.recRelaySeek(p.ts, p.rate, p.srate, p.mark);\n };\n const q = `api/relay-seek?session=${encodeURIComponent(s.id)}&start=${Math.round(ts)}&rate=${rate}&srate=${srate}` + (mark ? `&mark=1&avoid=${this.shownW || this.v.videoWidth || 0}` : '');\n fetch(this.api.url(q), { cache: 'no-store' })\n .then(r => { if (!r.ok) return done(false, 0); if (r.status === 200) return r.json().then((j: any) => done(true, Number(j?.w) || 0), () => done(true, 0)); return done(true, 0); })\n .catch(() => done(false, 0));\n }\n /** Speed button: the server changes its base rate in place (api/relay-speed) — no reposition, no \"loading\", no still.\n * Servers without the endpoint (404) get the former seek to the displayed position. */\n private recRelaySpeed(r: number): void {\n const s = this.rw; if (!s?.id) return;\n const c = this.currentTs(); if (c != null) { this.rwPosTs = c; this.rwPosAt = Date.now(); }\n if (!this.rwScrub) this.rwRate = r;\n this.cmdSeq++; this.wdGrace = Date.now() + 5000; this.cad.lastNew = Date.now();\n this.api.control(`api/relay-speed?session=${encodeURIComponent(s.id)}&rate=${r}`).then(ok => { if (!ok && this.rw === s && s.id) this.recRelaySeek(c ?? this.rwStartMs, r); });\n }\n /** Scrub target (timeline centre), coalesced: one in flight, latest wins, 120 ms floor, 250 ms minimum step. */\n private recRelayTarget(ts: number): void {\n const s = this.rw; if (!s?.active || !s.id) return;\n if (this.rwTargetBusy) { this.rwPendingTarget = ts; return; }\n if (Math.abs(ts - this.rwLastTarget) < TARGET_MIN_STEP_MS) return;\n const wait = TARGET_FLOOR_MS - (Date.now() - this.rwLastTargetAt);\n if (wait > 0) { this.rwTargetBusy = true; this.rwPendingTarget = ts; window.setTimeout(() => { this.rwTargetBusy = false; const p = this.rwPendingTarget; this.rwPendingTarget = null; if (p != null && this.rw?.id) this.recRelayTarget(p); }, wait); return; }\n this.rwLastTarget = ts; this.rwLastTargetAt = Date.now(); // no cmdSeq bump: the position moves continuously, polls stay valid\n this.wdGrace = Date.now() + 8000; this.cad.lastNew = Date.now();\n this.rwTargetBusy = true;\n this.api.control(`api/relay-target?session=${encodeURIComponent(s.id)}&ts=${Math.round(ts)}`).then(ok => { if (!ok) this.relayRecover(); }).then(() => { this.rwTargetBusy = false; const p = this.rwPendingTarget; this.rwPendingTarget = null; if (p != null && this.rw?.id && Math.abs(p - this.rwLastTarget) >= TARGET_MIN_STEP_MS) this.recRelayTarget(p); });\n }\n /** profile on/off; `off` also ends the server's target steering, so it is sent even when the profile was never entered\n * (single-notch gesture) as long as the gesture steered (`force`) */\n private recRelayScrub(on: boolean, force = false): void {\n const s = this.rw; if (!s?.active || !s.id) return;\n if (this.rwScrub === on && !(force && !on)) return;\n this.rwScrub = on;\n this.cmdSeq++;\n if (!on) { const c = this.currentTs(); this.rwSrate = 1; this.rwRate = this.rate; if (c != null) { this.rwPosTs = c; this.rwPosAt = Date.now(); } if (this.label === 'scrub') this.setLabel('playing'); }\n this.wdLastCt = -1; this.wdLastAt = Date.now(); this.wdGrace = Date.now() + 5000; this.cad.lastNew = Date.now();\n this.api.control(`api/relay-scrub?session=${encodeURIComponent(s.id)}&on=${on ? 1 : 0}`).then(ok => { if (!ok) this.relayRecover(); });\n }\n private relayRecover(): void {\n if (!this.rw?.active) return;\n const t = this.rwPosTs ?? this.rwStartMs;\n this.recoveries++; rlog('relay-recover', { n: this.recoveries });\n if (this.recoveries > 2) { this.recoveries--; this.recFallbackMse(t); return; } // hand-over: recFallbackMse counts once more\n this.recWebrtcStart(t);\n }\n private startRelayPoll(): void {\n if (this.relayPoll) return;\n this.cadStart(); this.wdLastCt = -1; this.wdLastAt = Date.now(); this.wdDead = 0; this.wdGrace = Date.now() + 8000;\n this.relayPoll = window.setInterval(() => {\n const s = this.rw; const v = this.v; if (!s?.active || !s.id) return;\n const q = this.presentedFrames();\n if (v.paused && !this.recPaused && !document.hidden) { if (!this.wdResumeLogged) { this.wdResumeLogged = true; rlog('auto-resume', { rs: v.readyState }); } this.safePlay(); } else if (!v.paused) this.wdResumeLogged = false;\n if (!v.paused && !document.hidden && this.rwBase != null) {\n if (q !== this.wdLastCt) { this.wdLastCt = q; this.wdLastAt = Date.now(); this.recoveries = 0; if (!this.posterUntilSeek) this.freezeLift(); if (this.label === 'loading' && !this.swapPending) this.setLabel('playing'); }\n else if (this.rwScrub) this.wdLastAt = Date.now();\n else if (Date.now() - this.wdLastAt > 4000 && Date.now() > this.wdGrace) {\n this.wdLastAt = Date.now();\n const o: any = { ct: Math.round(v.currentTime * 10) / 10, paused: v.paused, muted: v.muted, rs: v.readyState, pf: q, w: v.videoWidth };\n try { s.pc?.getStats().then(st => { st.forEach((r: any) => { if (r.type === 'inbound-rtp' && (r.kind || r.mediaType) === 'video') { o.recv = r.framesReceived; o.dec = r.framesDecoded; o.drop = r.framesDropped; o.pli = r.pliCount; } }); rlog('stall-snap', o); }).catch(() => { /* ignore */ }); } catch { /* ignore */ }\n this.relayRecover(); return;\n }\n } else { this.wdLastCt = q; this.wdLastAt = Date.now(); }\n const seq = this.cmdSeq;\n fetch(this.api.url(`api/relay-pos?session=${encodeURIComponent(s.id)}`), { cache: 'no-store' }).then(r => r.json()).then((d: any) => {\n if (seq !== this.cmdSeq) return; // answered across a seek/rate change → stale\n if (d && d.t > 0 && Date.now() - this.seekAt < 2500 && Math.abs(d.t - this.seekTarget) > 5000) return; // pre-swap position\n if (d && d.t > 0) { this.wdDead = 0; this.rwPosTs = d.t; this.rwPosAt = Date.now(); if ((this.rwScrub || this.scrubMoves > 0) && typeof d.r === 'number' && isFinite(d.r) && d.r) this.rwRate = d.r; this.emit(); }\n else if (d && d.t <= 0) { if (++this.wdDead >= 3) { this.wdDead = 0; this.relayRecover(); } }\n }).catch(() => { /* ignore */ });\n }, 600);\n }\n private stopRelayPoll(): void { this.cadStop(); if (this.relayPoll) { clearInterval(this.relayPoll); this.relayPoll = undefined; } }\n private cadStart(): void {\n this.cadStop(); const C = this.cad; C.last = -1; C.frames0 = -1; C.stalls = 0; C.maxStall = 0; C.gapMax = 0; C.t0 = Date.now();\n C.t = window.setInterval(() => {\n if (!this.rw?.active || document.hidden) return;\n const q = this.presentedFrames(), now = Date.now();\n if (this.rwScrub) { C.last = q; C.lastNew = now; return; }\n if (C.frames0 < 0) { C.frames0 = q; C.last = q; C.lastNew = now; return; }\n if (q === C.frames0 && C.last === C.frames0) { C.lastNew = now; return; } // connect phase: no frame yet, not a stall\n if (q > C.last) { const gap = now - C.lastNew; if (gap > C.gapMax) C.gapMax = gap; if (gap >= 400) { C.stalls++; if (gap > C.maxStall) C.maxStall = gap; } C.last = q; C.lastNew = now; }\n if (now - C.t0 >= 30000) {\n const rep: any = { sec: Math.round((now - C.t0) / 1000), frames: C.last - C.frames0, stalls: C.stalls, maxStall: C.maxStall, gapMax: C.gapMax, w: this.v.videoWidth };\n C.t0 = now; C.frames0 = C.last; C.stalls = 0; C.maxStall = 0; C.gapMax = 0;\n const pc = this.rw?.pc;\n if (pc) pc.getStats().then(st => { st.forEach((r: any) => { if (r.type === 'inbound-rtp' && (r.kind || r.mediaType) === 'video') { rep.lost = r.packetsLost; rep.jit = Math.round((r.jitter || 0) * 1000); rep.recv = r.framesReceived; rep.dec = r.framesDecoded; rep.drop = r.framesDropped; } }); rlog('cadence', rep); }).catch(() => rlog('cadence', rep));\n else rlog('cadence', rep);\n }\n }, 100);\n }\n private cadStop(): void { if (this.cad.t) { clearInterval(this.cad.t); this.cad.t = 0; } }\n\n // ---- playAt: relay first, MSE/native fallback ------------------------------------------------\n playAt(ts: number, opts: { scrub?: boolean; srate?: number; noChase?: boolean } = {}): void {\n if (this.destroyed) return;\n const idx0 = this.clipIndexFor(ts);\n if (this.recWebrtcOk()) {\n this.chaseAbort();\n if (idx0 < 0) { this.setLabel('noRecording'); return; }\n this.recPaused = false;\n const t0 = Math.max(ts, this.clips[idx0]!.startTime);\n const jump = !opts.scrub; // a user jump (event, ±15 s, keys, date) — scrub landings are steered, not jumped\n if (this.rw?.active && this.rw.id) { if (jump) this.freezeCurrent(); this.recRelaySeek(t0, this.rate || 1, opts.srate || 1, jump); }\n else if (this.rw?.active && !this.live) this.rwPending = { ts: t0, rate: this.rate || 1, srate: opts.srate || 1, mark: jump };\n else { if (this.live) { this.freezeShow(true); this.exitLiveState(); } this.recWebrtcStart(t0); }\n return;\n }\n // ---- MSE fallback / native\n const canChase = !opts.noChase && !this.live && this.M.active && !this.recPaused && this.currentTs() != null && idx0 >= 0;\n this.chaseAbort();\n if (canChase && !opts.scrub) { this.startChase(ts); return; }\n if (idx0 < 0) { this.setLabel('noRecording'); return; }\n if (this.live) { this.freezeShow(true); this.exitLiveState(); }\n this.recPaused = false;\n const clip = this.clips[idx0]!; if (ts < clip.startTime) ts = clip.startTime;\n this.playIndex = idx0;\n this.v.muted = opts.scrub ? true : !this.soundOn;\n if (this.mseSupported()) {\n const t = (ts - this.M.base) / 1000;\n if (this.M.active && t >= 0 && (this.bufferedContains(t) || (t <= this.M.end + 0.5 && this.M.end - t < 95))) { try { this.v.currentTime = t; } catch { /* ignore */ } if (this.v.paused) this.safePlay(); this.feed(); }\n else { if (opts.scrub && Date.now() - this.lastLoad < 200) { this.pendingTs = ts; return; } this.lastLoad = Date.now(); this.mseStart(idx0, (ts - clip.startTime) / 1000); }\n } else {\n const off = Math.min(Math.max((ts - clip.startTime) / 1000, 0), (clip.duration || 0) / 1000);\n if (clip.id === this.curClipId && this.v.src) { try { this.v.currentTime = off; } catch { /* ignore */ } if (this.v.paused) this.safePlay(); }\n else { if (opts.scrub && Date.now() - this.lastLoad < 120) { this.pendingTs = ts; return; } this.freezeShow(); this.lastLoad = Date.now(); this.curClipId = clip.id; this.transport = 'native'; rlog('native-fallback', { clip: clip.id }); this.v.src = this.api.url(`api/segment?id=${encodeURIComponent(clip.videoId || clip.id)}`); this.v.load(); this.v.onloadedmetadata = () => { this.v.playbackRate = this.rate; try { this.v.currentTime = off; } catch { /* ignore */ } this.safePlay(); }; }\n }\n this.setLabel(opts.scrub ? 'scrub' : 'playing');\n }\n\n // ---- MSE recorded ------------------------------------------------------------------------\n private mseSupported(): boolean { try { return !!(this.api.corsMedia && MSCls && this.codecs && MSCls.isTypeSupported(`video/mp4; codecs=\"${this.codecs}\"`)); } catch { return false; } }\n private mseTeardown(): void { const M = this.M; M.active = false; M.nextIdx = -1; M.feeding = false; M.end = 0; M.pendingSeek = null; M.q = []; M.segFirst = false; try { M.abort?.abort(); } catch { /* ignore */ } M.abort = null; if (M.sb && M.ms && M.ms.readyState === 'open') { try { M.sb.abort(); } catch { /* ignore */ } } M.sb = null; M.ms = null; }\n private bufferedContains(t: number): boolean { try { const b = this.v.buffered; for (let i = 0; i < b.length; i++) if (t >= b.start(i) - 0.3 && t <= b.end(i) + 0.3) return true; } catch { /* ignore */ } return false; }\n private mseStart(idx: number, offSec: number): void {\n if (this.destroyed) return;\n this.v.onloadedmetadata = null;\n this.freezeShow(); this.mseTeardown();\n const M = this.M; const ms = new MSCls!(); M.ms = ms; M.active = true; M.base = this.clips[idx]!.startTime; M.nextIdx = idx; M.end = 0; M.mmsGo = true; this.transport = 'mse';\n if ((window as any).ManagedMediaSource && ms instanceof (window as any).ManagedMediaSource) { try { (this.v as any).disableRemotePlayback = true; } catch { /* ignore */ } ms.addEventListener('startstreaming', () => { M.mmsGo = true; this.feed(); }); ms.addEventListener('endstreaming', () => { M.mmsGo = false; }); }\n M.pendingSeek = offSec;\n const u = URL.createObjectURL(ms);\n ms.addEventListener('sourceopen', () => {\n URL.revokeObjectURL(u); if (M.ms !== ms) return;\n let sb: SourceBuffer; try { sb = ms.addSourceBuffer(`video/mp4; codecs=\"${this.codecs}\"`); } catch { this.codecs = null; M.active = false; return; }\n sb.mode = 'segments';\n sb.addEventListener('updateend', () => { if (M.pendingSeek != null && this.v.readyState >= 1) { const t0 = M.pendingSeek; M.pendingSeek = null; try { this.v.currentTime = t0; } catch { /* ignore */ } } this.drain(); if (!M.feeding && !M.q.length) this.feed(); });\n sb.addEventListener('error', () => { M.active = false; });\n M.sb = sb; try { this.v.currentTime = offSec; } catch { /* ignore */ } this.feed();\n });\n try { this.v.srcObject = null; } catch { /* ignore */ }\n this.v.src = u; this.v.playbackRate = this.rate; this.safePlay();\n }\n private drain(): void {\n const M = this.M; if (!M.active || !M.sb || M.sb.updating || !M.q.length) return;\n if (M.segFirst) { M.segFirst = false; try { M.sb.timestampOffset = M.segOff; } catch { try { M.sb.abort(); M.sb.timestampOffset = M.segOff; } catch { M.active = false; return; } } }\n const buf = M.q.shift()!;\n try { M.sb.appendBuffer(buf as BufferSource); } catch { try { M.sb.abort(); M.sb.appendBuffer(buf as BufferSource); } catch { M.active = false; } }\n }\n private feed(): void {\n const M = this.M; if (!M.active || M.feeding) return; if (M.mmsGo === false) return; if (M.nextIdx < 0 || M.nextIdx >= this.clips.length) return;\n if (M.end - this.v.currentTime > 90) return;\n try { const b = this.v.buffered; if (b.length && this.v.currentTime - b.start(0) > 240 && M.sb && !M.sb.updating && !M.q.length) { M.sb.remove(0, this.v.currentTime - 120); return; } } catch { /* ignore */ }\n const clip = this.clips[M.nextIdx]!, ms = M.ms;\n M.feeding = true; M.segFirst = true; M.segOff = (clip.startTime - M.base) / 1000; M.abort = new AbortController();\n fetch(this.api.url(`api/segment?id=${encodeURIComponent(clip.videoId || clip.id)}`), { credentials: 'same-origin', signal: M.abort.signal })\n .then(r => { if (!r.ok || !r.body) throw new Error(String(r.status)); const rd = r.body.getReader(); const loop = () => { rd.read().then(x => { if (M.ms !== ms || !M.active) return; if (x.done) { M.feeding = false; M.nextIdx++; M.end = M.segOff + (clip.duration || 60000) / 1000; if (!M.q.length) this.feed(); return; } M.q.push(x.value); this.drain(); loop(); }).catch(() => { if (M.ms === ms) M.feeding = false; }); }; loop(); })\n .catch(() => { if (M.ms !== ms) return; M.feeding = false; M.nextIdx++; this.feed(); });\n }\n private handleStall(): void { if (this.live || !this.M.active || this.v.paused) return; const t = this.v.currentTime; try { const b = this.v.buffered; for (let i = 0; i < b.length; i++) if (b.start(i) > t && b.start(i) - t < 60) { this.v.currentTime = b.start(i) + 0.05; return; } } catch { /* ignore */ } if (this.M.nextIdx >= this.clips.length) this.opts.onClipsRefresh().then(c => { const cur = this.clips[this.M.nextIdx - 1]; this.clips = c; if (cur) { const i = c.findIndex(x => x.id === cur.id); if (i >= 0) this.M.nextIdx = i + 1; } this.feed(); }).catch(() => { /* ignore */ }); else this.feed(); }\n // trick-play chase inside the MSE buffer\n private chaseAbort(): void { if (!this.CH.active) return; this.CH.active = false; if (this.CH.timer) { clearInterval(this.CH.timer); this.CH.timer = 0; } this.v.playbackRate = this.rate; this.v.muted = !this.soundOn; }\n private endChase(): void { const tgt = this.CH.target; this.chaseAbort(); try { this.v.currentTime = (tgt - this.M.base) / 1000; } catch { /* ignore */ } this.setLabel('playing'); if (this.v.paused) this.safePlay(); }\n private startChase(target: number): void {\n this.chaseAbort(); this.freezeHide(); this.CH.active = true; this.CH.target = target; try { this.v.pause(); } catch { /* ignore */ } this.v.muted = true; this.setLabel('scrub');\n this.CH.timer = window.setInterval(() => {\n if (!this.CH.active) return; const c = this.currentTs(); if (c == null) { this.endChase(); return; }\n const rem = this.CH.target - c; if (Math.abs(rem) <= 250) { this.endChase(); return; }\n let step = rem * 0.2; if (Math.abs(step) < 180) step = rem > 0 ? 180 : -180;\n const nt = c + step, tt = (nt - this.M.base) / 1000;\n if (this.M.active && this.bufferedContains(tt)) { try { this.v.currentTime = tt; } catch { /* ignore */ } this.feed(); } else { this.endChase(); this.playAt(this.CH.target, { noChase: true }); }\n }, 50);\n }\n\n // ---- controls -----------------------------------------------------------------------------\n togglePlayPause(): void {\n if (this.live) return;\n if (this.CH.active) { this.chaseAbort(); try { this.v.pause(); } catch { /* ignore */ } this.emit(); return; }\n if (this.recPaused) { this.recPaused = false; const t = this.recPausedTs ?? (this.currentTs() ?? Date.now() - 1000); this.playAt(t, {}); return; }\n if (this.rw?.active) { this.recPausedTs = this.currentTs(); this.freezeShow(); this.recWebrtcTeardown(); if (this.freezeT) { clearTimeout(this.freezeT); this.freezeT = 0; } this.freezeTok = null; /* the pause still stays until play */ try { this.v.pause(); } catch { /* ignore */ } this.recPaused = true; this.transport = 'none'; this.setLabel('paused'); return; }\n if (this.v.paused) this.safePlay(); else this.v.pause();\n }\n skip(ms: number): void { const ts = this.live ? Date.now() + ms : ((this.currentTs() ?? Date.now()) + ms); if (this.live && ms > 0) return; this.playAt(ts, {}); }\n cycleSpeed(): number {\n if (this.live) return this.rate;\n const rates = [1, 2, 4, 8]; this.rate = rates[(rates.indexOf(this.rate) + 1) % rates.length] ?? 1;\n if (this.rw?.active && this.rw.id) { this.recRelaySpeed(this.rate); this.v.muted = !this.soundOn || this.rate !== 1; }\n else this.v.playbackRate = this.rate;\n this.emit(); return this.rate;\n }\n setSound(on: boolean): void { this.soundOn = on; this.v.muted = !on || (!!this.rw?.active && this.rate !== 1); if (on && this.v.paused && !this.recPaused) this.safePlay(); this.emit(); }\n snapshot(): void {\n try {\n const src: any = this.live && !this.img.classList.contains('hidden') ? this.img : this.v;\n const w = src.videoWidth || src.naturalWidth || 1280, h = src.videoHeight || src.naturalHeight || 720;\n const cv = document.createElement('canvas'); cv.width = w; cv.height = h; cv.getContext('2d')!.drawImage(src, 0, 0, w, h);\n cv.toBlob(b => { if (!b) return; const a = document.createElement('a'); a.href = URL.createObjectURL(b); const ts = this.currentTs() ?? Date.now(); const d = new Date(ts); a.download = `${(this.camName || 'snapshot').replace(/[^\\w.-]+/g, '_')}_${String(d.getHours()).padStart(2, '0')}${String(d.getMinutes()).padStart(2, '0')}${String(d.getSeconds()).padStart(2, '0')}.jpg`; document.body.appendChild(a); a.click(); a.remove(); setTimeout(() => URL.revokeObjectURL(a.href), 4000); }, 'image/jpeg', 0.92);\n } catch { /* ignore */ }\n }\n private capLog(tag: string, extra?: object): void { try { const v: any = this.v, st: any = this.stage; rlog(tag, { fsReq: !!st.requestFullscreen, wkFs: !!st.webkitRequestFullscreen, vEnter: !!v.webkitEnterFullscreen, pipReq: !!v.requestPictureInPicture, wkPip: !!(v.webkitSupportsPresentationMode && v.webkitSupportsPresentationMode('picture-in-picture')), rs: v.readyState, vw: v.videoWidth, ...(extra || {}) }); } catch { /* ignore */ } }\n pip(): void {\n const v: any = this.v; this.capLog('pip-btn');\n try {\n if (document.pictureInPictureElement || v.webkitPresentationMode === 'picture-in-picture') { if (document.pictureInPictureElement) document.exitPictureInPicture().catch(() => { /* ignore */ }); else v.webkitSetPresentationMode('inline'); return; }\n if (this.v.classList.contains('hidden')) return;\n const wk = () => { try { if (v.webkitSupportsPresentationMode && v.webkitSupportsPresentationMode('picture-in-picture')) v.webkitSetPresentationMode('picture-in-picture'); else this.capLog('pip-unsupported'); } catch (e: any) { this.capLog('pip-fail', { e: String(e?.name || e) }); } };\n if (v.requestPictureInPicture) v.requestPictureInPicture().catch((e: any) => { this.capLog('pip-fail', { e: String(e?.name || e) }); wk(); }); else wk();\n } catch (e: any) { this.capLog('pip-fail', { e: String(e?.name || e) }); }\n }\n fullscreen(): void {\n const st: any = this.stage, v: any = this.v, d: any = document; this.capLog('fs-btn');\n try {\n if (d.fullscreenElement || d.webkitFullscreenElement) { (d.exitFullscreen || d.webkitExitFullscreen).call(d); return; }\n if (st.requestFullscreen) st.requestFullscreen().catch((e: any) => this.capLog('fs-fail', { e: String(e?.name || e) }));\n else if (st.webkitRequestFullscreen) st.webkitRequestFullscreen();\n else if (v.webkitEnterFullscreen && !this.v.classList.contains('hidden')) v.webkitEnterFullscreen();\n else this.capLog('fs-unsupported');\n } catch (e: any) { this.capLog('fs-fail', { e: String(e?.name || e) }); }\n }\n\n // ---- scrub (timeline gesture) ------------------------------------------------------------\n /** first gesture: scrub profile on (relay); MSE: freeze + pause */\n scrubBegin(): void {\n this.chaseAbort();\n if (this.scrubOffT) { clearTimeout(this.scrubOffT); this.scrubOffT = 0; } // gesture continues → stay in the scrub profile\n this.scrubMoves = 0;\n if (!this.rw?.active) { this.freezeShow(); if (!this.live) { try { this.v.pause(); } catch { /* ignore */ } } }\n // the scrub profile is entered by scrubMove on the first real movement (a single wheel notch = one in-place seek, no restarts)\n }\n /** true between the end of a gesture and the profile switch back (SCRUB_OFF_DELAY_MS): the timeline must not auto-follow\n * the playhead in that window — the servo is still converging on the centre the user left */\n scrubSettling(): boolean { return this.scrubOffT !== 0; }\n /** scroll position while the gesture runs: the centre becomes the server's steering target (velocity unused since 0.7.0) */\n scrubMove(centerTs: number, _vel: number, _smoothTs: number): void {\n if (!this.rw?.active) { this.freezeHold(); return; }\n if (!this.rw.id) return;\n // the 640 all-intra profile (two transcoder restarts per gesture) only for real scrubbing: a second movement of the\n // gesture or a big jump — a single wheel notch is steered in the normal profile\n const c = this.currentTs();\n if (++this.scrubMoves >= 2 || (c != null && Math.abs(centerTs - c) > 60000)) this.recRelayScrub(true);\n this.recRelayTarget(this.clampRange(centerTs));\n }\n /** release / hard landing: near now → live; relay in scrub → just the final target (no seek: the servo stops there);\n * MSE / no session → preview seek */\n scrubSeek(ts: number, srate = 1): void {\n if (this.nearNow(ts)) { this.goLive(); return; }\n if (this.rw?.active && this.rw.id && this.scrubMoves > 0) { this.recRelayTarget(this.clampRange(ts)); return; }\n this.playAt(this.clampRange(ts), { scrub: true, srate });\n }\n /** brief hold mid-gesture: nothing to do on the relay (the target already stands), MSE: preview seek */\n scrubHold(ts: number): void { if (!this.rw?.active) this.scrubSeek(ts); else if (this.rw.id) this.recRelayTarget(this.clampRange(ts)); }\n /** gesture settled → final target, then back to the normal profile after SCRUB_OFF_DELAY_MS of quiet (a new gesture cancels it) */\n scrubIdle(ts?: number): void {\n if (ts != null && this.rw?.active && this.rw.id && this.scrubMoves > 0) this.recRelayTarget(this.clampRange(ts));\n if (this.scrubOffT) clearTimeout(this.scrubOffT);\n this.scrubOffT = window.setTimeout(() => { this.scrubOffT = 0; const steered = this.scrubMoves > 0; this.scrubMoves = 0; this.recRelayScrub(false, steered); }, SCRUB_OFF_DELAY_MS);\n }\n\n // ---- visibility ---------------------------------------------------------------------------\n private hiddenTs: number | null = null;\n private onVisibility(): void {\n if (document.visibilityState === 'hidden') {\n // don't pin a camera stream in the background; live is simply restarted on return\n if (this.live) { this.hiddenTs = null; this.webrtcTeardown(); this.liveTeardown(); if (this.transport === 'mjpeg') this.img.removeAttribute('src'); }\n // the still stays while hidden (like pause): a hold-until-next-frame would be lifted by the last frame the torn-down\n // stream still presents, and the return would then copy a black picture from the dead element\n else if (this.rw?.active) { this.hiddenTs = this.currentTs(); this.freezeShow(); this.recWebrtcTeardown(); if (this.freezeT) { clearTimeout(this.freezeT); this.freezeT = 0; } this.freezeTok = null; }\n } else {\n if (this.live) this.goLive(); // also covers goLive() issued while hidden (background tab)\n else if (this.hiddenTs != null && !this.recPaused) { const t = this.hiddenTs; this.hiddenTs = null; this.playAt(t, {}); }\n }\n }\n}\n\n"],"mappings":";AAQA,IAAI,QAAQ;AAEZ,IAAI,SAAgC;AAE7B,SAAS,cAAc,GAA0B,GAAkB;AACxE,WAAS;AACT,MAAI,EAAG,SAAQ;AACjB;AAEO,SAAS,KAAK,KAAa,MAAsC;AACtE,MAAI,CAAC,OAAQ;AACb,MAAI;AACJ,MAAI;AACF,WAAO,KAAK,UAAU,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,MAAM,IAAI,UAAU,UAAU,MAAM,GAAG,EAAE,EAAE,CAAC;AAAA,EAChG,QAAQ;AACN,WAAO,KAAK,UAAU,EAAE,KAAK,GAAG,MAAM,CAAC;AAAA,EACzC;AACA,SAAO,SAAS,iB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kBAAkB;AAAG,YAAI,KAAK,SAAS;AAAE,uBAAa,KAAK,OAAO;AAAG,eAAK,UAAU;AAAA,QAAG;AAAE,aAAK,YAAY;AAAA,MAAM;AAAA,IACxM,OAAO;AACL,UAAI,KAAK,KAAM,MAAK,OAAO;AAAA,eAClB,KAAK,YAAY,QAAQ,CAAC,KAAK,WAAW;AAAE,cAAM,IAAI,KAAK;AAAU,aAAK,WAAW;AAAM,aAAK,OAAO,GAAG,CAAC,CAAC;AAAA,MAAG;AAAA,IAC1H;AAAA,EACF;AACF;","names":[]}
@@ -90,6 +90,11 @@ declare class PlayerController {
90
90
  private swapT;
91
91
  private posterFor;
92
92
  private scrubOffT;
93
+ private swapW;
94
+ private swapAt;
95
+ private shownW;
96
+ private sessFrames0;
97
+ private liftTok;
93
98
  private scrubMoves;
94
99
  private rwTargetBusy;
95
100
  private rwPendingTarget;
@@ -131,15 +136,24 @@ declare class PlayerController {
131
136
  /** Wall-clock position of the picture on screen (Scrypted's getRecordingStreamCurrentTime). */
132
137
  currentTs(): number | null;
133
138
  private fcArm;
139
+ /** a presented frame of width w: is it the first frame of the marked seek's new position? */
140
+ private markerCheck;
134
141
  presentedFrames(): number;
135
142
  private freezeArm;
143
+ /** a still is shown (again): cancel a pending lift, full opacity */
144
+ private stillUp;
145
+ /** New content is being presented → lift the still after LIFT_FRAMES more presented frames with a short fade (see
146
+ * LIFT_FRAMES). `frames` 0 = fade right away (MJPEG image loaded). A lift already under way is not restarted. */
147
+ private freezeLift;
136
148
  /** copy the current video picture onto the freeze canvas (false = nothing to copy yet) */
137
149
  private drawVideo;
150
+ /** Freeze the current picture. A still that is already visible stays (redrawing would copy from an element whose stream
151
+ * may already be gone → black) — it is only re-armed. */
138
152
  freezeShow(hold?: boolean): void;
139
- /** poster/freeze stays until the seek's picture is visible (swapVisible), 6 s safety net */
153
+ /** poster/freeze stays until the seek's picture is visible (swapVisible); safety net MARK_CAP_MS */
140
154
  private holdUntilSwap;
141
- /** Event click inside a running relay session: the current picture stands still at once (the old position must not keep
142
- * playing while the event frame loads); the event frame replaces it, the picture at the target lifts it. */
155
+ /** A jump inside a running relay session: the current picture stands still at once (the old position must not keep playing
156
+ * while the new one crosses the pipeline); an already visible still (event frame) is kept. Lifted by swapVisible. */
143
157
  freezeCurrent(): void;
144
158
  /** the picture of the last seek is on screen: lift a held poster, report playing */
145
159
  private swapVisible;
@@ -148,6 +162,7 @@ declare class PlayerController {
148
162
  freezeFromImage(img: HTMLImageElement, hold: boolean, untilSeek?: boolean, kind?: string): boolean;
149
163
  freezeHide(): void;
150
164
  private posterUp;
165
+ /** scrub on MSE: the still stays while the gesture runs (lifted by the seek's `seeked`/`playing`) */
151
166
  freezeHold(): void;
152
167
  /** Event click: the stored frame is the poster until the seek lands. */
153
168
  posterEvent(ts: number): void;
@@ -176,8 +191,12 @@ declare class PlayerController {
176
191
  private recWebrtcStart;
177
192
  /** Relay failed: retry the relay up to twice (transient WS/ICE hiccups), only then fall back to MSE for the rest of this camera. */
178
193
  private recFallbackMse;
179
- /** Hard server-side seek, coalesced: one in flight, latest wins, 150 ms floor. */
194
+ /** Hard server-side seek, coalesced: one in flight, latest wins, 150 ms floor. `mark` = a user jump with a still picture
195
+ * (see SWAP_MS): the server answers with the marker width the new position arrives with. */
180
196
  private recRelaySeek;
197
+ /** Speed button: the server changes its base rate in place (api/relay-speed) — no reposition, no "loading", no still.
198
+ * Servers without the endpoint (404) get the former seek to the displayed position. */
199
+ private recRelaySpeed;
181
200
  /** Scrub target (timeline centre), coalesced: one in flight, latest wins, 120 ms floor, 250 ms minimum step. */
182
201
  private recRelayTarget;
183
202
  /** profile on/off; `off` also ends the server's target steering, so it is sent even when the profile was never entered
@@ -1,4 +1,4 @@
1
- export { P as PlayerController, a as PlayerLabel, b as PlayerOptions, c as PlayerRefs, d as PlayerState } from '../controller-91737fq7.js';
1
+ export { P as PlayerController, a as PlayerLabel, b as PlayerOptions, c as PlayerRefs, d as PlayerState } from '../controller-C01h-VeS.js';
2
2
  import { e as SentinelClient } from '../client-Dtfs8TX2.js';
3
3
 
4
4
  /**
@@ -4,7 +4,7 @@ import {
4
4
  mobileClient,
5
5
  rlog,
6
6
  setRlogClient
7
- } from "../chunk-ECFTCXR4.js";
7
+ } from "../chunk-Z22KWFHI.js";
8
8
  export {
9
9
  PlayerController,
10
10
  WebRtcSession,
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
  import { e as SentinelClient, j as SentinelEventClass, l as SentinelRecentEvent, d as SentinelCamera, h as SentinelEvent, o as SentinelStats, f as SentinelClip } from '../client-Dtfs8TX2.js';
4
- import { d as PlayerState } from '../controller-91737fq7.js';
4
+ import { d as PlayerState } from '../controller-C01h-VeS.js';
5
5
 
6
6
  /**
7
7
  * Minimal translation core with the same dictionary semantics as HAPulse:
package/dist/ui/index.js CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  import {
20
20
  PlayerController,
21
21
  rlog
22
- } from "../chunk-ECFTCXR4.js";
22
+ } from "../chunk-Z22KWFHI.js";
23
23
 
24
24
  // src/ui/context.tsx
25
25
  import { createContext, useContext } from "react";
package/dist/ui/ui.css CHANGED
@@ -251,7 +251,9 @@
251
251
  the screen's aspect, so there contain is right. */
252
252
  .nvr-stage__video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
253
253
  .nvr-stage:fullscreen .nvr-stage__video, .nvr-stage:-webkit-full-screen .nvr-stage__video { object-fit: contain; }
254
- .nvr-stage__freeze { pointer-events: none; }
254
+ .nvr-stage__freeze { pointer-events: none; transition: opacity 120ms linear; }
255
+ /* lifting a still: fade out over the running video (see LIFT_FADE_MS in the player) */
256
+ .nvr-stage__freeze--fade { opacity: 0; }
255
257
  .nvr-stage .hidden { display: none !important; }
256
258
  .nvr-mute { position: absolute; right: 16px; bottom: 16px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-dim); display: grid; place-items: center; box-shadow: var(--shadow-elevated); cursor: pointer; z-index: 3; }
257
259
  .nvr-mute[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: transparent; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentinel-nvr/web",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Shared browser code for the Sentinel NVR plugin for Scrypted: API model + client (/api), player (/player) and React UI with i18n + themes (/ui). Consumed by the plugin's own web UI and the HAPulse dashboard.",
5
5
  "license": "MIT",
6
6
  "author": "Muggedadscher",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/player/rlog.ts","../src/player/webrtc.ts","../src/player/controller.ts"],"sourcesContent":["/**\n * Client telemetry → the plugin's `api/clientlog` → its server log as `[client]`\n * lines (phones have no console; this is how playback problems on a device get\n * diagnosed). `brand` tags which host emitted the line (e.g. 'sentinel', 'hapulse').\n */\n\nimport type { SentinelClient } from '../api';\n\nlet brand = 'web';\n\nlet client: SentinelClient | null = null;\n\nexport function setRlogClient(c: SentinelClient | null, b?: string): void {\n client = c;\n if (b) brand = b;\n}\n\nexport function rlog(tag: string, data?: Record<string, unknown>): void {\n if (!client) return;\n let line: string;\n try {\n line = JSON.stringify({ tag, b: brand, d: data ?? null, ua: navigator.userAgent.slice(0, 80) });\n } catch {\n line = JSON.stringify({ tag, b: brand });\n }\n client.postText('api/clientlog', line);\n}\n","/**\n * WebRTC session over the plugin's WebSocket signaling (docs/API.md §6).\n * Battle-tested flow: options first, createLocalDescription/setRemoteDescription\n * RPCs, trickle ICE, stream composed from ALL receivers (Safari attached an\n * audio-only stream forever when the audio track arrived first), fresh offer on\n * renegotiation, dec-check after connect with a one-time TURN-relay retry on a\n * media blackhole. The API client is injected (hosts may run on another origin).\n */\nimport type { SentinelClient } from '../api';\nimport { rlog } from './rlog';\n\nexport interface SessionCallbacks {\n onStream: (ms: MediaStream) => void;\n onFail: (reason: string) => void;\n onSessionId?: (id: string) => void;\n}\nexport interface SessionOptions { camId: string; mode: 'live' | 'recorded'; startMs?: number; compat?: boolean; forceRelay?: boolean; kind?: string; }\n\nlet forceRelayGlobal = false;\n\nexport function mobileClient(): boolean {\n return /iPhone|iPod|Android|Mobile/i.test(navigator.userAgent) || (navigator.maxTouchPoints > 1 && Math.min(screen.width || 9999, screen.height || 9999) < 920);\n}\nfunction rtcOptions() {\n let capabilities: unknown;\n try { capabilities = RTCRtpReceiver.getCapabilities ? { audio: RTCRtpReceiver.getCapabilities('audio'), video: RTCRtpReceiver.getCapabilities('video') } : undefined; } catch { /* none */ }\n return { userAgent: navigator.userAgent, capabilities, screen: { devicePixelRatio: window.devicePixelRatio || 1, width: screen.width || 1920, height: screen.height || 1080 } };\n}\n\nexport class WebRtcSession {\n ws: WebSocket | undefined; pc: RTCPeerConnection | undefined; id: string | undefined; active = false;\n private connectT: number | undefined; private trackSig = ''; private api: SentinelClient; private opts: SessionOptions; private cb: SessionCallbacks;\n constructor(api: SentinelClient, opts: SessionOptions, cb: SessionCallbacks) { this.api = api; this.opts = opts; this.cb = cb; }\n get connected(): boolean { const s = this.pc?.iceConnectionState; return s === 'connected' || s === 'completed'; }\n\n start(): void {\n const params: Record<string, string> = {};\n if (this.opts.mode === 'recorded') { params.mode = 'recorded'; params.start = String(Math.round(this.opts.startMs || 0)); }\n if (this.opts.compat ?? mobileClient()) params.compat = '1';\n let ws: WebSocket;\n try { ws = new WebSocket(this.api.signalingUrl(this.opts.camId, params)); } catch { this.cb.onFail('ws'); return; }\n this.ws = ws; this.active = true;\n this.connectT = window.setTimeout(() => {\n if (this.active && this.ws === ws && !this.connected) {\n rlog('connect-timeout', { kind: this.opts.mode, ice: this.pc?.iceConnectionState });\n if (!forceRelayGlobal) { forceRelayGlobal = true; rlog('retry-relay-only', { kind: this.opts.mode }); this.stop(); this.start(); return; }\n this.fail('timeout');\n }\n }, 12000);\n ws.onopen = () => { try { ws.send(JSON.stringify({ type: 'options', options: rtcOptions() })); } catch { /* ignore */ } };\n ws.onerror = () => { if (this.active && this.ws === ws && !this.pc) this.fail('ws-error'); };\n ws.onclose = () => { if (this.active && this.ws === ws && !this.connected) this.fail('ws-closed'); };\n ws.onmessage = (ev) => {\n let msg: any; try { msg = JSON.parse(ev.data); } catch { return; }\n if (msg.type === 'createLocalDescription') this.createLocal(ws, msg);\n else if (msg.type === 'setRemoteDescription') this.setRemote(ws, msg);\n else if (msg.type === 'addIceCandidate') this.pc?.addIceCandidate(msg.candidate).catch(() => { /* ignore */ });\n else if (msg.type === 'sessionStarted') { this.id = msg.id; this.cb.onSessionId?.(msg.id); }\n else if (msg.type === 'error') { if (this.active && this.ws === ws) this.fail(msg.reason || 'error'); }\n };\n }\n\n stop(): void {\n this.active = false;\n if (this.connectT) { clearTimeout(this.connectT); this.connectT = undefined; }\n try { if (this.ws) { this.ws.onmessage = null; this.ws.onclose = null; this.ws.onerror = null; this.ws.close(); } } catch { /* ignore */ }\n try { if (this.pc) { this.pc.ontrack = null; this.pc.oniceconnectionstatechange = null; this.pc.onicecandidate = null; this.pc.close(); } } catch { /* ignore */ }\n this.ws = undefined; this.pc = undefined; this.id = undefined; this.trackSig = '';\n }\n\n private fail(reason: string): void { if (!this.active) return; this.stop(); this.cb.onFail(reason); }\n\n private ensurePc(setup: any): RTCPeerConnection {\n if (this.pc) return this.pc;\n let cfg: RTCConfiguration = (setup && setup.configuration) || { iceServers: [{ urls: 'stun:stun.l.google.com:19302' }] };\n if (forceRelayGlobal) cfg = { ...cfg, iceTransportPolicy: 'relay' };\n const pc = new RTCPeerConnection(cfg);\n this.pc = pc;\n if (setup?.datachannel) { try { const dc = pc.createDataChannel(setup.datachannel.label, setup.datachannel.dict); dc.binaryType = 'arraybuffer'; } catch { /* ignore */ } }\n if (setup?.audio) { try { pc.addTransceiver('audio', { direction: setup.audio.direction || 'recvonly' }); } catch { /* ignore */ } }\n if (setup?.video) { try { pc.addTransceiver('video', { direction: setup.video.direction || 'recvonly' }); } catch { /* ignore */ } }\n pc.ontrack = () => {\n if (!this.active || this.pc !== pc) return;\n const ms = new MediaStream();\n pc.getReceivers().forEach(r => { if (r.track) ms.addTrack(r.track); });\n if (!ms.getVideoTracks().length) return; // audio-first: wait for the video event\n const sig = ms.getTracks().map(t => t.id).sort().join(',');\n if (this.trackSig === sig) return;\n this.trackSig = sig;\n this.cb.onStream(ms);\n };\n pc.oniceconnectionstatechange = () => {\n if (!this.active || this.pc !== pc) return;\n const st = pc.iceConnectionState;\n if (st === 'connected' || st === 'completed') {\n if (this.connectT) { clearTimeout(this.connectT); this.connectT = undefined; }\n window.setTimeout(() => {\n if (!this.active || this.pc !== pc) return;\n pc.getStats().then(s => {\n let dec = -1, recv = -1, vBytes = -1, aBytes = -1;\n s.forEach((r: any) => {\n if (r.type === 'inbound-rtp' && (r.kind || r.mediaType) === 'video') { dec = r.framesDecoded || 0; recv = r.framesReceived ?? -1; vBytes = r.bytesReceived || 0; }\n if (r.type === 'inbound-rtp' && (r.kind || r.mediaType) === 'audio') aBytes = r.bytesReceived || 0;\n });\n if (dec <= 0) {\n rlog('dec-check-fail', { kind: this.opts.mode, dec, recv, vBytes, aBytes, relayForced: forceRelayGlobal });\n if (!forceRelayGlobal && vBytes <= 0 && aBytes <= 0) { forceRelayGlobal = true; rlog('retry-relay-only', { kind: this.opts.mode }); this.stop(); this.start(); return; }\n this.fail('no-decode');\n }\n else rlog('dec-ok', { kind: this.opts.mode, dec, relayForced: forceRelayGlobal });\n }).catch(() => { /* ignore */ });\n }, this.opts.mode === 'live' ? 5000 : 9000);\n }\n if (st === 'failed') { rlog('ice-failed', { kind: this.opts.mode }); this.fail('ice-failed'); }\n };\n return pc;\n }\n\n private createLocal(ws: WebSocket, msg: any): void {\n const pc = this.ensurePc(msg.setup);\n const mid = this.connected;\n if (mid) rlog('reneg', { dtype: msg.dtype, kind: this.opts.mode });\n const reply = (desc: RTCSessionDescriptionInit) => { try { ws.send(JSON.stringify({ type: 'response', reqId: msg.reqId, description: { type: desc.type, sdp: desc.sdp } })); } catch { /* ignore */ } };\n pc.onicecandidate = (ev) => { if (ev.candidate) { try { ws.send(JSON.stringify({ type: 'iceCandidate', candidate: JSON.parse(JSON.stringify(ev.candidate)) })); } catch { /* ignore */ } } };\n const p = msg.dtype === 'offer'\n ? pc.createOffer({ offerToReceiveAudio: !!msg.setup?.audio, offerToReceiveVideo: !!msg.setup?.video }).then(o => pc.setLocalDescription(o).then(() => reply(o)))\n : pc.createAnswer().then(a => pc.setLocalDescription(a).then(() => reply(a)));\n p.catch(e => { rlog('createLocal-fail', { dtype: msg.dtype, name: e?.name, mid }); if (!mid) this.fail('createLocal'); });\n }\n\n private setRemote(ws: WebSocket, msg: any): void {\n const pc = this.ensurePc(msg.setup);\n const mid = this.connected;\n pc.setRemoteDescription(msg.description)\n .then(() => { try { ws.send(JSON.stringify({ type: 'response', reqId: msg.reqId, ok: true })); } catch { /* ignore */ } })\n .catch(e => { rlog('sRD-fail', { name: e?.name, mid }); try { ws.send(JSON.stringify({ type: 'response', reqId: msg.reqId, ok: false })); } catch { /* ignore */ } if (!mid) this.fail('sRD'); });\n }\n}\n","/**\n * PlayerController — the whole playback brain of the NVR. Framework-free: it owns\n * a <video>, a freeze <canvas> and an MJPEG <img> inside a stage element, and\n * reports state through `onState`; the host only renders what it says.\n *\n * Host seams: the API client is injected; status labels are i18n KEY suffixes\n * (`nvr.player.<label>`) the host translates; `storagePrefix` namespaces the\n * remembered stage aspect per camera; `brand` tags telemetry lines. The MSE paths\n * are gated on `SentinelClient.corsMedia`; posters load with crossOrigin so the\n * freeze canvas stays untainted. The host CSS must define a `.hidden` class.\n *\n * Paths: LIVE = WebRTC (sink) → MSE live (fMP4, no audio) → MJPEG <img>.\n * RECORDED = WebRTC relay (server-seekable, scrub time-lapse in place) →\n * MSE fallback (progressive segments, trick-play chase) → native <video src>.\n */\nimport type { SentinelClip as Clip, SentinelClient } from '../api';\nimport { rlog, setRlogClient } from './rlog';\nimport { WebRtcSession, mobileClient } from './webrtc';\n\n/** `label` is an i18n key suffix: nvr.player.<label> */\nexport type PlayerLabel = 'live' | 'liveWebrtc' | 'liveMse' | 'liveMjpeg' | 'loading' | 'playing' | 'paused' | 'scrub' | 'noRecording' | '';\nexport interface PlayerState {\n live: boolean; label: PlayerLabel; playhead: number | null; rate: number; sound: boolean; paused: boolean;\n transport: 'webrtc' | 'mse' | 'mjpeg' | 'relay' | 'native' | 'none'; muted: boolean;\n}\nexport interface PlayerRefs { video: HTMLVideoElement; freeze: HTMLCanvasElement; img: HTMLImageElement; stage: HTMLElement; }\nexport interface PlayerOptions {\n onState: (s: PlayerState) => void;\n onClipsRefresh: () => Promise<Clip[]>;\n /** localStorage key prefix for the remembered stage aspect per camera (default 'snvr-ar-'). */\n storagePrefix?: string;\n /** telemetry brand tag written into api/clientlog lines (default 'web'). */\n brand?: string;\n}\ntype Opts = PlayerOptions;\n\nconst MSCls: typeof MediaSource | undefined = (window as any).ManagedMediaSource || window.MediaSource;\n/** Seek → picture. Measured in the lab (scripts/seek-swap-test.js + RTSP tap, 23.09.2026, 14 seeks): the relay answers a seek\n * after ~10 ms, the NEW position leaves mediamtx ~1.08 s later and reaches the screen after 2.2–2.6 s (sink ffmpeg + 500 ms\n * jitter buffer + render). Until then the OLD position keeps playing — a poster (event frame / frozen picture) must stay up that\n * long, else old frames flash through (\"springt hin und her\"). A profile switch does NOT reset this latency (measured). */\nconst SWAP_MS = 2600;\n/** Scrub profile (640 all-intra) → normal (1280) only after the gesture has been quiet this long: a scroll–pause–scroll pattern\n * restarted the transcoder twice per pause (server log: profile switch every 1–2 s, 30 restarts in one session). */\nconst SCRUB_OFF_DELAY_MS = 1500;\n/** hold mid-gesture: seek only if the playhead is further than this from the centre; idle: land if further than this */\n/** Scrub by TARGET (since 0.7.0): while the user scrubs, the client sends the timeline centre (api/relay-target, coalesced) and\n * the server's feeder steers its cursor onto it and stops there. No client-side rate estimate, no hold/landing seeks — those\n * overshot by (reaction time × rate) and then jumped back, and every seek shows 2.4 s of stale stream first. */\nconst TARGET_FLOOR_MS = 120, TARGET_MIN_STEP_MS = 250;\n\nexport class PlayerController {\n private v!: HTMLVideoElement; private fz!: HTMLCanvasElement; private img!: HTMLImageElement; private stage!: HTMLElement;\n private api: SentinelClient; private opts: Opts;\n camId = ''; camName = ''; clips: Clip[] = []; codecs: string | null = null; rangeStart = 0; rangeEnd = 0;\n live = false; rate = 1; soundOn = false; recPaused = false; recPausedTs: number | null = null;\n recWebrtcDisabled = false; label: PlayerLabel = ''; transport: PlayerState['transport'] = 'none';\n // relay session (RW)\n private rw: WebRtcSession | undefined; private rwStartMs = 0; private rwBase: number | null = null; private rwPosTs: number | null = null; private rwPosAt = 0;\n private rwRate = 1; private rwSrate = 1; private rwScrub = false; private rwSeekBusy = false; private rwPending: { ts: number; rate: number; srate: number } | null = null;\n private rwLastSeekTs: number | null = null; private rwLastSeekAt = 0;\n private relayPoll: number | undefined; private wdLastCt = -1; private wdLastAt = 0; private wdDead = 0; private wdGrace = 0; private wdResumeLogged = false; private recoveries = 0;\n private posterUntilSeek = false; private seekTarget = 0;\n // seek → visible swap (see SWAP_MS); posterFor = event the pending poster belongs to; scrubOffT = delayed profile switch\n private swapPending = false; private swapFrames = -1; private swapT = 0; private posterFor = 0; private scrubOffT = 0;\n private scrubMoves = 0; private rwTargetBusy = false; private rwPendingTarget: number | null = null; private rwLastTarget = 0; private rwLastTargetAt = 0;\n // relay-pos answers are only valid for the command generation they were asked under; a poll sent BEFORE a\n // seek/rate change and answered after it would drag the playhead back to the old position (and the\n // auto-follow timeline with it → visible back-and-forth). seekAt: the server may still report the pre-swap\n // position for a moment after a seek — ignore far-off values in that window.\n private cmdSeq = 0; private seekAt = 0;\n // live session (W) + live MSE (L)\n private w: WebRtcSession | undefined; private L = { active: false, ms: null as MediaSource | null, sb: null as SourceBuffer | null, abort: null as AbortController | null, queue: [] as Uint8Array[], restarts: 0, lastTrim: 0, stallT: 0 };\n // recorded MSE (M)\n private M = { ms: null as MediaSource | null, sb: null as SourceBuffer | null, base: 0, nextIdx: -1, end: 0, active: false, feeding: false, abort: null as AbortController | null, q: [] as Uint8Array[], segFirst: false, segOff: 0, pendingSeek: null as number | null, mmsGo: true };\n private CH = { active: false, target: 0, timer: 0 };\n private curClipId: string | null = null; private playIndex = -1; private lastLoad = 0; private pendingTs: number | null = null; private pendingT: number | undefined;\n // frame counter / freeze\n private fc = { n: 0, tok: {} as object }; private freezeT = 0; private freezeTok: object | null = null;\n private cad = { t: 0, last: -1, lastNew: 0, stalls: 0, maxStall: 0, frames0: -1, t0: 0, gapMax: 0 };\n private stallTimer = 0; private destroyed = false; private liveRestartT = 0;\n private unlisten: (() => void)[] = [];\n\n private arPrefix: string;\n constructor(api: SentinelClient, opts: Opts) { this.api = api; this.opts = opts; this.arPrefix = opts.storagePrefix ?? 'snvr-ar-'; setRlogClient(api, opts.brand); }\n\n attach(r: PlayerRefs): void {\n this.v = r.video; this.fz = r.freeze; this.img = r.img; this.stage = r.stage;\n const v = this.v;\n const on = (n: string, f: () => void) => { v.addEventListener(n, f); this.unlisten.push(() => v.removeEventListener(n, f)); };\n on('timeupdate', () => { if (this.live) return; if (this.rw?.active && this.rwBase == null && v.currentTime > 0) this.rwBase = v.currentTime; const ts = this.currentTs(); if (ts == null) return; if (this.M.active || this.rw?.active) { const i = this.clipIndexFor(ts); if (i >= 0) this.playIndex = i; } this.feed(); this.emit(); });\n on('waiting', () => { if (this.live) { if (this.L.active && !this.L.stallT) this.L.stallT = window.setTimeout(() => { this.L.stallT = 0; if (this.live && this.L.active && v.readyState < 3) this.liveRestart(); }, 4000); return; } if (!this.rw?.active) this.setLabel('loading'); if (!this.M.active || this.stallTimer) return; this.stallTimer = window.setTimeout(() => { this.stallTimer = 0; this.handleStall(); }, 600); });\n on('seeking', () => { if (!this.live && !this.rw?.active) this.setLabel('loading'); });\n for (const n of ['loadeddata', 'playing', 'canplay', 'seeked']) on(n, () => { if (v.videoWidth) this.freezeHide(); if (!this.live && this.label === 'loading') this.setLabel('playing'); if (this.L.stallT) { clearTimeout(this.L.stallT); this.L.stallT = 0; } this.emit(); });\n on('pause', () => { if (this.L.stallT) { clearTimeout(this.L.stallT); this.L.stallT = 0; } this.emit(); });\n on('play', () => this.emit());\n // the stage box follows the picture's real aspect where the layout uses it (mobile: no letterbox bars for 4:3 cameras)\n on('loadedmetadata', () => this.setAspect(this.v.videoWidth, this.v.videoHeight));\n on('resize', () => this.setAspect(this.v.videoWidth, this.v.videoHeight));\n on('volumechange', () => this.emit());\n on('error', () => { const e = v.error; rlog('video-error', { code: e?.code, msg: e?.message?.slice(0, 120), src: v.getAttribute('src') ? 'src' : 'srcObject' }); });\n on('ended', () => { if (this.live || this.M.active || this.rw?.active) return; const n = this.playIndex + 1; if (n < this.clips.length) { const c = this.clips[n]!; this.curClipId = c.id; this.playIndex = n; v.src = this.api.url(`api/segment?id=${encodeURIComponent(c.videoId || c.id)}`); v.load(); v.onloadedmetadata = () => { v.playbackRate = this.rate; try { v.currentTime = 0; } catch { /* ignore */ } this.safePlay(); }; this.setLabel('playing'); } });\n this.pendingT = window.setInterval(() => { if (this.pendingTs != null && Date.now() - this.lastLoad >= 200) { const t = this.pendingTs; this.pendingTs = null; this.playAt(t, { scrub: true }); } }, 120);\n const vis = () => this.onVisibility(); document.addEventListener('visibilitychange', vis); this.unlisten.push(() => document.removeEventListener('visibilitychange', vis));\n const edge = window.setInterval(() => { if (this.live && this.L.active) this.liveEdge(); }, 1000); this.unlisten.push(() => clearInterval(edge));\n }\n\n destroy(): void {\n this.destroyed = true;\n // no path may (re)start a stream on a destroyed controller: the 1-s live\n // restart timer, a pending async load in the host, a visibility change …\n this.live = false; this.recPaused = false;\n if (this.liveRestartT) { clearTimeout(this.liveRestartT); this.liveRestartT = 0; }\n this.recWebrtcTeardown(); this.webrtcTeardown(); this.mseTeardown(); this.liveTeardown(); this.chaseAbort();\n if (this.pendingT) clearInterval(this.pendingT);\n for (const u of this.unlisten) u();\n try { this.v.pause(); this.v.srcObject = null; this.v.removeAttribute('src'); } catch { /* ignore */ }\n }\n\n setCamera(camId: string, name: string): void {\n if (camId !== this.camId) { this.recWebrtcDisabled = false; this.recoveries = 0; }\n this.camId = camId; this.camName = name;\n // last known picture aspect of this camera: the stage has the right shape before any poster/video arrives\n let ar = ''; try { ar = localStorage.getItem(this.arPrefix + camId) || ''; } catch { /* ignore */ }\n if (ar) this.stage.style.setProperty('--stage-ar', ar); else this.stage.style.removeProperty('--stage-ar');\n }\n /** picture aspect → stage box (mobile layout uses it); posters and video both report it */\n private setAspect(w: number, h: number): void {\n if (!w || !h) return;\n const ar = `${w} / ${h}`;\n if (this.stage.style.getPropertyValue('--stage-ar') === ar) return;\n this.stage.style.setProperty('--stage-ar', ar);\n try { localStorage.setItem(this.arPrefix + this.camId, ar); } catch { /* ignore */ }\n }\n /** clips of the loaded range (several days, sorted), codec string, and the range the timeline spans */\n setClips(clips: Clip[], codecs: string | null, rangeStart: number, rangeEnd: number): void { this.clips = clips; this.codecs = codecs; this.rangeStart = rangeStart; this.rangeEnd = rangeEnd; }\n\n // ---- state ---------------------------------------------------------------------\n private setLabel(l: PlayerLabel): void { this.label = l; this.emit(); }\n private emit(): void {\n if (this.destroyed) return;\n this.opts.onState({ live: this.live, label: this.label, playhead: this.live ? null : this.currentTs(), rate: this.rate, sound: this.soundOn, paused: this.recPaused || (this.v.paused && !this.live && !this.rw?.active), transport: this.transport, muted: this.v.muted });\n }\n clipIndexFor(ts: number): number { for (let i = 0; i < this.clips.length; i++) { const c = this.clips[i]!; if (ts >= c.startTime && ts < c.startTime + (c.duration || 60000)) return i; } return -1; }\n private nearNow(ts: number): boolean { return Date.now() - ts < 8000; }\n private clampRange(ts: number): number { return Math.min(Math.max(ts, this.rangeStart), Math.min(this.rangeEnd - 1, Date.now())); }\n\n /** Wall-clock position of the picture on screen (Scrypted's getRecordingStreamCurrentTime). */\n currentTs(): number | null {\n if (this.rw?.active) {\n if (this.rwPosTs != null) return this.rwPosTs + (Date.now() - this.rwPosAt) * (this.rwRate || 1);\n if (this.rwBase != null && this.v.currentTime > 0) return this.rwStartMs + (this.v.currentTime - this.rwBase) * 1000 * (this.rwRate || 1);\n return this.rwStartMs;\n }\n if (this.recPaused) return this.recPausedTs;\n if (this.live) return null;\n if (this.M.active) return this.M.base + this.v.currentTime * 1000;\n const pc = this.playIndex >= 0 ? this.clips[this.playIndex] : undefined; if (pc) return pc.startTime + this.v.currentTime * 1000;\n return null;\n }\n\n // ---- presented frames / freeze / poster -----------------------------------------\n private fcArm(): void { const v: any = this.v; if (!v.requestVideoFrameCallback) return; const tok = {}; this.fc.tok = tok; const tick = () => { if (this.fc.tok !== tok) return; this.fc.n++; try { v.requestVideoFrameCallback(tick); } catch { /* ignore */ } }; try { v.requestVideoFrameCallback(tick); } catch { /* ignore */ } }\n presentedFrames(): number { if ((this.v as any).requestVideoFrameCallback) return this.fc.n; try { return this.v.getVideoPlaybackQuality().totalVideoFrames; } catch { return -1; } }\n private freezeArm(hold: boolean): void {\n if (this.freezeT) clearTimeout(this.freezeT);\n this.freezeT = window.setTimeout(() => this.freezeHide(), hold ? 90000 : 5000);\n const v: any = this.v;\n if (hold && v.requestVideoFrameCallback) { const tok = {}; this.freezeTok = tok; try { v.requestVideoFrameCallback(() => { if (this.freezeTok === tok && this.v.videoWidth) this.freezeHide(); }); } catch { /* ignore */ } }\n }\n /** copy the current video picture onto the freeze canvas (false = nothing to copy yet) */\n private drawVideo(): boolean {\n const v = this.v, fc = this.fz;\n if (!v.videoWidth || !v.videoHeight || v.readyState < 2) return false;\n if (fc.width !== v.videoWidth) fc.width = v.videoWidth;\n if (fc.height !== v.videoHeight) fc.height = v.videoHeight;\n fc.getContext('2d')!.drawImage(v, 0, 0, fc.width, fc.height);\n fc.classList.remove('hidden'); fc.dataset.src = 'video';\n return true;\n }\n freezeShow(hold = false): void {\n try { if (this.drawVideo()) this.freezeArm(hold); } catch { /* ignore */ }\n }\n /** poster/freeze stays until the seek's picture is visible (swapVisible), 6 s safety net */\n private holdUntilSwap(): void {\n if (this.freezeT) clearTimeout(this.freezeT); this.freezeTok = null;\n this.posterUntilSeek = true; this.freezeT = window.setTimeout(() => this.swapVisible(), 6000);\n }\n /** Event click inside a running relay session: the current picture stands still at once (the old position must not keep\n * playing while the event frame loads); the event frame replaces it, the picture at the target lifts it. */\n freezeCurrent(): void {\n if (!this.rw?.active || !this.rw.id) return; // no session yet: playAt's own freeze/poster path applies\n try { if (this.drawVideo()) this.holdUntilSwap(); } catch { /* ignore */ }\n }\n /** the picture of the last seek is on screen: lift a held poster, report playing */\n private swapVisible(): void {\n if (this.swapT) { clearTimeout(this.swapT); this.swapT = 0; }\n this.swapPending = false;\n if (this.posterUntilSeek) this.freezeHide();\n if (this.label === 'loading' && this.rw?.active) this.setLabel('playing');\n }\n /** seek answered: the new picture is on screen SWAP_MS later (plus proof of a presented frame) */\n private swapArm(): void {\n if (this.swapT) clearTimeout(this.swapT);\n this.swapFrames = this.presentedFrames();\n const check = () => { this.swapT = 0; if (!this.swapPending || !this.rw?.active) return; if (this.presentedFrames() > this.swapFrames) this.swapVisible(); else this.swapT = window.setTimeout(check, 100); };\n this.swapT = window.setTimeout(check, SWAP_MS);\n }\n freezeFromImage(img: HTMLImageElement, hold: boolean, untilSeek = false, kind = 'image'): boolean {\n try {\n if (!img.naturalWidth || !img.naturalHeight) return false;\n const fc = this.fz; fc.width = img.naturalWidth; fc.height = img.naturalHeight; fc.getContext('2d')!.drawImage(img, 0, 0); fc.classList.remove('hidden'); fc.dataset.src = kind;\n this.setAspect(img.naturalWidth, img.naturalHeight);\n if (untilSeek) this.holdUntilSwap(); // stays until the seek's picture is visible (see startRelayPoll)\n else this.freezeArm(hold);\n return true;\n } catch { return false; }\n }\n freezeHide(): void { if (this.freezeT) { clearTimeout(this.freezeT); this.freezeT = 0; } this.posterUntilSeek = false; this.fz.classList.add('hidden'); delete this.fz.dataset.src; }\n private posterUp(): boolean { return !this.fz.classList.contains('hidden'); }\n freezeHold(): void { if (this.freezeT) { clearTimeout(this.freezeT); this.freezeT = window.setTimeout(() => this.freezeHide(), 5000); } }\n /** Event click: the stored frame is the poster until the seek lands. */\n posterEvent(ts: number): void {\n const cam = this.camId; this.posterFor = ts; const img = new Image(); img.crossOrigin = 'anonymous';\n img.onload = () => {\n if (this.camId !== cam || this.posterFor !== ts || this.destroyed) return;\n const inSession = !!this.rw?.active && !!this.rw.id;\n if (inSession && !this.swapPending) return; // arrived after the seek's picture is already on screen — don't cover it\n this.freezeFromImage(img, true, inSession, 'event');\n };\n img.src = this.api.url(`api/evframe?camera=${encodeURIComponent(cam)}&ts=${ts}`);\n }\n /** Camera opened: a picture in front of the black stage until live plays — the overview tile's snapshot when the host\n * remembers one (browser cache → instant), else a fresh api/snapshot (1–3 s). */\n posterFromSnapshot(tileUrl?: string): void {\n const cam = this.camId;\n const load = (src: string, fresh: boolean) => {\n const img = new Image(); img.crossOrigin = 'anonymous';\n img.onload = () => { if (this.camId !== cam || this.rw?.active || this.recPaused || this.posterUp()) return; if (this.v.readyState >= 2 && this.v.videoWidth && !this.v.paused) return; this.freezeFromImage(img, true, false, 'snapshot'); };\n if (!fresh) img.onerror = () => load(this.api.url(`api/snapshot?camera=${encodeURIComponent(cam)}`) + `&_=${Date.now()}`, true);\n img.src = src;\n };\n if (tileUrl) load(tileUrl, false); else load(this.api.url(`api/snapshot?camera=${encodeURIComponent(cam)}`) + `&_=${Date.now()}`, true);\n }\n private posterShow(ts: number): void { try { if (this.posterUp()) return; if (this.v.readyState >= 2 && this.v.videoWidth) return; const i = this.clipIndexFor(ts); const c = i >= 0 ? this.clips[i] : undefined; if (!c?.thumbnailId) return; const cam = this.camId; const img = new Image(); img.crossOrigin = 'anonymous'; img.onload = () => { if (this.camId !== cam || this.destroyed) return; if (!this.posterUp()) this.freezeFromImage(img, true, false, 'thumb'); }; img.src = this.api.url(`api/thumb?id=${encodeURIComponent(c.thumbnailId)}`); } catch { /* ignore */ } }\n\n private safePlay(): void {\n let pr: Promise<void>; try { pr = this.v.play(); } catch { return; }\n pr.then(() => this.emit()).catch((e1) => { this.v.muted = true; this.v.play().then(() => this.emit()).catch((e2) => rlog('play-fail', { e1: e1?.name, e2: e2?.name, rs: this.v.readyState, paused: this.v.paused })); });\n }\n\n // ---- LIVE ---------------------------------------------------------------------------\n goLive(): void {\n if (!this.camId || this.destroyed) return;\n this.chaseAbort();\n this.freezeShow(true);\n this.exitLiveState(); this.recWebrtcTeardown(); this.recPaused = false; this.live = true; this.playIndex = -1; this.curClipId = null; this.L.restarts = 0;\n this.setLabel('live');\n if (document.visibilityState === 'hidden') return;\n if (window.RTCPeerConnection && window.WebSocket) this.liveStartWebrtc();\n else if (this.liveMseOk()) this.liveStartMse();\n else { try { this.v.pause(); } catch { /* ignore */ } this.liveFallbackImg(); }\n }\n private exitLiveState(): void { if (this.live) { this.live = false; this.webrtcTeardown(); this.liveTeardown(); try { this.v.srcObject = null; } catch { /* ignore */ } this.setMjpeg(false); } }\n private setMjpeg(on: boolean): void { this.img.classList.toggle('hidden', !on); this.v.classList.toggle('hidden', on); if (!on) this.img.removeAttribute('src'); }\n private webrtcTeardown(): void { this.w?.stop(); this.w = undefined; }\n private liveStartWebrtc(): void {\n if (this.destroyed) return;\n this.v.onloadedmetadata = null;\n this.webrtcTeardown(); this.recWebrtcTeardown(); this.mseTeardown(); this.liveTeardown();\n try { this.v.pause(); } catch { /* ignore */ } try { this.v.srcObject = null; } catch { /* ignore */ } this.v.removeAttribute('src');\n this.setMjpeg(false);\n const s = new WebRtcSession(this.api, { camId: this.camId, mode: 'live' }, {\n onStream: (ms) => { if (!this.live || this.w !== s) return; this.setMjpeg(false); this.v.muted = !this.soundOn; try { this.v.removeAttribute('src'); } catch { /* ignore */ } try { this.v.srcObject = ms; } catch { /* ignore */ } this.fcArm(); this.safePlay(); this.transport = 'webrtc'; this.setLabel('liveWebrtc'); },\n onFail: () => { if (this.w === s) this.liveFallbackMse(); },\n });\n this.w = s; this.transport = 'webrtc'; s.start();\n }\n private liveFallbackMse(): void { this.webrtcTeardown(); if (!this.live) return; try { this.v.srcObject = null; } catch { /* ignore */ } if (this.liveMseOk()) this.liveStartMse(); else this.liveFallbackImg(); }\n private liveCodec(): string | null { return this.codecs ? (this.codecs.split(',')[0] ?? null) : null; }\n private liveMseOk(): boolean { try { const c = this.liveCodec(); return !!(this.api.corsMedia && MSCls && c && MSCls.isTypeSupported(`video/mp4; codecs=\"${c}\"`)); } catch { return false; } }\n private liveTeardown(): void { const L = this.L; L.active = false; L.queue = []; if (L.stallT) { clearTimeout(L.stallT); L.stallT = 0; } try { L.abort?.abort(); } catch { /* ignore */ } L.abort = null; if (L.sb && L.ms && L.ms.readyState === 'open') { try { L.sb.abort(); } catch { /* ignore */ } } L.sb = null; L.ms = null; }\n private liveAppend(): void { const L = this.L; if (!L.active || !L.sb || L.sb.updating || !L.queue.length) return; const buf = L.queue.shift()!; try { L.sb.appendBuffer(buf as BufferSource); } catch { this.liveRestart(); } }\n private liveTrim(): void { const L = this.L; if (!L.sb || L.sb.updating) return; try { const b = this.v.buffered; if (b.length && this.v.currentTime - b.start(0) > 30) L.sb.remove(0, this.v.currentTime - 10); } catch { /* ignore */ } }\n private liveEdge(): void { try { const b = this.v.buffered; if (!b.length) return; const end = b.end(b.length - 1); if (end - this.v.currentTime > 2.5) this.v.currentTime = end - 0.7; if (this.v.paused) this.safePlay(); } catch { /* ignore */ } }\n private liveRestart(): void { if (!this.live || !this.L.active) return; this.liveTeardown(); this.L.restarts++; if (this.L.restarts > 5) { this.liveFallbackImg(); return; } if (this.liveRestartT) clearTimeout(this.liveRestartT); this.liveRestartT = window.setTimeout(() => { this.liveRestartT = 0; if (this.live && !this.destroyed) this.liveStartMse(); }, 1000); }\n private liveStartMse(): void {\n if (this.destroyed) return;\n this.v.onloadedmetadata = null;\n this.liveTeardown(); this.mseTeardown();\n const L = this.L; L.active = true; this.transport = 'mse'; this.setLabel('liveMse'); this.setMjpeg(false);\n const ms = new MSCls!(); L.ms = ms; L.lastTrim = Date.now();\n if ((window as any).ManagedMediaSource && ms instanceof (window as any).ManagedMediaSource) { try { (this.v as any).disableRemotePlayback = true; } catch { /* ignore */ } }\n const u = URL.createObjectURL(ms);\n ms.addEventListener('sourceopen', () => {\n URL.revokeObjectURL(u); if (L.ms !== ms) return;\n let sb: SourceBuffer; try { sb = ms.addSourceBuffer(`video/mp4; codecs=\"${this.liveCodec()}\"`); } catch { this.liveFallbackImg(); return; }\n sb.mode = 'segments';\n sb.addEventListener('updateend', () => { if (Date.now() - L.lastTrim > 10000) { L.lastTrim = Date.now(); this.liveTrim(); } this.liveAppend(); });\n sb.addEventListener('error', () => this.liveRestart());\n L.sb = sb; L.abort = new AbortController();\n fetch(this.api.url(`api/livemse?camera=${encodeURIComponent(this.camId)}`), { credentials: 'same-origin', signal: L.abort.signal })\n .then(r => { if (!r.ok || !r.body) throw new Error(String(r.status)); const rd = r.body.getReader(); const loop = () => { rd.read().then(x => { if (!L.active || L.ms !== ms) return; if (x.done) { this.liveRestart(); return; } L.queue.push(x.value); this.liveAppend(); loop(); }).catch(() => { if (L.active && L.ms === ms) this.liveRestart(); }); }; loop(); })\n .catch(() => { if (L.active && L.ms === ms) this.liveFallbackImg(); });\n });\n try { this.v.srcObject = null; } catch { /* ignore */ }\n this.v.src = u; this.v.playbackRate = 1; this.v.muted = true; this.safePlay();\n }\n private liveFallbackImg(): void { this.liveTeardown(); if (!this.live) return; try { this.v.pause(); } catch { /* ignore */ } this.freezeHide(); this.transport = 'mjpeg'; this.setLabel('liveMjpeg'); this.setMjpeg(true); this.img.src = this.api.url(`api/live?camera=${encodeURIComponent(this.camId)}`) + `&_=${Date.now()}`; }\n\n // ---- RECORDED via relay -----------------------------------------------------------------\n private recWebrtcOk(): boolean { return !this.recWebrtcDisabled && !!(window.RTCPeerConnection && window.WebSocket); }\n private recWebrtcTeardown(): void { this.posterUntilSeek = false; this.swapPending = false; if (this.swapT) { clearTimeout(this.swapT); this.swapT = 0; } if (this.scrubOffT) { clearTimeout(this.scrubOffT); this.scrubOffT = 0; } this.rwTargetBusy = false; this.rwPendingTarget = null; this.rwLastTarget = 0; this.stopRelayPoll(); this.rw?.stop(); this.rw = undefined; this.rwBase = null; this.rwPosTs = null; this.rwScrub = false; this.rwSeekBusy = false; this.rwPending = null; this.rwLastSeekTs = null; this.rwSrate = 1; this.rwRate = 1; }\n private recWebrtcStart(ts: number): void {\n if (this.destroyed) return;\n this.v.onloadedmetadata = null;\n this.freezeShow(true); this.posterShow(ts);\n this.live = false;\n this.recWebrtcTeardown(); this.webrtcTeardown(); this.mseTeardown(); this.liveTeardown();\n try { this.v.pause(); } catch { /* ignore */ } try { this.v.removeAttribute('src'); this.v.srcObject = null; } catch { /* ignore */ }\n this.setMjpeg(false); this.transport = 'relay';\n this.setLabel('loading');\n this.rwStartMs = ts; this.rwBase = null; this.rwRate = this.rate; this.rwSrate = 1; this.seekTarget = ts; // event poster clears when relay-pos reaches here\n const compat = mobileClient();\n if (compat) rlog('rec-compat-start', { ts: Math.round(ts) });\n const s = new WebRtcSession(this.api, { camId: this.camId, mode: 'recorded', startMs: ts, compat }, {\n onStream: (ms) => {\n if (this.rw !== s || this.live) return;\n try { s.pc?.getReceivers().forEach(r => { try { (r as any).jitterBufferTarget = 500; } catch { /* ignore */ } try { (r as any).playoutDelayHint = 0.5; } catch { /* ignore */ } }); } catch { /* ignore */ }\n this.setMjpeg(false); this.v.muted = !this.soundOn || this.rate !== 1;\n try { this.v.removeAttribute('src'); } catch { /* ignore */ } try { this.v.srcObject = ms; } catch { /* ignore */ }\n this.fcArm(); this.rwBase = null; this.safePlay(); this.setLabel('playing');\n },\n onFail: () => { if (this.rw === s) this.recFallbackMse(ts); },\n onSessionId: () => { if (this.rw === s && this.rwPending) { const p = this.rwPending; this.rwPending = null; if (Math.abs(p.ts - this.rwStartMs) > 1500) this.recRelaySeek(p.ts, p.rate, p.srate); } },\n });\n this.rw = s; s.start(); this.startRelayPoll(); this.emit();\n }\n /** Relay failed: retry the relay up to twice (transient WS/ICE hiccups), only then fall back to MSE for the rest of this camera. */\n private recFallbackMse(ts: number): void {\n this.recWebrtcTeardown();\n if (this.live || this.destroyed) return;\n this.recoveries++;\n if (this.recoveries <= 2) { rlog('relay-retry', { n: this.recoveries }); this.recWebrtcStart(ts); return; }\n rlog('rec-fallback-mse', { mseOk: this.mseSupported(), after: this.recoveries }); this.recWebrtcDisabled = true; this.playAt(ts, {});\n }\n /** Hard server-side seek, coalesced: one in flight, latest wins, 150 ms floor. */\n private recRelaySeek(ts: number, rate = 1, srate = 1): void {\n const s = this.rw; if (!s?.id) return;\n if (this.rwSeekBusy) { this.rwPending = { ts, rate, srate }; return; }\n if (this.rwLastSeekTs === ts && this.rwRate === rate && this.rwSrate === srate && Date.now() - this.rwLastSeekAt < 1000) return;\n const wait = 150 - (Date.now() - this.rwLastSeekAt);\n if (wait > 0) { this.rwSeekBusy = true; this.rwPending = { ts, rate, srate }; window.setTimeout(() => { this.rwSeekBusy = false; const p = this.rwPending; this.rwPending = null; if (p && this.rw?.id) this.recRelaySeek(p.ts, p.rate, p.srate); }, wait); return; }\n this.rwStartMs = ts; this.rwSrate = srate; this.rwRate = this.rwScrub ? srate : rate; this.rwLastSeekTs = ts; this.rwLastSeekAt = Date.now();\n this.cad.lastNew = Date.now(); this.wdLastCt = -1; this.wdLastAt = Date.now(); this.wdGrace = Date.now() + 5000;\n this.rwPosTs = ts; this.rwPosAt = Date.now();\n this.setLabel(this.rwScrub ? 'scrub' : 'loading'); // scrubbing seeks constantly — no \"loading\" flicker there\n this.rwSeekBusy = true;\n this.seekTarget = ts; this.seekAt = Date.now(); this.cmdSeq++;\n this.swapPending = true; if (this.swapT) { clearTimeout(this.swapT); this.swapT = 0; }\n const done = (ok: boolean) => { this.rwSeekBusy = false; if (!ok) { this.relayRecover(); return; } if (this.swapPending) this.swapArm(); const p = this.rwPending; this.rwPending = null; if (p && this.rw?.id) this.recRelaySeek(p.ts, p.rate, p.srate); };\n this.api.control(`api/relay-seek?session=${encodeURIComponent(s.id)}&start=${Math.round(ts)}&rate=${rate}&srate=${srate}`).then(ok => done(ok));\n }\n /** Scrub target (timeline centre), coalesced: one in flight, latest wins, 120 ms floor, 250 ms minimum step. */\n private recRelayTarget(ts: number): void {\n const s = this.rw; if (!s?.active || !s.id) return;\n if (this.rwTargetBusy) { this.rwPendingTarget = ts; return; }\n if (Math.abs(ts - this.rwLastTarget) < TARGET_MIN_STEP_MS) return;\n const wait = TARGET_FLOOR_MS - (Date.now() - this.rwLastTargetAt);\n if (wait > 0) { this.rwTargetBusy = true; this.rwPendingTarget = ts; window.setTimeout(() => { this.rwTargetBusy = false; const p = this.rwPendingTarget; this.rwPendingTarget = null; if (p != null && this.rw?.id) this.recRelayTarget(p); }, wait); return; }\n this.rwLastTarget = ts; this.rwLastTargetAt = Date.now(); this.cmdSeq++;\n this.wdGrace = Date.now() + 8000; this.cad.lastNew = Date.now();\n this.rwTargetBusy = true;\n this.api.control(`api/relay-target?session=${encodeURIComponent(s.id)}&ts=${Math.round(ts)}`).then(ok => { if (!ok) this.relayRecover(); }).then(() => { this.rwTargetBusy = false; const p = this.rwPendingTarget; this.rwPendingTarget = null; if (p != null && this.rw?.id && Math.abs(p - this.rwLastTarget) >= TARGET_MIN_STEP_MS) this.recRelayTarget(p); });\n }\n /** profile on/off; `off` also ends the server's target steering, so it is sent even when the profile was never entered\n * (single-notch gesture) as long as the gesture steered (`force`) */\n private recRelayScrub(on: boolean, force = false): void {\n const s = this.rw; if (!s?.active || !s.id) return;\n if (this.rwScrub === on && !(force && !on)) return;\n this.rwScrub = on;\n this.cmdSeq++;\n if (!on) { const c = this.currentTs(); this.rwSrate = 1; this.rwRate = this.rate; if (c != null) { this.rwPosTs = c; this.rwPosAt = Date.now(); } if (this.label === 'scrub') this.setLabel('playing'); }\n this.wdLastCt = -1; this.wdLastAt = Date.now(); this.wdGrace = Date.now() + 5000; this.cad.lastNew = Date.now();\n this.api.control(`api/relay-scrub?session=${encodeURIComponent(s.id)}&on=${on ? 1 : 0}`).then(ok => { if (!ok) this.relayRecover(); });\n }\n private relayRecover(): void {\n if (!this.rw?.active) return;\n const t = this.rwPosTs ?? this.rwStartMs;\n this.recoveries++; rlog('relay-recover', { n: this.recoveries });\n if (this.recoveries > 2) { this.recoveries--; this.recFallbackMse(t); return; } // hand-over: recFallbackMse counts once more\n this.recWebrtcStart(t);\n }\n private startRelayPoll(): void {\n if (this.relayPoll) return;\n this.cadStart(); this.wdLastCt = -1; this.wdLastAt = Date.now(); this.wdDead = 0; this.wdGrace = Date.now() + 8000;\n this.relayPoll = window.setInterval(() => {\n const s = this.rw; const v = this.v; if (!s?.active || !s.id) return;\n const q = this.presentedFrames();\n if (v.paused && !this.recPaused && !document.hidden) { if (!this.wdResumeLogged) { this.wdResumeLogged = true; rlog('auto-resume', { rs: v.readyState }); } this.safePlay(); } else if (!v.paused) this.wdResumeLogged = false;\n if (!v.paused && !document.hidden && this.rwBase != null) {\n if (q !== this.wdLastCt) { this.wdLastCt = q; this.wdLastAt = Date.now(); this.recoveries = 0; if (!this.posterUntilSeek) this.freezeHide(); if (this.label === 'loading' && !this.swapPending) this.setLabel('playing'); }\n else if (this.rwScrub) this.wdLastAt = Date.now();\n else if (Date.now() - this.wdLastAt > 4000 && Date.now() > this.wdGrace) {\n this.wdLastAt = Date.now();\n const o: any = { ct: Math.round(v.currentTime * 10) / 10, paused: v.paused, muted: v.muted, rs: v.readyState, pf: q, w: v.videoWidth };\n try { s.pc?.getStats().then(st => { st.forEach((r: any) => { if (r.type === 'inbound-rtp' && (r.kind || r.mediaType) === 'video') { o.recv = r.framesReceived; o.dec = r.framesDecoded; o.drop = r.framesDropped; o.pli = r.pliCount; } }); rlog('stall-snap', o); }).catch(() => { /* ignore */ }); } catch { /* ignore */ }\n this.relayRecover(); return;\n }\n } else { this.wdLastCt = q; this.wdLastAt = Date.now(); }\n const seq = this.cmdSeq;\n fetch(this.api.url(`api/relay-pos?session=${encodeURIComponent(s.id)}`), { cache: 'no-store' }).then(r => r.json()).then((d: any) => {\n if (seq !== this.cmdSeq) return; // answered across a seek/rate change → stale\n if (d && d.t > 0 && Date.now() - this.seekAt < 2500 && Math.abs(d.t - this.seekTarget) > 5000) return; // pre-swap position\n if (d && d.t > 0) { this.wdDead = 0; this.rwPosTs = d.t; this.rwPosAt = Date.now(); if (this.rwScrub && typeof d.r === 'number' && isFinite(d.r) && d.r) this.rwRate = d.r; this.emit(); }\n else if (d && d.t <= 0) { if (++this.wdDead >= 3) { this.wdDead = 0; this.relayRecover(); } }\n }).catch(() => { /* ignore */ });\n }, 600);\n }\n private stopRelayPoll(): void { this.cadStop(); if (this.relayPoll) { clearInterval(this.relayPoll); this.relayPoll = undefined; } }\n private cadStart(): void {\n this.cadStop(); const C = this.cad; C.last = -1; C.frames0 = -1; C.stalls = 0; C.maxStall = 0; C.gapMax = 0; C.t0 = Date.now();\n C.t = window.setInterval(() => {\n if (!this.rw?.active || document.hidden) return;\n const q = this.presentedFrames(), now = Date.now();\n if (this.rwScrub) { C.last = q; C.lastNew = now; return; }\n if (C.frames0 < 0) { C.frames0 = q; C.last = q; C.lastNew = now; return; }\n if (q === C.frames0 && C.last === C.frames0) { C.lastNew = now; return; } // connect phase: no frame yet, not a stall\n if (q > C.last) { const gap = now - C.lastNew; if (gap > C.gapMax) C.gapMax = gap; if (gap >= 400) { C.stalls++; if (gap > C.maxStall) C.maxStall = gap; } C.last = q; C.lastNew = now; }\n if (now - C.t0 >= 30000) {\n const rep: any = { sec: Math.round((now - C.t0) / 1000), frames: C.last - C.frames0, stalls: C.stalls, maxStall: C.maxStall, gapMax: C.gapMax, w: this.v.videoWidth };\n C.t0 = now; C.frames0 = C.last; C.stalls = 0; C.maxStall = 0; C.gapMax = 0;\n const pc = this.rw?.pc;\n if (pc) pc.getStats().then(st => { st.forEach((r: any) => { if (r.type === 'inbound-rtp' && (r.kind || r.mediaType) === 'video') { rep.lost = r.packetsLost; rep.jit = Math.round((r.jitter || 0) * 1000); rep.recv = r.framesReceived; rep.dec = r.framesDecoded; rep.drop = r.framesDropped; } }); rlog('cadence', rep); }).catch(() => rlog('cadence', rep));\n else rlog('cadence', rep);\n }\n }, 100);\n }\n private cadStop(): void { if (this.cad.t) { clearInterval(this.cad.t); this.cad.t = 0; } }\n\n // ---- playAt: relay first, MSE/native fallback ------------------------------------------------\n playAt(ts: number, opts: { scrub?: boolean; srate?: number; noChase?: boolean } = {}): void {\n if (this.destroyed) return;\n const idx0 = this.clipIndexFor(ts);\n if (this.recWebrtcOk()) {\n this.chaseAbort();\n if (idx0 < 0) { this.setLabel('noRecording'); return; }\n this.recPaused = false;\n const t0 = Math.max(ts, this.clips[idx0]!.startTime);\n if (this.rw?.active && this.rw.id) this.recRelaySeek(t0, this.rate || 1, opts.srate || 1);\n else if (this.rw?.active && !this.live) this.rwPending = { ts: t0, rate: this.rate || 1, srate: opts.srate || 1 };\n else { if (this.live) { this.freezeShow(true); this.exitLiveState(); } this.recWebrtcStart(t0); }\n return;\n }\n // ---- MSE fallback / native\n const canChase = !opts.noChase && !this.live && this.M.active && !this.recPaused && this.currentTs() != null && idx0 >= 0;\n this.chaseAbort();\n if (canChase && !opts.scrub) { this.startChase(ts); return; }\n if (idx0 < 0) { this.setLabel('noRecording'); return; }\n if (this.live) { this.freezeShow(true); this.exitLiveState(); }\n this.recPaused = false;\n const clip = this.clips[idx0]!; if (ts < clip.startTime) ts = clip.startTime;\n this.playIndex = idx0;\n this.v.muted = opts.scrub ? true : !this.soundOn;\n if (this.mseSupported()) {\n const t = (ts - this.M.base) / 1000;\n if (this.M.active && t >= 0 && (this.bufferedContains(t) || (t <= this.M.end + 0.5 && this.M.end - t < 95))) { try { this.v.currentTime = t; } catch { /* ignore */ } if (this.v.paused) this.safePlay(); this.feed(); }\n else { if (opts.scrub && Date.now() - this.lastLoad < 200) { this.pendingTs = ts; return; } this.lastLoad = Date.now(); this.mseStart(idx0, (ts - clip.startTime) / 1000); }\n } else {\n const off = Math.min(Math.max((ts - clip.startTime) / 1000, 0), (clip.duration || 0) / 1000);\n if (clip.id === this.curClipId && this.v.src) { try { this.v.currentTime = off; } catch { /* ignore */ } if (this.v.paused) this.safePlay(); }\n else { if (opts.scrub && Date.now() - this.lastLoad < 120) { this.pendingTs = ts; return; } this.freezeShow(); this.lastLoad = Date.now(); this.curClipId = clip.id; this.transport = 'native'; rlog('native-fallback', { clip: clip.id }); this.v.src = this.api.url(`api/segment?id=${encodeURIComponent(clip.videoId || clip.id)}`); this.v.load(); this.v.onloadedmetadata = () => { this.v.playbackRate = this.rate; try { this.v.currentTime = off; } catch { /* ignore */ } this.safePlay(); }; }\n }\n this.setLabel(opts.scrub ? 'scrub' : 'playing');\n }\n\n // ---- MSE recorded ------------------------------------------------------------------------\n private mseSupported(): boolean { try { return !!(this.api.corsMedia && MSCls && this.codecs && MSCls.isTypeSupported(`video/mp4; codecs=\"${this.codecs}\"`)); } catch { return false; } }\n private mseTeardown(): void { const M = this.M; M.active = false; M.nextIdx = -1; M.feeding = false; M.end = 0; M.pendingSeek = null; M.q = []; M.segFirst = false; try { M.abort?.abort(); } catch { /* ignore */ } M.abort = null; if (M.sb && M.ms && M.ms.readyState === 'open') { try { M.sb.abort(); } catch { /* ignore */ } } M.sb = null; M.ms = null; }\n private bufferedContains(t: number): boolean { try { const b = this.v.buffered; for (let i = 0; i < b.length; i++) if (t >= b.start(i) - 0.3 && t <= b.end(i) + 0.3) return true; } catch { /* ignore */ } return false; }\n private mseStart(idx: number, offSec: number): void {\n if (this.destroyed) return;\n this.v.onloadedmetadata = null;\n this.freezeShow(); this.mseTeardown();\n const M = this.M; const ms = new MSCls!(); M.ms = ms; M.active = true; M.base = this.clips[idx]!.startTime; M.nextIdx = idx; M.end = 0; M.mmsGo = true; this.transport = 'mse';\n if ((window as any).ManagedMediaSource && ms instanceof (window as any).ManagedMediaSource) { try { (this.v as any).disableRemotePlayback = true; } catch { /* ignore */ } ms.addEventListener('startstreaming', () => { M.mmsGo = true; this.feed(); }); ms.addEventListener('endstreaming', () => { M.mmsGo = false; }); }\n M.pendingSeek = offSec;\n const u = URL.createObjectURL(ms);\n ms.addEventListener('sourceopen', () => {\n URL.revokeObjectURL(u); if (M.ms !== ms) return;\n let sb: SourceBuffer; try { sb = ms.addSourceBuffer(`video/mp4; codecs=\"${this.codecs}\"`); } catch { this.codecs = null; M.active = false; return; }\n sb.mode = 'segments';\n sb.addEventListener('updateend', () => { if (M.pendingSeek != null && this.v.readyState >= 1) { const t0 = M.pendingSeek; M.pendingSeek = null; try { this.v.currentTime = t0; } catch { /* ignore */ } } this.drain(); if (!M.feeding && !M.q.length) this.feed(); });\n sb.addEventListener('error', () => { M.active = false; });\n M.sb = sb; try { this.v.currentTime = offSec; } catch { /* ignore */ } this.feed();\n });\n try { this.v.srcObject = null; } catch { /* ignore */ }\n this.v.src = u; this.v.playbackRate = this.rate; this.safePlay();\n }\n private drain(): void {\n const M = this.M; if (!M.active || !M.sb || M.sb.updating || !M.q.length) return;\n if (M.segFirst) { M.segFirst = false; try { M.sb.timestampOffset = M.segOff; } catch { try { M.sb.abort(); M.sb.timestampOffset = M.segOff; } catch { M.active = false; return; } } }\n const buf = M.q.shift()!;\n try { M.sb.appendBuffer(buf as BufferSource); } catch { try { M.sb.abort(); M.sb.appendBuffer(buf as BufferSource); } catch { M.active = false; } }\n }\n private feed(): void {\n const M = this.M; if (!M.active || M.feeding) return; if (M.mmsGo === false) return; if (M.nextIdx < 0 || M.nextIdx >= this.clips.length) return;\n if (M.end - this.v.currentTime > 90) return;\n try { const b = this.v.buffered; if (b.length && this.v.currentTime - b.start(0) > 240 && M.sb && !M.sb.updating && !M.q.length) { M.sb.remove(0, this.v.currentTime - 120); return; } } catch { /* ignore */ }\n const clip = this.clips[M.nextIdx]!, ms = M.ms;\n M.feeding = true; M.segFirst = true; M.segOff = (clip.startTime - M.base) / 1000; M.abort = new AbortController();\n fetch(this.api.url(`api/segment?id=${encodeURIComponent(clip.videoId || clip.id)}`), { credentials: 'same-origin', signal: M.abort.signal })\n .then(r => { if (!r.ok || !r.body) throw new Error(String(r.status)); const rd = r.body.getReader(); const loop = () => { rd.read().then(x => { if (M.ms !== ms || !M.active) return; if (x.done) { M.feeding = false; M.nextIdx++; M.end = M.segOff + (clip.duration || 60000) / 1000; if (!M.q.length) this.feed(); return; } M.q.push(x.value); this.drain(); loop(); }).catch(() => { if (M.ms === ms) M.feeding = false; }); }; loop(); })\n .catch(() => { if (M.ms !== ms) return; M.feeding = false; M.nextIdx++; this.feed(); });\n }\n private handleStall(): void { if (this.live || !this.M.active || this.v.paused) return; const t = this.v.currentTime; try { const b = this.v.buffered; for (let i = 0; i < b.length; i++) if (b.start(i) > t && b.start(i) - t < 60) { this.v.currentTime = b.start(i) + 0.05; return; } } catch { /* ignore */ } if (this.M.nextIdx >= this.clips.length) this.opts.onClipsRefresh().then(c => { const cur = this.clips[this.M.nextIdx - 1]; this.clips = c; if (cur) { const i = c.findIndex(x => x.id === cur.id); if (i >= 0) this.M.nextIdx = i + 1; } this.feed(); }).catch(() => { /* ignore */ }); else this.feed(); }\n // trick-play chase inside the MSE buffer\n private chaseAbort(): void { if (!this.CH.active) return; this.CH.active = false; if (this.CH.timer) { clearInterval(this.CH.timer); this.CH.timer = 0; } this.v.playbackRate = this.rate; this.v.muted = !this.soundOn; }\n private endChase(): void { const tgt = this.CH.target; this.chaseAbort(); try { this.v.currentTime = (tgt - this.M.base) / 1000; } catch { /* ignore */ } this.setLabel('playing'); if (this.v.paused) this.safePlay(); }\n private startChase(target: number): void {\n this.chaseAbort(); this.freezeHide(); this.CH.active = true; this.CH.target = target; try { this.v.pause(); } catch { /* ignore */ } this.v.muted = true; this.setLabel('scrub');\n this.CH.timer = window.setInterval(() => {\n if (!this.CH.active) return; const c = this.currentTs(); if (c == null) { this.endChase(); return; }\n const rem = this.CH.target - c; if (Math.abs(rem) <= 250) { this.endChase(); return; }\n let step = rem * 0.2; if (Math.abs(step) < 180) step = rem > 0 ? 180 : -180;\n const nt = c + step, tt = (nt - this.M.base) / 1000;\n if (this.M.active && this.bufferedContains(tt)) { try { this.v.currentTime = tt; } catch { /* ignore */ } this.feed(); } else { this.endChase(); this.playAt(this.CH.target, { noChase: true }); }\n }, 50);\n }\n\n // ---- controls -----------------------------------------------------------------------------\n togglePlayPause(): void {\n if (this.live) return;\n if (this.CH.active) { this.chaseAbort(); try { this.v.pause(); } catch { /* ignore */ } this.emit(); return; }\n if (this.recPaused) { this.recPaused = false; const t = this.recPausedTs ?? (this.currentTs() ?? Date.now() - 1000); this.playAt(t, {}); return; }\n if (this.rw?.active) { this.recPausedTs = this.currentTs(); this.freezeShow(); if (this.freezeT) { clearTimeout(this.freezeT); this.freezeT = 0; } this.recWebrtcTeardown(); try { this.v.pause(); } catch { /* ignore */ } this.recPaused = true; this.transport = 'none'; this.setLabel('paused'); return; }\n if (this.v.paused) this.safePlay(); else this.v.pause();\n }\n skip(ms: number): void { const ts = this.live ? Date.now() + ms : ((this.currentTs() ?? Date.now()) + ms); if (this.live && ms > 0) return; this.playAt(ts, {}); }\n cycleSpeed(): number {\n if (this.live) return this.rate;\n const rates = [1, 2, 4, 8]; this.rate = rates[(rates.indexOf(this.rate) + 1) % rates.length] ?? 1;\n if (this.rw?.active && this.rw.id) { const c = this.currentTs(); this.recRelaySeek(c ?? this.rwStartMs, this.rate); this.v.muted = !this.soundOn || this.rate !== 1; }\n else this.v.playbackRate = this.rate;\n this.emit(); return this.rate;\n }\n setSound(on: boolean): void { this.soundOn = on; this.v.muted = !on || (!!this.rw?.active && this.rate !== 1); if (on && this.v.paused && !this.recPaused) this.safePlay(); this.emit(); }\n snapshot(): void {\n try {\n const src: any = this.live && !this.img.classList.contains('hidden') ? this.img : this.v;\n const w = src.videoWidth || src.naturalWidth || 1280, h = src.videoHeight || src.naturalHeight || 720;\n const cv = document.createElement('canvas'); cv.width = w; cv.height = h; cv.getContext('2d')!.drawImage(src, 0, 0, w, h);\n cv.toBlob(b => { if (!b) return; const a = document.createElement('a'); a.href = URL.createObjectURL(b); const ts = this.currentTs() ?? Date.now(); const d = new Date(ts); a.download = `${(this.camName || 'snapshot').replace(/[^\\w.-]+/g, '_')}_${String(d.getHours()).padStart(2, '0')}${String(d.getMinutes()).padStart(2, '0')}${String(d.getSeconds()).padStart(2, '0')}.jpg`; document.body.appendChild(a); a.click(); a.remove(); setTimeout(() => URL.revokeObjectURL(a.href), 4000); }, 'image/jpeg', 0.92);\n } catch { /* ignore */ }\n }\n private capLog(tag: string, extra?: object): void { try { const v: any = this.v, st: any = this.stage; rlog(tag, { fsReq: !!st.requestFullscreen, wkFs: !!st.webkitRequestFullscreen, vEnter: !!v.webkitEnterFullscreen, pipReq: !!v.requestPictureInPicture, wkPip: !!(v.webkitSupportsPresentationMode && v.webkitSupportsPresentationMode('picture-in-picture')), rs: v.readyState, vw: v.videoWidth, ...(extra || {}) }); } catch { /* ignore */ } }\n pip(): void {\n const v: any = this.v; this.capLog('pip-btn');\n try {\n if (document.pictureInPictureElement || v.webkitPresentationMode === 'picture-in-picture') { if (document.pictureInPictureElement) document.exitPictureInPicture().catch(() => { /* ignore */ }); else v.webkitSetPresentationMode('inline'); return; }\n if (this.v.classList.contains('hidden')) return;\n const wk = () => { try { if (v.webkitSupportsPresentationMode && v.webkitSupportsPresentationMode('picture-in-picture')) v.webkitSetPresentationMode('picture-in-picture'); else this.capLog('pip-unsupported'); } catch (e: any) { this.capLog('pip-fail', { e: String(e?.name || e) }); } };\n if (v.requestPictureInPicture) v.requestPictureInPicture().catch((e: any) => { this.capLog('pip-fail', { e: String(e?.name || e) }); wk(); }); else wk();\n } catch (e: any) { this.capLog('pip-fail', { e: String(e?.name || e) }); }\n }\n fullscreen(): void {\n const st: any = this.stage, v: any = this.v, d: any = document; this.capLog('fs-btn');\n try {\n if (d.fullscreenElement || d.webkitFullscreenElement) { (d.exitFullscreen || d.webkitExitFullscreen).call(d); return; }\n if (st.requestFullscreen) st.requestFullscreen().catch((e: any) => this.capLog('fs-fail', { e: String(e?.name || e) }));\n else if (st.webkitRequestFullscreen) st.webkitRequestFullscreen();\n else if (v.webkitEnterFullscreen && !this.v.classList.contains('hidden')) v.webkitEnterFullscreen();\n else this.capLog('fs-unsupported');\n } catch (e: any) { this.capLog('fs-fail', { e: String(e?.name || e) }); }\n }\n\n // ---- scrub (timeline gesture) ------------------------------------------------------------\n /** first gesture: scrub profile on (relay); MSE: freeze + pause */\n scrubBegin(): void {\n this.chaseAbort();\n if (this.scrubOffT) { clearTimeout(this.scrubOffT); this.scrubOffT = 0; } // gesture continues → stay in the scrub profile\n this.scrubMoves = 0;\n if (!this.rw?.active) { this.freezeShow(); if (!this.live) { try { this.v.pause(); } catch { /* ignore */ } } }\n // the scrub profile is entered by scrubMove on the first real movement (a single wheel notch = one in-place seek, no restarts)\n }\n /** true between the end of a gesture and the profile switch back (SCRUB_OFF_DELAY_MS): the timeline must not auto-follow\n * the playhead in that window — the servo is still converging on the centre the user left */\n scrubSettling(): boolean { return this.scrubOffT !== 0; }\n /** scroll position while the gesture runs: the centre becomes the server's steering target (velocity unused since 0.7.0) */\n scrubMove(centerTs: number, _vel: number, _smoothTs: number): void {\n if (!this.rw?.active) { this.freezeHold(); return; }\n if (!this.rw.id) return;\n // the 640 all-intra profile (two transcoder restarts per gesture) only for real scrubbing: a second movement of the\n // gesture or a big jump — a single wheel notch is steered in the normal profile\n const c = this.currentTs();\n if (++this.scrubMoves >= 2 || (c != null && Math.abs(centerTs - c) > 60000)) this.recRelayScrub(true);\n this.recRelayTarget(this.clampRange(centerTs));\n }\n /** release / hard landing: near now → live; relay in scrub → just the final target (no seek: the servo stops there);\n * MSE / no session → preview seek */\n scrubSeek(ts: number, srate = 1): void {\n if (this.nearNow(ts)) { this.goLive(); return; }\n if (this.rw?.active && this.rw.id && this.scrubMoves > 0) { this.recRelayTarget(this.clampRange(ts)); return; }\n this.playAt(this.clampRange(ts), { scrub: true, srate });\n }\n /** brief hold mid-gesture: nothing to do on the relay (the target already stands), MSE: preview seek */\n scrubHold(ts: number): void { if (!this.rw?.active) this.scrubSeek(ts); else if (this.rw.id) this.recRelayTarget(this.clampRange(ts)); }\n /** gesture settled → final target, then back to the normal profile after SCRUB_OFF_DELAY_MS of quiet (a new gesture cancels it) */\n scrubIdle(ts?: number): void {\n if (ts != null && this.rw?.active && this.rw.id && this.scrubMoves > 0) this.recRelayTarget(this.clampRange(ts));\n if (this.scrubOffT) clearTimeout(this.scrubOffT);\n this.scrubOffT = window.setTimeout(() => { this.scrubOffT = 0; const steered = this.scrubMoves > 0; this.scrubMoves = 0; this.recRelayScrub(false, steered); }, SCRUB_OFF_DELAY_MS);\n }\n\n // ---- visibility ---------------------------------------------------------------------------\n private hiddenTs: number | null = null;\n private onVisibility(): void {\n if (document.visibilityState === 'hidden') {\n // don't pin a camera stream in the background; live is simply restarted on return\n if (this.live) { this.hiddenTs = null; this.webrtcTeardown(); this.liveTeardown(); if (this.transport === 'mjpeg') this.img.removeAttribute('src'); }\n else if (this.rw?.active) { this.hiddenTs = this.currentTs(); this.freezeShow(true); this.recWebrtcTeardown(); }\n } else {\n if (this.live) this.goLive(); // also covers goLive() issued while hidden (background tab)\n else if (this.hiddenTs != null && !this.recPaused) { const t = this.hiddenTs; this.hiddenTs = null; this.playAt(t, {}); }\n }\n }\n}\n\n"],"mappings":";AAQA,IAAI,QAAQ;AAEZ,IAAI,SAAgC;AAE7B,SAAS,cAAc,GAA0B,GAAkB;AACxE,WAAS;AACT,MAAI,EAAG,SAAQ;AACjB;AAEO,SAAS,KAAK,KAAa,MAAsC;AACtE,MAAI,CAAC,OAAQ;AACb,MAAI;AACJ,MAAI;AACF,WAAO,KAAK,UAAU,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,MAAM,IAAI,UAAU,UAAU,MAAM,GAAG,EAAE,EAAE,CAAC;AAAA,EAChG,QAAQ;AACN,WAAO,KAAK,UAAU,EAAE,KAAK,GAAG,MAAM,CAAC;AAAA,EACzC;AACA,SAAO,SAAS,iBAAiB,IAAI;AACvC;;;ACRA,IAAI,mBAAmB;AAEhB,SAAS,eAAwB;AACtC,SAAO,8BAA8B,KAAK,UAA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