Monica视频监控处理程序
xc
2021-04-27 d8a274cd30024a992cbf757cb6738c96a373b368
src/main/resources/public/js/history/historyComponent.js
File was renamed from src/main/resources/public/js/history/historypler.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;
})()