fix
13404089107
7 天以前 a90bcdf047a8baf02aeec81221aeeb49db523cde
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
var hstVideoAll = {
    init: function (domId, width, height, params, playerType) {
        var path = this.getPath();
        this.playerPath = path + '../Content/play_media_stream.swf';
        this.domId = domId;
        this.width = width;
        this.height = height;
        this.version = '11.0.0';
        this.params = params;
        this.windownum = 4;
        if (playerType === 'flash' || playerType === 'h5') {
            this.playerType = playerType;
        }
        //if (this.isBrowseIE()) {
        //    this.playerType = 'flash';
        //}
        if (!this.playerType && localStorage.playerType && localStorage.playerType === 'flash') {
            this.playerType = 'flash';
        }
        if (this.playerType === 'flash') {
            this.loadJs(path + "swfobject.js");
        } else {
            this.loadCss(path + "../css/DPlayer.min.css");
            this.loadCss(path + "../css/swfobject-h5.css");
            this.loadJs(path + "flv.min.js");
            this.loadJs(path + "DPlayer.min.js");
            this.loadJs(path + "swfobject-h5.js");
            this.loadJs(path + "md5.js");
            this.loadJs(path + "HZRecorder.js");
            this.loadJs(path + "HZPlayer.js");
        }
        this.initTimer();
    },
    initTimer: function () {
        if (hstVideoAll.playerType == 'flash') {
            if (typeof swfobject == "undefined") {
                setTimeout(this.initTimer, 300)
            } else {
                swfobject.embedSWF(hstVideoAll.playerPath, hstVideoAll.domId, hstVideoAll.width, hstVideoAll.height, "11.0.0", null, null, hstVideoAll.params, null);
                playerobject = swfobject.getObjectById(hstVideoAll.domId);
            }
            
        } else {
            if (typeof HstH5Video == "undefined") {
                setTimeout(this.initTimer, 300)
            } else {
                var options = {
                    domId: hstVideoAll.domId,
                    width: hstVideoAll.width,
                    height: hstVideoAll.height
                };
                if (hstVideoAll.params.lang) {
                    options.lang = hstVideoAll.params.lang
                }
                playerobject = new HstH5Video(options);
            }
        }
    },
    setWindowCount: function (num) {
        
        if (!num) {
            return;
        }
        num = parseInt(num);
        hstVideoAll.windownum = num;
        this.setWindowNum();
    },
    setWindowNum: function(){
        
        if (typeof playerobject == "undefined") {
                setTimeout(this.setWindowNum, 300)
        } 
        else{
            
            if (hstVideoAll.playerType == 'flash') {
                playerobject.ActionScriptSetWindowsCount(hstVideoAll.windownum);
            }
            else{
                playerobject.setWindowNum(hstVideoAll.windownum);    
            }
        }
    },
    openVideo: function(server,port,devicechannel){
        if (hstVideoAll.playerType == 'flash') {
            playerobject.ActionScriptPlayStream(server,port,devicechannel);
        }
        else{
            playerobject.openVideo(server,port,devicechannel);    
        }
    },
    closeVideo: function(devicechannel){
        if (hstVideoAll.playerType == 'flash') {
            playerobject.ActionScriptClosePlayStream(devicechannel);
        }
        else{
            playerobject.closeVideo(devicechannel);    
        }
    },
    JsStartTalk: function(MediaServerName,MediaTCPPort, VoiceTCPPort,deviceId, channelId, MediaType,username,password){
        if (hstVideoAll.playerType == 'flash') {
            playerobject.JsStartTalk(MediaServerName,MediaTCPPort, deviceId, channelId, MediaType);
        }
        else{
            //playerobject.closeVideo(devicechannel);    
            
           playerobject.StartTalk(MediaServerName,MediaTCPPort, VoiceTCPPort,deviceId, channelId, MediaType,username,password);
        }
    },
    JsStartMonitor: function(MediaServerName,MediaTCPPort, VoiceTCPPort,deviceId, channelId, MediaType,username,password){
        if (hstVideoAll.playerType == 'flash') {
            playerobject.JsStartMonitor(MediaServerName,MediaTCPPort, deviceId, channelId, MediaType);
        }
        else{
            //playerobject.closeVideo(devicechannel);
            playerobject.StartMonitor(MediaServerName,MediaTCPPort, VoiceTCPPort,deviceId, channelId, MediaType,username,password);
        }
    },
    JsStartBroadcast: function(MediaServerName,MediaTCPPort,VoiceTCPPort,type,username,password){
        if (hstVideoAll.playerType == 'flash') {
            playerobject.JsStartBroadcast(MediaServerName,MediaTCPPort, type);
        }
        else{
            //playerobject.closeVideo(devicechannel);    
          playerobject.StartBroadcast(MediaServerName, VoiceTCPPort, type, username, password);
        }
    },
    JsCloseTalk: function(deviceId, channelId){
        if (hstVideoAll.playerType == 'flash') {
            playerobject.JsCloseTalk(deviceId, channelId);
        }
        else{
            playerobject.CloseTalk(deviceId, channelId);    
        }
    },
    JsCloseMonitor: function(deviceId, channelId){
        if (hstVideoAll.playerType == 'flash') {
            playerobject.JsCloseMonitor(deviceId, channelId);
        }
        else{
            playerobject.CloseMonitor(deviceId, channelId);    
        }
    },
    JsCloseBroadcast: function(){
        if (hstVideoAll.playerType == 'flash') {
            playerobject.JsCloseBroadcast();
        }
        else{
            playerobject.CloseBroadcast();    
        }
    },
    StartRemotePlayback: function(server,port,devicechannel,starttime,endtime,callback){
        if (hstVideoAll.playerType == 'flash') {
            playerobject.JavaScriptStartRemotePlayback(server,port,devicechannel,starttime,endtime,2);
        }
        else{
            playerobject.StartRemotePlayback(server,port,devicechannel,starttime,endtime,callback);    
        }
    },
    CloseRemotePlayback: function(devicechannel){
        if (hstVideoAll.playerType == 'flash') {
            playerobject.JavaScriptCloseRemotePlayback(devicechannel);
        }
        else{
            playerobject.CloseRemotePlayback(devicechannel);    
        }
    },
    getPath: function () {
        var scripts = document.getElementsByTagName('script')
        for (let i = 0; i < scripts.length; i++) {
            var src = scripts[i].src;
            if (src.indexOf('swfobject-all.js') > -1) {
                return src.replace(/[^\/]+$/, "");
            }
        }
        return '';
    },
    switchType: function (playerType) {
        if (this.isBrowseIE() && playerType != 'flash') {
            alert('ie浏览器只支持flash播放')
            return;
        }
        if (playerType !== 'flash' && playerType !== 'h5' && playerType !== 'auto') {
            return;
        }
        localStorage.playerType = playerType
        location.reload()
    },
    isBrowseIE: function () {
        return (this.getBrowseVersion().indexOf("msie") != -1) ? true : false;
    },
    getBrowseVersion: function () {
        var userAgent = navigator.userAgent.toLowerCase();
        var browser = userAgent.match(/(firefox|chrome|safari|opera|msie)/);
        var browserId = "msie";
        var browserVersion = "";
        var isIE11 = (userAgent.toLowerCase().indexOf("trident") > -1 && userAgent.indexOf("rv") > -1);
        if (isIE11) {
            browserId = "msie";
            browserVersion = "11.0";
        } else {
            if (browser.length >= 2) {
                browserId = browser[1];
            } else {
                browserId = "msie";
            }
            browserVersion = (userAgent.match(new RegExp('.+(?:version)[\/: ]([\\d.]+)')) || userAgent.match(new RegExp('(?:' + browserId + ')[\/: ]([\\d.]+)')) || [0, '0'])[1];
        }
        return browserId + browserVersion;
    },
    loadCss: function (path) {
        if (!path || path.length === 0) {
            throw new Error('argument "path" is required !');
        }
        var head = document.getElementsByTagName('head')[0];
        var link = document.createElement('link');
        link.href = path;
        link.rel = 'stylesheet';
        link.type = 'text/css';
        head.appendChild(link);
    },
    loadJs: function (path) {
        if (!path || path.length === 0) {
            throw new Error('argument "path" is required !');
        }
        var head = document.getElementsByTagName('head')[0];
        var script = document.createElement('script');
        script.src = path;
        script.type = 'text/javascript';
        head.appendChild(script);
    }
}