jiazx0107@163.com
2023-07-05 95aa8661cf7499638a9db6ee015be507599bac15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
var timer1;
var timer2;
var timer3;
 
/**
 * 页面最多同时调用三个视频,一个车牌识别,抓拍,三个顺序执行
 * @param lprParam 车牌识别参数
 * @param snapParam1 抓拍参数1
 * @param snapPram2 抓拍参数2
 */
function initVideo(snapParam1, snapParam2, snapPram3) {
 
    //车牌识别播放
    if (snapParam1) {
        $.ajax({
            type: "POST",
            url: "../../inout/api/inout-video-play",
            dataType: "json",
            contentType: "application/json;charset=UTF-8",
            data: JSON.stringify(snapParam1),
            success: function (result) {
                if (result.code != "0000") {
                    layer.msg(result.msg);
                } else {
                    snapDto1 = result.data;
                    initSnapVideo(result.data, 1);
                }
                //执行第二个
                initVideo2(snapParam2, snapPram3);
            },
            error: function () {
                layer.msg("过程1摄像头配置失败……");
                //执行第二个
                initVideo2(snapParam2, snapPram3);
            }
        });
    } else {
        initVideo2(snapParam2, snapPram3);
    }
}
 
function initVideo2(snapParam2, snapParam3) {
    if (snapParam2) {
        $.ajax({
            type: "POST",
            url: "../../inout/api/inout-video-play",
            dataType: "json",
            contentType: "application/json;charset=UTF-8",
            data: JSON.stringify(snapParam2),
            success: function (result) {
                if (result.code != "0000") {
                    layer.msg(result.msg);
                } else {
                    snapDto2 = result.data;
                    initSnapVideo(result.data, 2);
                }
                //执行第三个
                initVideo3(snapParam3);
            },
            error: function () {
                layer.msg("过程2摄像头配置失败……");
                //执行第三个
                initVideo3(snapParam3);
            }
        });
    } else {
        initVideo3(snapParam3);
    }
}
 
function initVideo3(snapParam3) {
    if (!snapParam3) return;
    $.ajax({
        type: "POST",
        url: "../../inout/api/inout-video-play",
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(snapParam3),
        success: function (result) {
            if (result.code != "0000") {
                layer.msg(result.msg);
            } else {
                snapDto3 = result.data;
                initSnapVideo(result.data, 3);
            }
        },
        error: function () {
            layer.msg("过程3摄像头配置失败……");
        }
    });
}
 
 
/**
 * 视频播放
 * @param data
 * @param order
 */
function initSnapVideo(data, order) {
    var htm = "";
    //海康web4.0播放
    if (PlayType.HIK_WEB4 == data.playType) {
        var url = "../../inout/api/iframe-hik?id=" + data.id;
        if (ship && ship == "ship") { //船运称重页面
            url += "&length=340&width=195";
        } else { //称重页面
            url += "&length=310&width=170";
        }
        htm = '<iframe src=' + url + ' style="width: 100%;height: 100%"></iframe>';
    }
    //VLC播放
    if (PlayType.VLC == data.playType) {
        htm = "<object type='application/x-vlc-plugin' "
            + "events='true' width='100%' height='100%'"
            + "pluginspage='http://www.videolan.org'"
            + "th:codebase='@{../../static/plugins/vlc/npapi-vlc-2.2.2.tar.xz}'>\n"
            + "<param name='mrl' value='" + data.playAddr + "'/>\n"
            + "<param name='volume' value='50'/>\n"
            + "<param name='autoplay' value='true'/>\n"
            + "<param name='loop' value='false'/>\n"
            + "<param name='fullscreen' value='true'/>\n"
            + "<param name='toolbar' value='false'/>\n" + "</object>";
    }
    //流媒体播放
    if (PlayType.FZZY_GB == data.playType) {
        var id = "easyPlayer" + order;
        htm = "<easy-player live=true' show-custom-button='true' auto-play='true' muted='true' id='" + id + "' "
            + " video-url='" + data.playAddr + "'"
            + "></easy-player>";
 
        //定时器-保活直播
        if (order == 1) {
            if (timer1) clearInterval(timer1);
            timer1 = setInterval(function () {
                keepAlive(data);
            }, 15 * 1000);
        }
 
        if (order == 2) {
            if (timer2) clearInterval(timer2);
            timer2 = setInterval(function () {
                keepAlive(data);
            }, 15 * 1000);
        }
        if (order == 3) {
            if (timer3) clearInterval(timer3);
            timer3 = setInterval(function () {
                keepAlive(data);
            }, 15 * 1000);
        }
    }
 
    if (1 == order) {
        $("#kccz-r-video1").append(htm);
    }
    if (2 == order) {
        $("#kccz-r-video2").append(htm);
    }
    if (3 == order) {
        $("#kccz-r-video3").append(htm);
    }
}
 
/**
 * 保活,msg参数为了防止浏览器缓存
 */
function keepAlive(data) {
    var param = {
        playType: data.playType,
        sn: data.sn,
        ip: data.ip,
        msg: Math.random()
    };
    $.ajax({
        type: 'POST',
        url: "../../inout/api/video-keep-alive",
        dataType: 'JSON',
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(param)
    });
}