surprise
2023-12-29 18377dc5d61caf3a6a0835e17015ac2601f8709d
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
<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>H5playerVue</title>
    <link rel="stylesheet" href="./static/css/antd.min.css">
    <style>
        html,
        body {
            height: 100%;
            width: 100%;
            margin: 0px;
            padding: 0px;
            overflow: hidden;
        }
 
        ::-webkit-media-controls {
            display: none !important;
        }
 
        @media screen and (max-width: 991px) {
            #player {
                width: calc(100vw - 16px);
                height: calc((100vw - 16px) * 5 / 8);
            }
        }
 
        @media screen and (min-width: 992px) {
            #player {
                width: calc(50vw - 8px);
                height: calc((50vw - 8px) * 5 / 8);
            }
        }
    </style>
</head>
 
<body>
 
 
    <div id="player"></div>
 
 
    <!-- <script src="./static/js/moment.js"></script>
    <script src="./static/js/moment.js"></script>
    <script src="./static/js/vue.js"></script>
    <script src="./static/js/antd.min.js"></script>
    <script src="./static/js/antd-with-locales.min.js"></script> -->
    <script src="./static/js/jquery-1.12.4.min.js"></script>
    <script src="./h5player.min.js"></script>
    <script>
 
        var player = null;
        function GetQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }
        function setSize() {
            var width = $(window).width();
            var height = $(window).height();
            $("#player").width(width);
            $("#player").height(height);
            player && player.JS_Resize(width, height)
        }
        function init() {
            var code = GetQueryString("code");
            // 设置播放容器的宽高并监听窗口大小变化
            window.addEventListener('resize', () => {
                setSize()
            })
            createPlayer();
            if (code) {
                $.ajax({
                    url: "http://10.10.4.116:8086/getCamerasInfo?cameraIndexCode=" + code, success: function (result) {
                        try {
                            var data = JSON.parse(result);
                            realplay(data.data.url);
                        } catch (e) {
 
                        }
                    }
                });
            }
        }
        function createPlayer() {
            player = new window.JSPlugin({
                szId: 'player',
                szBasePath: "./",
                iMaxSplit: 1,
                iCurrentSplit: 1,
                openDebug: true,
                oStyle: {
                    borderSelect: '#000',
                }
            })
            setSize()
        }
        function arrangeWindow() {
            let splitNum = 1
            this.player.JS_ArrangeWindow(splitNum).then(
                () => { console.log(`arrangeWindow to ${splitNum}x${splitNum} success`) },
                e => { console.error(e) }
            )
        }
        function wholeFullScreen() {
            this.player.JS_FullScreenDisplay(true).then(
                () => { console.log(`wholeFullScreen success`) },
                e => { console.error(e) }
            )
        }
        /* 预览&对讲 */
        function realplay(url) {
            var mode = 1;
            var index = player.currentWindowIndex;
            var playURL = url;
 
            player.JS_Play(playURL, { playURL, mode }, index).then(
                () => { console.log('realplay success') },
                e => { console.error(e); alert("视频请求失败!") }
            )
        }
        $(function () {
            init();
        });
    </script>
</body>
 
</html>