YYC
2023-10-19 6bd36a38fc587ba39bd50e26257ed6ece71363e7
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
<!doctype html>
<html lang="zh-cn" xmlns:th=http://www.thymeleaf.org>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="Pragma" content="no-cache"/>
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate"/>
    <meta http-equiv="Expires" content="0"/>
    <style>
        body {
            display: unset;
            margin: 0;
        }
    </style>
</head>
<body>
<div>
    <div id="divPlugin"></div>
</div>
</body>
<script th:inline="javascript">
    var ip = [[${data.ip}]];
    var port = [[${data.port}]];
    var loginId = [[${data.loginId}]];
    var pwd = [[${data.pwd}]];
    var chanNum = [[${data.chanNum}]];
    var length = [[${length}]];
    var width = [[${width}]];
</script>
<script th:src="@{../../static/js/jquery.min.js}"></script>
<script th:src="@{../../static/plugins/layui/layui.js}"></script>
<script th:src="@{../../static/plugins/hikweb4/webVideoCtrl.js}"></script>
<script th:inline="javascript">
 
    var g_iWndIndex = 0; //可以不用设置这个变量,有窗口参数的接口中,不用传值,开发包会默认使用当前选择窗口
    var layer;
    $(function () {
        layui.use(['layer'], function () {
            layer = layui.layer;
        });
 
        // 检查插件是否已经安装过
        if (-1 == WebVideoCtrl.I_CheckPluginInstall()) {
            alert("您还未安装过插件,双击开发包目录里的WebComponents.exe安装!");
            return;
        }
 
        // 初始化插件参数及插入插件
        WebVideoCtrl.I_InitPlugin(length, width, {
            iWndowType: 1,
            cbSelWnd: function (xmlDoc) {
                g_iWndIndex = $(xmlDoc).find("SelectWnd").eq(0).text();
            }
        });
        WebVideoCtrl.I_InsertOBJECTPlugin("divPlugin");
 
 
        // 检查插件是否最新
        if (-1 == WebVideoCtrl.I_CheckPluginVersion()) {
            alert("检测到新的插件版本,双击开发包目录里的WebComponents.exe升级!");
            return;
        }
        clickLogin();
    });
 
    // 登录
    function clickLogin() {
        var szIP = ip,
            szPort = port,
            szUsername = loginId,
            szPassword = pwd,
            chanNum = chanNum;
        if ("" == szIP || "" == szPort) {
            return;
        }
        var iRet = WebVideoCtrl.I_Login(szIP, 1, szPort, szUsername, szPassword, {
            success: function (xmlDoc) {
                setTimeout(function () {
                    clickStartRealPlay(szIP, chanNum);
                }, 10);
            },
            error: function () {
                layer.msg("登录失败");
            }
        });
        if (-1 == iRet) {
            layer.msg("登录失败");
        }
    }
 
    // 开始预览
    function clickStartRealPlay(ip, chanNum) {
        var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
            szIP = ip,
            iStreamType = parseInt("1", 10),
            iChannelID = parseInt(chanNum, 10),
            bZeroChannel = true,
            szInfo = "";
 
        if ("" == szIP) {
            return;
        }
        if (oWndInfo != null) {// 已经在播放了,先停止
            WebVideoCtrl.I_Stop();
        }
        var iRet = WebVideoCtrl.I_StartRealPlay(szIP, {
            iStreamType: iStreamType,
            iChannelID: iChannelID,
            bZeroChannel: bZeroChannel
        });
        if (0 == iRet) {
            szInfo = "开始预览成功!";
        } else {
            szInfo = "开始预览失败!";
        }
        layer.msg(szInfo);
    }
</script>
</html>