iobroker.agent-dvr 0.5.2 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.agent-dvr",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "Connects ioBroker to AgentDVR: auto-discovers cameras, mirrors all device values as data points, delivers real-time triggers on new recordings, and generates a responsive HTML gallery with optional search and tag filtering.",
5
5
  "author": {
6
6
  "name": "ipod86",
@@ -23,16 +23,16 @@
23
23
  "node": ">= 22"
24
24
  },
25
25
  "dependencies": {
26
- "@iobroker/adapter-core": "^3.4.1"
26
+ "@iobroker/adapter-core": "^3.4.3"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@alcalzone/release-script": "^5.2.1",
30
30
  "@alcalzone/release-script-plugin-iobroker": "^5.2.0",
31
- "@alcalzone/release-script-plugin-license": "^5.2.0",
31
+ "@alcalzone/release-script-plugin-license": "^5.2.2",
32
32
  "@alcalzone/release-script-plugin-manual-review": "^5.2.0",
33
33
  "@iobroker/adapter-dev": "^1.5.0",
34
34
  "@iobroker/eslint-config": "^2.3.4",
35
- "@iobroker/testing": "^5.2.2",
35
+ "@iobroker/testing": "^6.3.0",
36
36
  "@tsconfig/node22": "^22.0.5",
37
37
  "@types/iobroker": "npm:@iobroker/types@^7.2.2",
38
38
  "@types/node": "^22.0.0",
package/www/index.html CHANGED
@@ -4,6 +4,7 @@
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
6
6
  <title>AgentDVR</title>
7
+ <link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAE+klEQVR4nO2Wf0yVZRTHP8/zXOBe7uWnwgXBC5goioYDVMyQampa2VpF2ahVan/lWrWsZJmxXP3jP63/qplb6iprbW4219Z0tDadGZoBKgyhCBAEhbjo5d73ffrjfV+4IRex+i/P3rP313nO+Z7znHOeA7fp/07iX651OJp0FP/nAJR9N6apW9lAzFiApgtAcqNXmUAGkAJ4bF3XgatAD3B5gg6XDcScps0xwyrqfTXwEfCLbUjH4AHgR+BdYCX/YKuFjdihlcCRGMZMrC0xGA91NIeB88CHwDLboSkBRXs8B9gTpcywFTrGJjPogBoBRoH9QBWwAzgEPMR4fsQ0ngBsB/pthYMet7tfCBEr5GNsy0QDGwG+tkE4JCeLgvPhfuC0pQwNNBTNLXhlZnrqAGAIMbnXQggtwFBS6pzsjCaXy1XLjXlyDtg4AcjYgwR2A+3AkL3gRGVlWXYgx98AaIQwxpWJiV4790iSNzGyYc299wGFQtBgy4WigHwG+KLDLoBXgX3AV7aynwDfqqUlT3hSM7VMyQ0nZhXqtNwineYPaKnU3yKQkJDgPEcAHZiVdVYpBeAFPo6SdYA0AndLrIRSwCdAB/AY0KC1d72A4c6hyFOjMxbr5DtW4J+/nLzipYSvBzENA9sA5eXldHV1UVNTA6CEEPwZDC54dPWq+UAQeAHYDFwB4m3Hs4EHJBBno34OqAUuAA9CsM8EEXJnBVROmUjJXyLzFq/El5TC8GA/Qgi0tvpSMBikpaWF/v5+J6pGOBJRPQOD+YCoqqpyAZ/aYFqATVgVVuvCKqu1wAdAL/Aw0A2Pq3gOGjO9mfGunFKSs1PILcxhUA8BIKTCNCKAoLm5mYqKirHM0lpjXZE4QNfX10eAN4FcoAY44OSeBF7Dqs8w8CRW03Cx80ttAHEJ3h6Zfad2B8q0219IyZqNuL3JmEYEKZ1WD+mz8vGlZToYpFJS+DzeS4BI1NoPvI7Vog9jNTkJmBKrl0tgK3DM/hmpOvaONIFko/cH3OliJD5DDwRN4mYEeHbXAVL9AUzTAKkILFxG3qK7UJ4UhBAmQKLH07W8ZM55QAfhPSAN2AYMMt6sxmq/2M5K6fzYCbIOYT49L77gSMXec3rJRlXsDcpAihTzcjwQHOBSWyPXhq8yPHSV82dO8FvTSa60nw7HCSOuaG7B7rPnWrcpxQbD4BBWdVXbCT92mjr132iDGTup6sCsrv5C7bsQupjb8fmu0d5O1Rbyhn8fMvSZ9iBdoSR8RZWo3HJ6r8czrD2ElTeMiIvLmpn+x46tL9cBAcNgn72tW6IddEhEAZnsmFQsrFa66WCkeO2WvZ1lbz+TkDGbLLcZSVYhEa8EoaE++lpP6Ustp0Sw7bjyh1qvrCstWLHn0NFe4CSQCqzAyv6YAKYmIVHapKRqw/bO/Jra0bzVPuWbgXSBMdBNuK0e1f49mSONh99YP//5ze9/6heC7+wqXQv8OjH0UwFwvs0G7rHfL+LLbmK4+7Kuwl2Z8eIjfe6iylGZOEsO91xLCracXeTq+Pb44aNdrfAW8BLW8b0J6I5l/GYREFhTTyVWb1iCkAZaN4P+GbiYYHU2M2R1tXW2XAdQB3xj64m1vTcFMJH8QClQKoRaoBF+0ImWdzok0Ge01vuBExN0T2s4nQqgIsbwcJM10xa+FdnoQSJ6SHXG81seOm/TbfoLAy3nsriPd+UAAAAASUVORK5CYII=" />
7
8
  <style>
8
9
  :root{
9
10
  --bg:#080b0f;--s1:#0d1117;--s2:#131a22;--s3:#1a2332;
@@ -313,7 +314,62 @@ main{flex:1;overflow:hidden;min-height:0;position:relative}
313
314
  background:var(--s3);border:1px solid var(--border2);
314
315
  color:var(--text);font-size:16px;display:flex;align-items:center;justify-content:center;cursor:pointer}
315
316
  #vid-close:hover{background:var(--red);border-color:var(--red)}
316
- #vid-el{width:100%;max-height:74dvh;background:#000;border-radius:6px;display:block;outline:none}
317
+ #vid-video-area{position:relative}
318
+ #vid-zoom-wrap{overflow:hidden;border-radius:6px}
319
+ #vid-el{width:100%;max-height:74dvh;background:#000;display:block;outline:none}
320
+ #vid-ctrls{display:flex;align-items:center;gap:6px;padding:28px 8px 8px;
321
+ position:absolute;bottom:0;left:0;right:0;
322
+ background:linear-gradient(transparent,rgba(0,0,0,.75));
323
+ border:none;border-radius:0 0 6px 6px;
324
+ opacity:0;pointer-events:none;transition:opacity .25s}
325
+ #vid-video-area.ctrls-visible #vid-ctrls{opacity:1;pointer-events:auto}
326
+ .vc-btn{background:none;border:none;color:rgba(255,255,255,.9);cursor:pointer;font-size:14px;
327
+ width:28px;height:28px;display:flex;align-items:center;justify-content:center;
328
+ border-radius:4px;padding:0;flex-shrink:0;line-height:1}
329
+ .vc-btn:hover{background:rgba(255,255,255,.15);color:#fff}
330
+ .vc-btn.active{color:#fff;background:rgba(255,255,255,.22)}
331
+ #vc-seek{flex:1;height:4px;-webkit-appearance:none;appearance:none;cursor:pointer;
332
+ background:rgba(255,255,255,.3);border-radius:2px;outline:none;accent-color:var(--accent-l)}
333
+ #vc-seek::-webkit-slider-thumb{-webkit-appearance:none;width:13px;height:13px;
334
+ border-radius:50%;background:var(--accent-l);cursor:pointer}
335
+ #vc-seek::-moz-range-thumb{width:13px;height:13px;border-radius:50%;border:none;
336
+ background:var(--accent-l);cursor:pointer}
337
+ #vc-time{font-size:11px;color:rgba(255,255,255,.75);white-space:nowrap;flex-shrink:0;
338
+ font-variant-numeric:tabular-nums;min-width:72px;text-align:center}
339
+ /* Fullscreen overrides */
340
+ #vid-panel:-webkit-full-screen,#vid-panel:fullscreen{background:#000;align-items:stretch;justify-content:stretch}
341
+ #vid-panel:-webkit-full-screen #vid-box,#vid-panel:fullscreen #vid-box{
342
+ width:100%;height:100%;padding:0;border:none;border-radius:0;
343
+ background:#000;box-shadow:none;display:flex;flex-direction:column;max-width:none}
344
+ #vid-panel:-webkit-full-screen #vid-hdr,#vid-panel:fullscreen #vid-hdr,
345
+ #vid-panel:-webkit-full-screen #vid-close,#vid-panel:fullscreen #vid-close,
346
+ #vid-panel:-webkit-full-screen #vid-nav,#vid-panel:fullscreen #vid-nav,
347
+ #vid-panel:-webkit-full-screen #vid-meta,#vid-panel:fullscreen #vid-meta{display:none}
348
+ #vid-panel:-webkit-full-screen #vid-video-area,#vid-panel:fullscreen #vid-video-area{
349
+ flex:1;min-height:0;position:relative}
350
+ #vid-panel:-webkit-full-screen #vid-zoom-wrap,#vid-panel:fullscreen #vid-zoom-wrap{
351
+ position:absolute;inset:0;border-radius:0}
352
+ #vid-panel:-webkit-full-screen #vid-el,#vid-panel:fullscreen #vid-el{
353
+ max-height:none;width:100%;height:100%;object-fit:contain}
354
+ #vid-panel:-webkit-full-screen #vid-ctrls,#vid-panel:fullscreen #vid-ctrls{
355
+ opacity:1;pointer-events:auto;border-radius:0}
356
+ #vid-panel:-webkit-full-screen #vid-err,#vid-panel:fullscreen #vid-err{
357
+ position:absolute;bottom:60px;left:50%;transform:translateX(-50%);white-space:nowrap}
358
+ /* Auto-hide in fullscreen */
359
+ #vid-panel:-webkit-full-screen.ctrls-hidden #vid-ctrls,
360
+ #vid-panel:fullscreen.ctrls-hidden #vid-ctrls,
361
+ #vid-panel:-webkit-full-screen.ctrls-hidden .vid-side-btn,
362
+ #vid-panel:fullscreen.ctrls-hidden .vid-side-btn{opacity:0;pointer-events:none}
363
+ /* Side navigation buttons (fullscreen only) */
364
+ .vid-side-btn{display:none;position:absolute;top:50%;transform:translateY(-50%);
365
+ background:rgba(0,0,0,.45);border:none;color:#fff;cursor:pointer;
366
+ width:44px;height:72px;border-radius:8px;font-size:26px;
367
+ align-items:center;justify-content:center;transition:opacity .3s,background .15s;z-index:5}
368
+ .vid-side-btn:hover{background:rgba(37,99,235,.55)}
369
+ .vid-side-btn:disabled{opacity:.25;cursor:default;pointer-events:none}
370
+ #vid-panel:-webkit-full-screen .vid-side-btn,#vid-panel:fullscreen .vid-side-btn{display:flex}
371
+ #vid-side-prev{left:12px}
372
+ #vid-side-next{right:12px}
317
373
  #vid-err{display:none;margin-top:8px;padding:8px 12px;border-radius:6px;background:rgba(239,68,68,.12);border:1px solid rgba(239,68,68,.35);color:#ef4444;font-size:12px}
