北京经济技术开发区经开区虚拟城市项目-【前端】-移动端Web
lixuliang
2024-05-08 f5233339920a59103d53e8efadc6f3f5d0b64f31
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
<!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 - 8/px);
                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()
        }
        function init() {
            var code = GetQueryString("code");
            // 设置播放容器的宽高并监听窗口大小变化
            window.addEventListener('resize', () => {
                setSize()
            })
            createPlayer();
            if (code) {
                $.ajax({
                    url: "https://skyzt.bda.gov.cn/BEApi/getCamerasInfo?cameraIndexCode=" + code, success: function (result) {
                        try {
                            var data = JSON.parse(result);
                            let res;
                            if (data.data.url.includes("41")) {
                                res = data.data.url.replace("ws://10.117.5.41:559/", "wss://skyzt.bda.gov.cn:443/")
                            } else if (data.data.url.includes("42")) {
                                res = data.data.url.replace("ws://10.117.5.42:559/", "wss://skyzt.bda.gov.cn:443/")
                            } else if (data.data.url.includes("43")) {
                                res = data.data.url.replace("ws://10.117.5.43:559/", "wss://skyzt.bda.gov.cn:443/")
                            } else if (data.data.url.includes("45")) {
                                res = data.data.url.replace("ws://10.117.5.45:559/", "wss://skyzt.bda.gov.cn:443/")
                            } else if (data.data.url.includes("46")) {
                                res = data.data.url.replace("ws://10.117.5.46:559/", "wss://skyzt.bda.gov.cn:443/")
                            } else if (data.data.url.includes("47")) {
                                res = data.data.url.replace("ws://10.117.5.47:559/", "wss://skyzt.bda.gov.cn:443/")
                            } else if (data.data.url.includes("28")) {
                                res = data.data.url.replace("ws://10.117.5.28:559/", "wss://skyzt.bda.gov.cn:443/")//视频最新返回地址
                            }
                            realplay(res);
 
                        } catch (e) { }
                    }
                });
            }
        }
        function createPlayer() {
            player = new window.JSPlugin({
                szId: 'player',
                szBasePath: "./",
                // 当容器div#play_window有固定宽高时,可不传iWidth和iHeight,窗口大小将自适应容器宽高
                iWidth: 600,
                iHeight: 400,
                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);
                }
            )
        }
        $(function () {
            init();
        });
    </script>
</body>
 
</html>