From 510c29eecab77493816d3f0cdb5e5c4462083cc8 Mon Sep 17 00:00:00 2001 From: ‘liusuyi’ <1951119284@qq.com> Date: 星期二, 29 八月 2023 14:03:55 +0800 Subject: [PATCH] 增加流媒体数据库业务 增加电子围栏接口 --- ard-work/src/main/resources/templates/mediaMTX.html | 36 ++++++++++++++++++++++++++++++------ 1 files changed, 30 insertions(+), 6 deletions(-) diff --git a/ard-work/src/main/resources/templates/mediaMTX.html b/ard-work/src/main/resources/templates/mediaMTX.html index 2ae58db..b3a39ee 100644 --- a/ard-work/src/main/resources/templates/mediaMTX.html +++ b/ard-work/src/main/resources/templates/mediaMTX.html @@ -10,7 +10,7 @@ .video-container { display: inline-block; vertical-align: top; - width: 25%; /* 鍏釜瑙嗛骞冲潎鍒嗛厤涓�琛岀殑瀹藉害 */ + width: 33%; /* 3涓棰戝钩鍧囧垎閰嶄竴琛岀殑瀹藉害 */ /*padding: 2px; !* 鍙互鏍规嵁闇�瑕佽皟鏁村唴杈硅窛 *!*/ box-sizing: border-box; } @@ -42,7 +42,16 @@ </div> </div> <script th:inline="javascript"> - const restartPause = 2000; + var chanMap = new Map(); + window.onload = function () { + + chanMap.set("video1", "http://127.0.0.1:8889/164/"); + chanMap.set("video2", "http://127.0.0.1:8889/164/"); + chanMap.set("video3", "http://127.0.0.1:8889/164/"); + chanMap.set("video4", "http://127.0.0.1:8889/165/"); + chanMap.set("video5", "http://127.0.0.1:8889/165/"); + console.log(chanMap); + } const linkToIceServers = (links) => ( (links !== null) ? links.split(', ').map((link) => { const m = link.match(/^<(.+?)>; rel="ice-server"(; username="(.*?)"; credential="(.*?)"; credential-type="password")?/i); @@ -260,22 +269,37 @@ this.eTag = ''; this.queuedCandidates = []; } + + stop() { + if (this.pc) { + try { + this.pc.close(); + } catch (e) { + console.log("Failure close peer connection:" + e); + } + this.pc = null; + } + } } let videoMap = new Map(); $('video').click(function (e) { let ID = e.target.id;//鑾峰彇褰撳墠鐐瑰嚮浜嬩欢鐨勫厓绱� console.log(ID); + console.log(videoMap); if (videoMap.get(ID) != null) { - closeVideo(ID, videoMap.get(ID)); + closeVideo(ID); } else { - let client = new WHEPClient("http://127.0.0.1:8889/165/", ID); + let stream = chanMap.get(ID); + let client = new WHEPClient(stream, ID); videoMap.set(ID, client); } }); + function closeVideo(id) { - let elementById = document.getElementById(id); - elementById.pause(); + console.log("鍏抽棴" + id) + let client = videoMap.get(id); + client.stop(id); videoMap.delete(id); } </script> -- Gitblit v1.9.3