318
374
  #vid-meta{margin-top:8px;font-size:11px;color:var(--muted);display:flex;align-items:center;gap:12px}
319
375
  #vid-dl{margin-left:auto;color:var(--accent-l);text-decoration:none;display:flex;align-items:center;gap:4px;padding:3px 8px;border-radius:4px;border:1px solid rgba(37,99,235,.35);transition:background .15s}
@@ -336,7 +392,7 @@ main{flex:1;overflow:hidden;min-height:0;position:relative}
336
392
  #fs-close{margin-left:8px;width:30px;height:30px;border-radius:50%;background:rgba(255,255,255,.1);
337
393
  border:none;color:#fff;font-size:18px;display:flex;align-items:center;justify-content:center;cursor:pointer}
338
394
  #fs-close:hover{background:rgba(255,255,255,.2)}
339
- #fs-body{flex:1;position:relative;min-height:0;display:flex}
395
+ #fs-body{flex:1;position:relative;min-height:0;display:flex;overflow:hidden}
340
396
  #fs-img{flex:1;width:100%;object-fit:contain;display:block;min-height:0}
341
397
  #fs-body .ptz-overlay{position:absolute;inset:0}
342
398
 
@@ -8026,7 +8082,18 @@ main{flex:1;overflow:hidden;min-height:0;position:relative}
8026
8082
  <div id="vid-title"></div>
