From d8a274cd30024a992cbf757cb6738c96a373b368 Mon Sep 17 00:00:00 2001
From: xc <double72cheng@gmail.com>
Date: Tue, 27 Apr 2021 17:26:35 +0800
Subject: [PATCH] 通过rtsp 实现 通过摄像头ID 实现

---
 src/main/resources/public/js/history/historyComponent.js |   55 ++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 34 insertions(+), 21 deletions(-)

diff --git a/src/main/resources/public/js/history/historypler.js b/src/main/resources/public/js/history/historyComponent.js
similarity index 64%
rename from src/main/resources/public/js/history/historypler.js
rename to src/main/resources/public/js/history/historyComponent.js
index 6f08c17..6776c09 100755
--- a/src/main/resources/public/js/history/historypler.js
+++ b/src/main/resources/public/js/history/historyComponent.js
@@ -1,8 +1,6 @@
 ;!(function () {
 
-
-
-    function Historypler(opt) {
+    function HistoryComponent(opt) {
         if (typeof opt.elem === 'string') {
             opt.elem = document.getElementById(opt.elem);
         }
@@ -14,11 +12,11 @@
         appendContent(this.elem);
 
         let stream_path;
-        let ffurl = opt.ffurl;
-        let code = opt.code;
+        let cameraId = opt.cameraId;
+
         let container = document.getElementById("container");
 
-        let h5lc = new Jessibuca({container, decoder: ffurl, videoBuffer: 0});
+        let h5lc = new Jessibuca({container, decoder: "js/jessibuca/ff.js", videoBuffer: 0});
 
         let hourTimestamp = 3600 * 1000;
         let dayTimestamp = hourTimestamp * 24;
@@ -50,11 +48,16 @@
 
         //播放
         $(".progressTime-left-b-start").on("click", function () {
-            historypler.playVideo(code,currentTimer,function (result) {
-                h5lc.onLoad = function () {
-                    this.play(result.jessicaURL);
-                }
-            });
+            if (opt.rtspUrl){
+                let rtspUrl = opt.rtspUrl;
+                historyComponent.playVideoRTSP(rtspUrl,currentTimer,function (result) {
+                    h5lc.play(result.jessicaURL)
+                });
+            }else {
+                historyComponent.playVideo(cameraId,currentTimer,function (result) {
+                    h5lc.play(result.jessicaURL)
+                });
+            }
         });
 
         let than = this;
@@ -62,7 +65,7 @@
         $(".progressTime-left-b-start stop").on("click", function () {
             $(this).removeClass("stop");
             h5lc.destroy();
-            than.closeVideo(stream_path)
+            than.closeVideo(stream_path);
             than.elem.style.display = 'none';
         });
 
@@ -75,12 +78,23 @@
         element.innerHTML = _content;
     }
 
-    //播放
-    Historypler.prototype.playVideo = function (video_id,starttime, callback) {
+    //播放 - 针对摄像头id
+    HistoryComponent.prototype.playVideo = function (video_id,starttime, callback) {
         $.ajax({
             type: "get",
-            //url: "../../webapi/media/live?param=" + video_id,
-            url: "../../monica/history?param=" + video_id+ "&startTime=" + starttime,
+            url: "../../webapi/media/historical?param=" + video_id+ "&startTime=" + starttime+"&endTime=",
+            timeout: 5000,
+            async: false,
+            success: function (result) {
+                callback(result);
+            }
+        });
+    };
+    //播放 - 针对rtsp
+    HistoryComponent.prototype.playVideoRTSP = function (rtspURL,starttime, callback) {
+        $.ajax({
+            type: "get",
+            url: "../../webapi/media/rtsp/historical?param=" + rtspURL+ "&startTime=" + starttime+"&endTime=",
             timeout: 5000,
             async: false,
             success: function (result) {
@@ -90,12 +104,11 @@
     };
 
     //关闭流
-    Historypler.prototype.closeVideo = function (streamPath) {
+    HistoryComponent.prototype.closeVideo = function (streamPath) {
         if (streamPath && typeof streamPath === "string") {
             $.ajax({
                 type: "get",
-                //url: "../../webapi/media/stop?param=" + streamPath,
-                url: "../../monica/stop?param=" + streamPath,
+                url: "../../webapi/media/stop?param=" + streamPath,
                 async: false,
                 success: function (result) {
                 }
@@ -103,11 +116,11 @@
         }
     };
 
-    Historypler.prototype.close = function () {
+    HistoryComponent.prototype.close = function () {
         this.closeVideo(this.stream_path);
     };
 
-    window.Historypler = Historypler;
+    window.HistoryComponent = HistoryComponent;
 
 })()
 

--
Gitblit v1.9.1