From 76817b8c752b12030ab285bcb5b2effebfa9a248 Mon Sep 17 00:00:00 2001 From: ‘liusuyi’ <1951119284@qq.com> Date: 星期六, 26 八月 2023 17:29:14 +0800 Subject: [PATCH] 流媒体增加webrtc和rtmp协议推拉流 --- ard-work/src/main/resources/templates/test.html | 33 ++++++++++++++++++++++++++------- 1 files changed, 26 insertions(+), 7 deletions(-) diff --git a/ard-work/src/main/resources/templates/test.html b/ard-work/src/main/resources/templates/test.html index 15e9981..a55bf5e 100644 --- a/ard-work/src/main/resources/templates/test.html +++ b/ard-work/src/main/resources/templates/test.html @@ -13,6 +13,20 @@ margin-top: 10px; } </style> + <!-- 瀵煎叆 ECMAScript 妯″潡 --> + <script th:type="module" th:src="@{/js/WHEPClient.js}"></script> + <!-- 鍐呰仈鑴氭湰鍧楋紝鍙互浣跨敤妯″潡涓殑鍐呭 --> + <script th:inline="javascript"> + /*<![CDATA[*/ + // 鍦ㄨ繖閲屼娇鐢� WHEPClient 妯″潡涓殑鍐呭 + $("#play").click(function webrtcClient(){ + const url = "http://127.0.0.1:8889/165"; // add the webRTC URL from your live input here + console.log(url) + const videoElement = document.getElementById("remote-video"); + const client = new WHEPClient(url, videoElement); + }) + /*]]>*/ + </script> <body> <div class="container"> <div class="row "> @@ -127,11 +141,15 @@ <div class="row top-buffer"> <video id="video" muted autoplay loop controls style="width: 800px; height: 100%; object-fit: fill;"/> </div> + <div class="row top-buffer"> + <button id="play" type="button" class="btn btn-default" >鎾斁</button> + <video id="remote-video" controls autoplay muted></video> + </div> </div> </div> </div> <script th:inline="javascript"> - var cameraId, opt, token; + var cameraId, opt,optOpen,optClose, token; window.onload = function () { $.ajax({ url: "../hik/list", @@ -461,8 +479,8 @@ var defogflag = true; $("#Defogcfg").click(function () { cameraId = $('#select option:selected').val(); - optOpen = {"cameraId": cameraId, "channelNum": 1, "enable": true}; - optClose = {"cameraId": cameraId, "channelNum": 1, "enable": false}; + optOpen = {"cameraId": cameraId, "channelNum": 1, "enable": true}; + optClose = {"cameraId": cameraId, "channelNum": 1, "enable": false}; if (defogflag) { $(this).text("鍏抽棴閫忛浘"); defogflag = false; @@ -503,8 +521,8 @@ var infrareflag = true; $("#Infrarecfg").click(function () { cameraId = $('#select option:selected').val(); - optOpen = {"cameraId": cameraId, "channelNum": 1, "enable": true}; - optClose = {"cameraId": cameraId, "channelNum": 1, "enable": false}; + optOpen = {"cameraId": cameraId, "channelNum": 1, "enable": true}; + optClose = {"cameraId": cameraId, "channelNum": 1, "enable": false}; if (infrareflag) { $(this).text("鍏抽棴绾㈠"); infrareflag = false; @@ -545,8 +563,8 @@ var focusModeflag = true; $("#FocusMode").click(function () { cameraId = $('#select option:selected').val(); - optOpen = {"cameraId": cameraId, "channelNum": 1, "enable": true}; - optClose = {"cameraId": cameraId, "channelNum": 1, "enable": false}; + optOpen = {"cameraId": cameraId, "channelNum": 1, "enable": true}; + optClose = {"cameraId": cameraId, "channelNum": 1, "enable": false}; if (focusModeflag) { $(this).text("鑷姩鑱氱劍"); focusModeflag = false; @@ -828,5 +846,6 @@ webRtcServer.disconnect(); } </script> + </body> </html> \ No newline at end of file -- Gitblit v1.9.3