8027
8083
  <div id="vid-cam"></div>
8028
8084
  </div>
8029
- <video id="vid-el" controls playsinline preload="auto" onerror="showVidErr()"></video>
8085
+ <div id="vid-video-area">
8086
+ <div id="vid-zoom-wrap"><video id="vid-el" playsinline preload="auto" onerror="showVidErr()"></video></div>
8087
+ <div id="vid-ctrls">
8088
+ <button class="vc-btn" id="vc-play" title="Play/Pause"></button>
8089
+ <span id="vc-time">0:00 / 0:00</span>
8090
+ <input id="vc-seek" type="range" min="0" max="1000" value="0" step="1">
8091
+ <button class="vc-btn" id="vc-mute" title="Ton"></button>
8092
+ <button class="vc-btn" id="vc-fs" title="Vollbild"></button>
8093
+ </div>
8094
+ </div>
8095
+ <button class="vid-side-btn" id="vid-side-prev">&#8249;</button>
8096
+ <button class="vid-side-btn" id="vid-side-next">&#8250;</button>
8030
8097
  <div id="vid-err"></div>
8031
8098
  <div id="vid-nav">
8032
8099
  <button id="vid-prev" onclick="playRecIdx(recPlayIdx - 1)" data-i18n="vidPrev">&#8249; Previous</button>
@@ -9616,8 +9683,110 @@ function toggleRec(key, btn, tile) {
9616
9683
  .catch(() => {});
9617
9684
  }
9618
9685
 
9686
+ /* ─────────────────────────── Zoom ──────────────────────────── */
9687
+ let _resetFsZoom = () => {};
9688
+ let _resetVidZoom = () => {};
9689
+ let _normalCtrlsTimer = null;
9690
+
9691
+ function makeZoomable(el, allowDbl, transformEl) {
9692
+ const tgt = transformEl || el;
9693
+ let sc = 1, tx = 0, ty = 0;
9694
+ let px = false, pd = 0, ps = 1, ptx = 0, pty = 0, pmx = 0, pmy = 0;
9695
+ let pan = false, psx = 0, psy = 0, ptxs = 0, ptys = 0;
9696
+ let lastTap = 0;
9697
+
9698
+ el.style.touchAction = 'none';
9699
+ tgt.style.transformOrigin = '0 0';
9700
+
9701
+ function apply(anim) {
9702
+ tgt.style.transition = anim ? 'transform 0.2s ease-out' : 'none';
9703
+ tgt.style.transform = sc === 1 ? '' : `translate(${tx}px,${ty}px) scale(${sc})`;
9704
+ }
9705
+ function clamp() {
9706
+ if (sc <= 1) { tx = 0; ty = 0; return; }
9707
+ const pw = el.clientWidth, ph = el.clientHeight;
9708
+ tx = Math.max(pw * (1 - sc), Math.min(0, tx));
9709
+ ty = Math.max(ph * (1 - sc), Math.min(0, ty));
9710
+ }
9711
+
9712
+ el.addEventListener('touchstart', e => {
9713
+ if (e.touches.length >= 2) {
9714
+ px = true; pan = false;
9715
+ pd = Math.hypot(e.touches[1].clientX - e.touches[0].clientX, e.touches[1].clientY - e.touches[0].clientY);
9716
+ ps = sc; ptx = tx; pty = ty;
9717
+ const r = el.getBoundingClientRect();
9718
+ pmx = (e.touches[0].clientX + e.touches[1].clientX) / 2 - r.left;
9719
+ pmy = (e.touches[0].clientY + e.touches[1].clientY) / 2 - r.top;
9720
+ e.preventDefault();
9721
+ } else if (e.touches.length === 1) {
9722
+ if (sc > 1) {
9723
+ pan = true;
9724
+ psx = e.touches[0].clientX; psy = e.touches[0].clientY;
9725
+ ptxs = tx; ptys = ty;
9726
+ e.preventDefault();
9727
+ }
9728
+ if (allowDbl) {
9729
+ const now = Date.now();
9730
+ if (now - lastTap < 300) {
9731
+ const r = el.getBoundingClientRect();
9732
+ const mx = e.touches[0].clientX - r.left, my = e.touches[0].clientY - r.top;
9733
+ if (sc > 1) { sc = 1; tx = 0; ty = 0; }
9734
+ else { sc = 2.5; tx = mx * (1 - sc); ty = my * (1 - sc); clamp(); }
9735
+ apply(true); e.preventDefault();
9736
+ }
9737
+ lastTap = now;
9738
+ }
9739
+ }
9740
+ }, { passive: false });
9741
+
9742
+ el.addEventListener('touchmove', e => {
9743
+ if (px && e.touches.length >= 2) {
9744
+ const d = Math.hypot(e.touches[1].clientX - e.touches[0].clientX, e.touches[1].clientY - e.touches[0].clientY);
9745
+ const ns = Math.max(1, Math.min(8, ps * (d / pd)));
9746
+ tx = pmx - (pmx - ptx) * (ns / ps);
9747
+ ty = pmy - (pmy - pty) * (ns / ps);
9748
+ sc = ns; clamp(); apply(false); e.preventDefault();
9749
+ } else if (pan && e.touches.length === 1) {
9750
+ tx = ptxs + e.touches[0].clientX - psx;
9751
+ ty = ptys + e.touches[0].clientY - psy;
9752
+ clamp(); apply(false); e.preventDefault();
9753
+ }
9754
+ }, { passive: false });
9755
+
9756
+ el.addEventListener('touchend', e => {
9757
+ if (e.touches.length < 2) px = false;
9758
+ if (e.touches.length === 0) pan = false;
9759
+ });
9760
+
9761
+ el.addEventListener('wheel', e => {
9762
+ e.preventDefault(); e.stopPropagation();
9763
+ const r = el.getBoundingClientRect();
9764
+ const mx = e.clientX - r.left, my = e.clientY - r.top;
9765
+ const ns = Math.max(1, Math.min(8, sc * (e.deltaY < 0 ? 1.2 : 1 / 1.2)));
9766
+ if (ns === sc) return;
9767
+ tx = mx - (mx - tx) * (ns / sc);
9768
+ ty = my - (my - ty) * (ns / sc);
9769
+ sc = ns;
9770
+ if (sc <= 1) { sc = 1; tx = 0; ty = 0; }
9771
+ clamp(); apply(false);
9772
+ }, { passive: false });
9773
+
9774
+ if (allowDbl) {
9775
+ el.addEventListener('dblclick', e => {
9776
+ const r = el.getBoundingClientRect();
9777
+ const mx = e.clientX - r.left, my = e.clientY - r.top;
9778
+ if (sc > 1) { sc = 1; tx = 0; ty = 0; }
9779
+ else { sc = 2.5; tx = mx * (1 - sc); ty = my * (1 - sc); clamp(); }
9780
+ apply(true); e.stopPropagation();
9781
+ });
9782
+ }
9783
+
9784
+ return () => { sc = 1; tx = 0; ty = 0; apply(false); };
9785
+ }
9786
+
9619
9787
  /* ─────────────────────────── Fullscreen ────────────────────── */
9620
9788
  function openFs(cam, key) {
9789
+ _resetFsZoom();
9621
9790
  document.getElementById('fs-name').textContent = cam.name;
9622
9791
  const fi = document.getElementById('fs-img');
9623
9792
  const fv = document.getElementById('fs-vid');
@@ -9732,6 +9901,7 @@ document.getElementById('fs-panel').addEventListener('mouseenter', _fsActivity);
9732
9901
  function closeFs() {
9733
9902
  if (_fsHdrTimer) { clearTimeout(_fsHdrTimer); _fsHdrTimer = null; }
9734
9903
  if (document.fullscreenElement) document.exitFullscreen();
9904
+ _resetFsZoom();
9735
9905
  const fi = document.getElementById('fs-img');
9736
9906
  const fv = document.getElementById('fs-vid');
9737
9907
  const fsCam = document.getElementById('fs-panel').dataset.cam;
@@ -9852,8 +10022,9 @@ function buildRecCamSel() {
9852
10022
  loadAndFilterRec(true);
9853
10023
  }
9854
10024
 
9855
- let _recPrevNewest = '';
10025
+ let _recPrevNewest = '', _recNeedsReload = false;
9856
10026
  async function loadAndFilterRec(silent = false) {
10027
+ if (document.hidden) { _recNeedsReload = true; return; }
9857
10028
  const camKeys = Object.keys(cameras);
9858
10029
  if (!camKeys.length) return;
9859
10030
  const keys = selectedCameras.size ? [...selectedCameras].filter(k => cameras[k]) : camKeys;
@@ -10232,10 +10403,15 @@ function renderTimeline(items, multiCam) {
10232
10403
  }
10233
10404
 
10234
10405
  function updateNavBtns() {
10235
- document.getElementById('vid-prev').disabled = recPlayIdx <= 0;
10236
- document.getElementById('vid-next').disabled = recPlayIdx >= recPlayList.length - 1;
10406
+ const atStart = recPlayIdx <= 0, atEnd = recPlayIdx >= recPlayList.length - 1;
10407
+ document.getElementById('vid-prev').disabled = atStart;
10408
+ document.getElementById('vid-next').disabled = atEnd;
10237
10409
  document.getElementById('vid-pos').textContent =
10238
10410
  recPlayList.length ? (recPlayIdx + 1) + ' / ' + recPlayList.length : '';
10411
+ const sp = document.getElementById('vid-side-prev');
10412
+ const sn = document.getElementById('vid-side-next');
10413
+ if (sp) sp.disabled = atStart;
10414
+ if (sn) sn.disabled = atEnd;
10239
10415
  }
10240
10416
  function playRecIdx(idx) {
10241
10417
  if (idx < 0 || idx >= recPlayList.length) return;
@@ -10248,6 +10424,7 @@ function showVidErr() {
10248
10424
  el.textContent = t('vidFmtErr');
10249
10425
  }
10250
10426
  function playRec(rec, cam, idx) {
10427
+ _resetVidZoom();
10251
10428
  const url = rec.video || rec.url || '';
10252
10429
  if (!url) return;
10253
10430
  const src = url.startsWith('/') ? url : (url.startsWith('http') ? url : BASE + url);
@@ -10263,12 +10440,22 @@ function playRec(rec, cam, idx) {
10263
10440
  updateNavBtns();
10264
10441
  document.getElementById('vid-panel').classList.add('open');
10265
10442
  el.play().catch(() => {});
10443
+ const va = document.getElementById('vid-video-area');
10444
+ if (va) {
10445
+ va.classList.add('ctrls-visible');
10446
+ clearTimeout(_normalCtrlsTimer);
10447
+ _normalCtrlsTimer = setTimeout(() => { if (!document.fullscreenElement) va.classList.remove('ctrls-visible'); }, 2500);
10448
+ }
10266
10449
  }
10267
10450
  function closeVideo() {
10451
+ if (document.fullscreenElement) document.exitFullscreen();
10452
+ _resetVidZoom();
10268
10453
  const el = document.getElementById('vid-el');
10269
10454
  el.pause(); el.removeAttribute('src'); el.load();
10270
10455
  document.getElementById('vid-err').style.display = 'none';
10271
10456
  document.getElementById('vid-panel').classList.remove('open');
10457
+ const va2 = document.getElementById('vid-video-area');
10458
+ if (va2) { va2.classList.remove('ctrls-visible'); clearTimeout(_normalCtrlsTimer); }
10272
10459
  resetDelBtn();
10273
10460
  }
10274
10461
 
@@ -10469,6 +10656,8 @@ document.addEventListener('visibilitychange', () => {
10469
10656
  else if (fsStype === 'mp4')
10470
10657
  createFlvPlayer(fv, flvStreamUrl(cameras[fsCam].oid, cameras[fsCam].aspect), 'fs_' + fsCam);
10471
10658
  }
10659
+ // Reload recordings if a fetch was skipped while hidden
10660
+ if (_recNeedsReload) { _recNeedsReload = false; loadAndFilterRec(true); }
10472
10661
  }
10473
10662
  });
10474
10663
 
@@ -10714,15 +10903,138 @@ loadConfig().then(() => loadData()).then(() => {
10714
10903
  setInterval(loadSysStats, 60000);
10715
10904
  });
10716
10905
 
10717
- // Swipe left/right in video player for next/prev recording
10906
+ // Swipe navigation removed — conflicts with pinch-zoom pan gesture
10907
+
10908
+ // Custom controls for recordings player
10718
10909
  (function() {
10719
- let _sx = 0;
10720
- const box = document.getElementById('vid-box');
10721
- box.addEventListener('touchstart', e => { _sx = e.touches[0].clientX; }, { passive: true });
10722
- box.addEventListener('touchend', e => {
10723
- const dx = e.changedTouches[0].clientX - _sx;
10724
- if (Math.abs(dx) > 55) dx < 0 ? playRecIdx(recPlayIdx + 1) : playRecIdx(recPlayIdx - 1);
10725
- }, { passive: true });
10910
+ const el = document.getElementById('vid-el');
10911
+ const play = document.getElementById('vc-play');
10912
+ const mute = document.getElementById('vc-mute');
10913
+ const seek = document.getElementById('vc-seek');
10914
+ const time = document.getElementById('vc-time');
10915
+ if (!el || !play) return;
10916
+
10917
+ const IC_PLAY = `<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor"><polygon points="2,1 11,6 2,11"/></svg>`;
10918
+ const IC_PAUSE = `<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor"><rect x="1.5" y="1" width="3.5" height="10" rx="1"/><rect x="7" y="1" width="3.5" height="10" rx="1"/></svg>`;
10919
+ const IC_VOL = `<svg width="14" height="12" viewBox="0 0 14 12" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"><polygon points="1,4 5,4 9,1 9,11 5,8 1,8" fill="currentColor" stroke="none"/><path d="M10.5 3.5q2 2.5 0 5" stroke-width="1.4"/><path d="M12 1.5q3.5 4.5 0 9" stroke-width="1.4"/></svg>`;
10920
+ const IC_MUTE = `<svg width="14" height="12" viewBox="0 0 14 12" fill="currentColor"><polygon points="1,4 5,4 9,1 9,11 5,8 1,8"/><line x1="11" y1="3.5" x2="14" y2="8.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><line x1="14" y1="3.5" x2="11" y2="8.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>`;
10921
+
10922
+ play.innerHTML = IC_PLAY;
10923
+ mute.innerHTML = IC_VOL;
10924
+
10925
+ function fmt(s) {
10926
+ if (!isFinite(s) || s < 0) return '0:00';
10927
+ const m = Math.floor(s / 60), sec = Math.floor(s % 60);
10928
+ return m + ':' + String(sec).padStart(2, '0');
10929
+ }
10930
+ function syncTime() {
10931
+ time.textContent = fmt(el.currentTime) + ' / ' + fmt(el.duration);
10932
+ }
10933
+
10934
+ let isSeeking = false;
10935
+ el.addEventListener('play', () => { play.innerHTML = IC_PAUSE; });
10936
+ el.addEventListener('pause', () => { play.innerHTML = IC_PLAY; });
10937
+ el.addEventListener('ended', () => { play.innerHTML = IC_PLAY; });
10938
+ el.addEventListener('loadedmetadata', () => { seek.value = 0; syncTime(); });
10939
+ el.addEventListener('timeupdate', () => { if (!isSeeking) { seek.value = el.duration ? (el.currentTime / el.duration) * 1000 : 0; syncTime(); } });
10940
+ el.addEventListener('volumechange', () => { mute.innerHTML = el.muted ? IC_MUTE : IC_VOL; });
10941
+
10942
+ play.addEventListener('click', () => { el.paused ? el.play().catch(() => {}) : el.pause(); });
10943
+ mute.addEventListener('click', () => { el.muted = !el.muted; });
10944
+
10945
+ seek.addEventListener('mousedown', () => { isSeeking = true; });
10946
+ seek.addEventListener('touchstart', () => { isSeeking = true; }, { passive: true });
10947
+ seek.addEventListener('input', () => { if (el.duration) { el.currentTime = (seek.value / 1000) * el.duration; syncTime(); } });
10948
+ seek.addEventListener('mouseup', () => { isSeeking = false; });
10949
+ seek.addEventListener('touchend', () => { isSeeking = false; });
10950
+ })();
10951
+
10952
+ // Init fullscreen zoom (double-tap / double-click / pinch / scroll-wheel)
10953
+ (function() {
10954
+ const fi = document.getElementById('fs-img');
10955
+ const fv = document.getElementById('fs-vid');
10956
+ const r1 = makeZoomable(fi, true);
10957
+ const r2 = makeZoomable(fv, true);
10958
+ _resetFsZoom = () => { r1(); r2(); };
10959
+
10960
+ // Recordings player: events on wrapper (overflow:hidden clips), transform on video element
10961
+ const vw = document.getElementById('vid-zoom-wrap');
10962
+ const ve = document.getElementById('vid-el');
10963
+ if (vw && ve) _resetVidZoom = makeZoomable(vw, false, ve);
10964
+
10965
+ const IC_FS_ENTER = `<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M1 5V1h4M9 1h4v4M13 9v4H9M5 13H1V9"/></svg>`;
10966
+ const IC_FS_EXIT = `<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M5 1v4H1M9 1v4h4M9 13v-4h4M1 9h4v4"/></svg>`;
10967
+ const fsBtn = document.getElementById('vc-fs');
10968
+
10969
+ // Fullscreen + auto-hide
10970
+ const vidPanel = document.getElementById('vid-panel');
10971
+ if (fsBtn && vidPanel) {
10972
+ fsBtn.innerHTML = IC_FS_ENTER;
10973
+
10974
+ let _fsHideTimer = null;
10975
+ function _vidActivity() {
10976
+ if (!document.fullscreenElement) return;
10977
+ vidPanel.classList.remove('ctrls-hidden');
10978
+ if (_fsHideTimer) clearTimeout(_fsHideTimer);
10979
+ const el2 = document.getElementById('vid-el');
10980
+ if (el2 && !el2.paused) _fsHideTimer = setTimeout(() => vidPanel.classList.add('ctrls-hidden'), 3000);
10981
+ }
10982
+ vidPanel.addEventListener('mousemove', _vidActivity);
10983
+ vidPanel.addEventListener('touchstart', _vidActivity, { passive: true });
10984
+
10985
+ document.addEventListener('fullscreenchange', () => {
10986
+ const inFs = !!document.fullscreenElement;
10987
+ fsBtn.innerHTML = inFs ? IC_FS_EXIT : IC_FS_ENTER;
10988
+ _resetVidZoom();
10989
+ if (!inFs) { vidPanel.classList.remove('ctrls-hidden'); if (_fsHideTimer) { clearTimeout(_fsHideTimer); _fsHideTimer = null; } }
10990
+ else _vidActivity();
10991
+ });
10992
+
10993
+ fsBtn.addEventListener('click', () => {
10994
+ if (!document.fullscreenElement) vidPanel.requestFullscreen().catch(() => {});
10995
+ else document.exitFullscreen();
10996
+ });
10997
+
10998
+ const el2 = document.getElementById('vid-el');
10999
+ if (el2) {
11000
+ el2.addEventListener('play', _vidActivity);
11001
+ el2.addEventListener('pause', () => { vidPanel.classList.remove('ctrls-hidden'); if (_fsHideTimer) { clearTimeout(_fsHideTimer); _fsHideTimer = null; } });
11002
+ }
11003
+ }
11004
+
11005
+ const sp = document.getElementById('vid-side-prev');
11006
+ const sn = document.getElementById('vid-side-next');
11007
+ if (sp) sp.addEventListener('click', () => playRecIdx(recPlayIdx - 1));
11008
+ if (sn) sn.addEventListener('click', () => playRecIdx(recPlayIdx + 1));
11009
+
11010
+ // Normal-view controls: show on hover/touch, hide on leave
11011
+ const vidArea = document.getElementById('vid-video-area');
11012
+ if (vidArea) {
11013
+ vidArea.addEventListener('mouseenter', () => { if (!document.fullscreenElement) vidArea.classList.add('ctrls-visible'); });
11014
+ vidArea.addEventListener('mouseleave', () => { if (!document.fullscreenElement) vidArea.classList.remove('ctrls-visible'); });
11015
+ vidArea.addEventListener('touchstart', () => {
11016
+ if (!document.fullscreenElement) {
11017
+ vidArea.classList.add('ctrls-visible');
11018
+ clearTimeout(_normalCtrlsTimer);
11019
+ _normalCtrlsTimer = setTimeout(() => vidArea.classList.remove('ctrls-visible'), 2500);
11020
+ }
11021
+ }, { passive: true });
11022
+ }
11023
+
11024
+ // Grid tiles: pinch + scroll-wheel only (no double-tap, single-tap opens fullscreen)
11025
+ const grid = document.getElementById('cam-grid');
11026
+ if (grid) {
11027
+ new MutationObserver(mutations => {
11028
+ mutations.forEach(m => {
11029
+ m.addedNodes.forEach(node => {
11030
+ if (node.classList && node.classList.contains('cam-tile')) {
11031
+ const el = node.querySelector('img, video');
11032
+ if (el) makeZoomable(el, false);
11033
+ }
11034
+ });
11035
+ });
11036
+ }).observe(grid, { childList: true });
11037
+ }
10726
11038
  })();
10727
11039
  </script>
10728
11040
  <script src="/socket.io/socket.io.js"></script>