wargerm 0.7.4 → 0.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4911,7 +4911,7 @@ var index$2 = /*#__PURE__*/React__default['default'].forwardRef(Index$8);
4911
4911
  var _excluded$c = ["height", "width", "count", "style", "numberStyle"],
4912
4912
  _excluded2$2 = ["count", "numberCount", "width", "height", "marginRight"];
4913
4913
 
4914
- var Number = function Number(_ref) {
4914
+ var Number$1 = function Number(_ref) {
4915
4915
  var height = _ref.height,
4916
4916
  width = _ref.width,
4917
4917
  _ref$count = _ref.count,
@@ -5033,7 +5033,7 @@ var Number = function Number(_ref) {
5033
5033
  })))));
5034
5034
  };
5035
5035
 
5036
- Number.defaultProps = {
5036
+ Number$1.defaultProps = {
5037
5037
  width: 28,
5038
5038
  height: 40
5039
5039
  };
@@ -5070,7 +5070,7 @@ var Index$9 = function Index(props) {
5070
5070
  display: 'flex'
5071
5071
  }
5072
5072
  }, numberList.map(function (res, index) {
5073
- return /*#__PURE__*/React__default['default'].createElement(Number, _objectSpread2({
5073
+ return /*#__PURE__*/React__default['default'].createElement(Number$1, _objectSpread2({
5074
5074
  key: index,
5075
5075
  width: width,
5076
5076
  height: height,
@@ -8383,7 +8383,7 @@ var IconFont = icons.createFromIconfontCN({
8383
8383
  scriptUrl: '//at.alicdn.com/t/font_3425259_s93peuz62an.js'
8384
8384
  });
8385
8385
 
8386
- function VideoPlayer(_ref, ref) {
8386
+ function VideoPlayer$1(_ref, ref) {
8387
8387
  var _ref$footer = _ref.footer,
8388
8388
  footer = _ref$footer === void 0 ? true : _ref$footer,
8389
8389
  style = _ref.style,
@@ -8591,7 +8591,2724 @@ function VideoPlayer(_ref, ref) {
8591
8591
  })) : null));
8592
8592
  }
8593
8593
 
8594
- var index$6 = /*#__PURE__*/React.forwardRef(VideoPlayer);
8594
+ var index$6 = /*#__PURE__*/React.forwardRef(VideoPlayer$1);
8595
+
8596
+ /**
8597
+ * version: v1.1.202301130900
8598
+ */
8599
+ (function () {
8600
+ window.dhPlayerControl = Object.assign({
8601
+ videoWS: null,
8602
+ wsConnectCount: 0,
8603
+ wsSession: '',
8604
+ windowState: '',
8605
+ videoList: {},
8606
+ // 每次创建后,每个videoId 对应的数据类
8607
+ hwndList: {},
8608
+ // 每次创建后对应的 {hwnd: videoId} 键值对
8609
+ callBackList: {},
8610
+ wsConnect: false
8611
+ }, window.dhPlayerControl || {}, {
8612
+ noCardPlayerFlag: false,
8613
+ DHPlayerVersion: '',
8614
+ pkgDHPlayerVerion: [2301102132, 2301121115] // 配套的插件版本号
8615
+
8616
+ }); //在Function的原型上自定义myBind()方法
8617
+
8618
+ Function.prototype.myBind = function myBind(context) {
8619
+ //获取要操作的函数
8620
+ var _this = this; //获取实参(context除外)
8621
+
8622
+
8623
+ var args = Array.prototype.slice.call(arguments, 1); //判断当前浏览器是否兼容bind()方法
8624
+
8625
+ if ('bind' in Function.prototype) {
8626
+ //如果浏览器兼容bind()方法,则使用bind()方法,并返回bind()方法执行后的结果
8627
+ return _this.bind(context, args);
8628
+ } //如果不兼容bind()方法,则返回一个匿名函数
8629
+
8630
+
8631
+ return function () {
8632
+ _this.apply(context, args);
8633
+ };
8634
+ };
8635
+
8636
+ if (!document.getElementsByClassName) {
8637
+ document.getElementsByClassName = function (className, element) {
8638
+ var children = (element || document).getElementsByTagName('*');
8639
+ var elements = new Array();
8640
+
8641
+ for (var i = 0; i < children.length; i++) {
8642
+ var child = children[i];
8643
+ var classNames = child.className.split(' ');
8644
+
8645
+ for (var j = 0; j < classNames.length; j++) {
8646
+ if (classNames[j] == className) {
8647
+ elements.push(child);
8648
+ break;
8649
+ }
8650
+ }
8651
+ }
8652
+
8653
+ return elements;
8654
+ };
8655
+ }
8656
+ /**
8657
+ * 内部方法 封装请求参数
8658
+ * @param {*} param
8659
+ * @param {*} type
8660
+ */
8661
+
8662
+
8663
+ function getAjaxParam(param, type) {
8664
+ // 处理对讲参数
8665
+ var processTalkParam = function processTalkParam(param) {
8666
+ if (param.channelId) {
8667
+ var tempArr = param.channelId.split('$1$0$');
8668
+ !tempArr && (tempArr = param.channelId.split('$'));
8669
+ return tempArr;
8670
+ } else {
8671
+ return [param.deviceCode, param.channelSeq];
8672
+ }
8673
+ };
8674
+
8675
+ var obj = {
8676
+ // 实时预览参数
8677
+ real: {
8678
+ data: {
8679
+ channelId: param.channelId || '',
8680
+ streamType: Number(param.streamType) || 1,
8681
+ // 默认主码流
8682
+ dataType: Number(param.dataType) || 1 // 默认是视频
8683
+
8684
+ }
8685
+ },
8686
+ // 对讲参数
8687
+ talk: {
8688
+ data: {
8689
+ audioBit: 8,
8690
+ sampleRate: 8000,
8691
+ audioType: 0,
8692
+ talkType: getTalkType(param.deviceType),
8693
+ deviceCode: processTalkParam(param)[0],
8694
+ channelSeq: processTalkParam(param)[1]
8695
+ }
8696
+ },
8697
+ // 停止对讲参数
8698
+ stopTalk: {
8699
+ data: {
8700
+ deviceCode: processTalkParam(param)[0],
8701
+ channelSeq: processTalkParam(param)[1],
8702
+ talkType: getTalkType(param.deviceType),
8703
+ session: param.session
8704
+ }
8705
+ },
8706
+ // 通过时间录像回放参数
8707
+ playbackByTime: {
8708
+ clientType: 'WINPC',
8709
+ clientMac: '30:9c:23:79:40:08',
8710
+ clientPushId: '',
8711
+ project: 'PSDK',
8712
+ method: 'SS.Playback.StartPlaybackByTime',
8713
+ data: {
8714
+ nvrId: '',
8715
+ optional: '/admin/API/SS/Playback/StartPlaybackByTime',
8716
+ recordType: '0',
8717
+ // 录像类型:1=一般录像,2=报警录像
8718
+ recordSource: param.recordSource,
8719
+ // 录像来源:1=全部,2=设备,3=中心
8720
+ streamType: param.streamType || 0,
8721
+ // 码流类型: 0=所有码流,1=主码流,2=辅码流
8722
+ channelId: param.channelId,
8723
+ startTime: param.bBack === 0 ? param.currentPlayTime : param.startTime,
8724
+ endTime: param.bBack === 0 ? param.endTime : param.currentPlayTime
8725
+ }
8726
+ },
8727
+ // 通过文件录像回放参数
8728
+ playbackByFile: {
8729
+ clientType: 'WINPC',
8730
+ clientMac: '30:9c:23:79:40:08',
8731
+ clientPushId: '',
8732
+ project: 'PSDK',
8733
+ method: 'SS.Playback.StartPlaybackByFile',
8734
+ data: {
8735
+ ssId: '1001',
8736
+ optional: '/evo-apigw/admin/API/SS/Playback/StartPlaybackByFile',
8737
+ startTime: param.bBack === 0 ? param.currentPlayTime : param.playStartTime,
8738
+ endTime: param.bBack === 0 ? param.playEndTime : param.currentPlayTime,
8739
+ fileName: '{fe69f729-9d4b-42d4-b6a0-56189aaa4e1e}',
8740
+ diskId: '1540852944-1540853395',
8741
+ nvrId: '',
8742
+ recordSource: param.recordSource,
8743
+ channelId: param.channelId,
8744
+ playbackMode: '0',
8745
+ streamId: '5875'
8746
+ }
8747
+ },
8748
+ // 查询录像参数
8749
+ queryRecord: {
8750
+ clientType: 'WINPC',
8751
+ clientMac: '30:9c:23:79:40:08',
8752
+ clientPushId: '',
8753
+ project: 'PSDK',
8754
+ method: 'SS.Record.QueryRecords',
8755
+ data: {
8756
+ cardNo: '',
8757
+ optional: '/admin/API/SS/Record/QueryRecords',
8758
+ diskPath: '',
8759
+ startIndex: '',
8760
+ streamType: param.streamType || 0,
8761
+ // 码流类型:0= 所有码流, 1=主码流, 2=辅码流
8762
+ recordType: '0',
8763
+ // 录像类型:0=全部,1=手动录像,2=报警录像,3=动态监测,4=视频丢失,5=视频遮挡,6=定时录像,7=全天候录像,8=文件录像转换
8764
+ recordSource: param.recordSource,
8765
+ // 录像来源:1=全部,2=设备,3=中心
8766
+ endIndex: '',
8767
+ startTime: param.startTime,
8768
+ endTime: param.endTime,
8769
+ channelId: param.channelId
8770
+ }
8771
+ }
8772
+ }; // 对应的窗口号
8773
+
8774
+ obj[type].snum = param.snum;
8775
+ return JSON.parse(JSON.stringify(obj[type]));
8776
+ }
8777
+ /**
8778
+ * 获取对讲类型
8779
+ * @param { Number } deviceType
8780
+ * @returns talkType 对讲类型 1-设备对讲 2-通道对讲
8781
+ * @mesc 只有NVS{3},NVR{6},smartNVR{14}[已弃用],IVSS{43}能对通道进行对讲。
8782
+ */
8783
+
8784
+
8785
+ function getTalkType(deviceType) {
8786
+ var channelTalk = [3, 6, 14, 43];
8787
+
8788
+ if (channelTalk.includes(Number(deviceType))) {
8789
+ return 2;
8790
+ }
8791
+
8792
+ return 1;
8793
+ }
8794
+ /**
8795
+ * 内部方法
8796
+ * @desc rtsp路径拼接token
8797
+ * @param {Object} 接口返回的rtsp对象
8798
+ */
8799
+
8800
+
8801
+ function dealUrl(data) {
8802
+ var path = data.url;
8803
+
8804
+ if (path.includes('|')) {
8805
+ path = path.split('|').map(function (item) {
8806
+ return item + '?token=' + data.token;
8807
+ }).reverse().join('|');
8808
+ } else {
8809
+ path = path + '?token=' + data.token;
8810
+ }
8811
+
8812
+ return path;
8813
+ }
8814
+ /**
8815
+ * 内部方法
8816
+ * @desc 处理当前浏览器的缩放比例
8817
+ */
8818
+
8819
+
8820
+ function getWindowSize() {
8821
+ var width = window.dhPlayerControl.isPIframe ? this.setting.topInnerWidth : window.top.innerWidth,
8822
+ height = window.dhPlayerControl.isPIframe ? this.setting.topInnerHeight : window.top.innerHeight;
8823
+ return {
8824
+ width: width,
8825
+ height: height
8826
+ };
8827
+ }
8828
+ /**
8829
+ * 内部方法
8830
+ * @desc 获取当前浏览器最左侧距离主屏的位置
8831
+ */
8832
+
8833
+
8834
+ function getScreenX() {
8835
+ // 造个假数据,模拟客户端返回
8836
+ var screenInfo = window.osRatio || [1, 1]; // [主屏的缩放比例, 副屏的缩放比例]
8837
+
8838
+ var defaultScreenX = window.screenX;
8839
+ var availX = window.screen.availLeft;
8840
+ var x = 0;
8841
+
8842
+ if (availX <= 0) {
8843
+ // 不需要计算主屏的位置
8844
+ x = defaultScreenX >= -2 && defaultScreenX <= 9 ? 0 : defaultScreenX; // availX === 0 ? 0 : 1 为 0 表示在主屏上面, 小于 0 表示在副屏上,所以获取的分辨率不同。
8845
+
8846
+ x = x * screenInfo[availX === 0 ? 0 : 1];
8847
+ } else {
8848
+ // 需要计算主屏的位置
8849
+ var sideX = defaultScreenX - availX;
8850
+ sideX = sideX >= -2 && sideX <= 9 ? 0 : sideX; // 计算主屏和副屏的真实距离后相加,即为x
8851
+
8852
+ x = availX * screenInfo[0] + sideX * screenInfo[1];
8853
+ }
8854
+
8855
+ return x;
8856
+ }
8857
+ /**
8858
+ * 内部方法
8859
+ * @desc 获取页面缩放比例
8860
+ */
8861
+
8862
+
8863
+ function detectZoom() {
8864
+ var ratio = 0,
8865
+ screen = window.screen,
8866
+ ua = navigator.userAgent.toLowerCase();
8867
+
8868
+ if (window.devicePixelRatio !== undefined) {
8869
+ ratio = window.devicePixelRatio;
8870
+ } else if (~ua.indexOf('msie')) {
8871
+ if (screen.deviceXDPI && screen.logicalXDPI) {
8872
+ ratio = screen.deviceXDPI / screen.logicalXDPI;
8873
+ }
8874
+ } else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
8875
+ ratio = window.outerWidth / window.innerWidth;
8876
+ }
8877
+
8878
+ if (ratio) {
8879
+ ratio = Math.round(ratio * 100);
8880
+ }
8881
+
8882
+ return ratio;
8883
+ } //socket连接
8884
+
8885
+
8886
+ function socketPort() {
8887
+ var that = this;
8888
+
8889
+ if (typeof WebSocket === 'undefined') {
8890
+ that.setting.createError && that.setting.createError({
8891
+ code: 1005,
8892
+ data: null,
8893
+ success: false,
8894
+ message: '您的浏览器不支持socket!'
8895
+ });
8896
+ return;
8897
+ }
8898
+
8899
+ if (sessionStorage.getItem('HikCentralWebControlPort')) {
8900
+ sessionStorage.removeItem('HikCentralWebControlPort');
8901
+ } // 轮询的端口列表
8902
+
8903
+
8904
+ var portList = [8000, 8001, 8002];
8905
+ var map = {};
8906
+ var id = 0;
8907
+ var startIndex = 0;
8908
+ window.dhPlayerControl.windowState = 'wsPending';
8909
+
8910
+ function ecallback(e) {
8911
+ window.dhPlayerControl.DHPlayerVersion = Number(e.data.ver);
8912
+
8913
+ if (window.dhPlayerControl.pkgDHPlayerVerion.includes(window.dhPlayerControl.DHPlayerVersion)) {
8914
+ console.log('==== 版本信息匹配成功 ====');
8915
+ } else {
8916
+ console.log('==== 插件版本信息不匹配 ====');
8917
+ }
8918
+
8919
+ var o = sessionStorage.getItem('HikCentralWebControlPort');
8920
+ map['ws' + o].close();
8921
+ socketOpen();
8922
+ }
8923
+
8924
+ function esuccess(evt) {
8925
+ var port = evt.target.url.split(':').length == 3 ? evt.target.url.split(':')[2].replace('/', '') : '80';
8926
+ var json = {
8927
+ method: 'common.version',
8928
+ info: {},
8929
+ id: id
8930
+ };
8931
+ map['ws' + port] && map['ws' + port].readyState == 1 && map['ws' + port].send(JSON.stringify(json));
8932
+ }
8933
+
8934
+ function eerror(evt) {
8935
+ if (evt && !window.dhPlayerControl.DHPlayerVersion) {
8936
+ that.setting.createError && that.setting.createError({
8937
+ code: 1001,
8938
+ success: false,
8939
+ message: '插件未安装!'
8940
+ });
8941
+ }
8942
+ var port = evt.target.url.split(':').length == 3 ? evt.target.url.split(':')[2].replace('/', '') : '80';
8943
+ map['ws' + port].close();
8944
+ startIndex = (startIndex + 1) % portList.length;
8945
+ estart();
8946
+ }
8947
+
8948
+ function emessage(evt) {
8949
+ var data = evt && evt.data ? JSON.parse(evt.data) : {};
8950
+
8951
+ if (data.id == id) {
8952
+ var port = evt.target.url.split(':').length == 3 ? evt.target.url.split(':')[2].replace('/', '') : '80';
8953
+ sessionStorage && sessionStorage.setItem('HikCentralWebControlPort', port);
8954
+ ecallback(data);
8955
+ } else {
8956
+ eerror(evt);
8957
+ }
8958
+ }
8959
+
8960
+ function eclose() {
8961
+ console.log('-------开始创建连接------------');
8962
+ }
8963
+
8964
+ function estart() {
8965
+ try {
8966
+ map['ws' + portList[startIndex]] = new WebSocket('ws://localhost:' + portList[startIndex]);
8967
+ map['ws' + portList[startIndex]].onopen = esuccess;
8968
+ map['ws' + portList[startIndex]].onerror = eerror;
8969
+ map['ws' + portList[startIndex]].onmessage = emessage;
8970
+ map['ws' + portList[startIndex]].onclose = eclose;
8971
+ } catch (err) {
8972
+ eerror();
8973
+ }
8974
+ }
8975
+
8976
+ estart();
8977
+ }
8978
+
8979
+ function socketOpen() {
8980
+ var o = sessionStorage.getItem('HikCentralWebControlPort');
8981
+ window.dhPlayerControl.videoWS = new WebSocket('ws:127.0.0.1:' + o);
8982
+
8983
+ window.dhPlayerControl.videoWS.onopen = function () {
8984
+ window.dhPlayerControl.windowState = 'wsSuccess';
8985
+ heartbeat.call(this);
8986
+
8987
+ var _isSupport = isSupport();
8988
+
8989
+ for (var key in window.dhPlayerControl.videoList) {
8990
+ var currentThis = window.dhPlayerControl.videoList[key];
8991
+
8992
+ if (_isSupport.success) {
8993
+ currentThis.create();
8994
+ window.isResetConnect = currentThis.setting.isResetConnect;
8995
+ window.connectClose = currentThis.setting.connectClose;
8996
+ } else {
8997
+ currentThis.setting.createError(_isSupport);
8998
+ }
8999
+ }
9000
+ };
9001
+
9002
+ window.dhPlayerControl.videoWS.onmessage = socketMessage;
9003
+
9004
+ window.dhPlayerControl.videoWS.onclose = function () {
9005
+ if (window.isResetConnect) {
9006
+ console.log('----------重连-------');
9007
+ window.createError && window.createError({
9008
+ code: 1003,
9009
+ data: null,
9010
+ message: 'websocket连接断开, 正在重连......',
9011
+ success: false
9012
+ });
9013
+ setTimeout(function () {
9014
+ socketOpen();
9015
+ }, 3000);
9016
+ } else {
9017
+ window.createError && window.createError({
9018
+ code: 1003,
9019
+ data: null,
9020
+ message: 'websocket连接断开',
9021
+ success: false
9022
+ });
9023
+ }
9024
+ };
9025
+
9026
+ window.dhPlayerControl.videoWS.onerror = function () {
9027
+ console.log('----------错误重连-------');
9028
+ window.createError && window.createError({
9029
+ code: 1003,
9030
+ data: null,
9031
+ message: 'websocket连接发生错误,刷新重试',
9032
+ success: false
9033
+ });
9034
+ };
9035
+ }
9036
+ /**
9037
+ * 内部方法
9038
+ * @desc 插件心跳,保活
9039
+ */
9040
+
9041
+
9042
+ function heartbeat() {
9043
+ var that = this;
9044
+ clearInterval(window.wsHeart);
9045
+ window.wsHeart = setInterval(function () {
9046
+ that.send(JSON.stringify({
9047
+ method: 'common.heartbeat',
9048
+ info: {}
9049
+ }));
9050
+ }, 10 * 1000);
9051
+ }
9052
+
9053
+ function dataURLtoBlob(dataurl) {
9054
+ var mime = 'image/jpeg',
9055
+ bstr = atob(dataurl),
9056
+ n = bstr.length,
9057
+ u8arr = new Uint8Array(n);
9058
+
9059
+ while (n--) {
9060
+ u8arr[n] = bstr.charCodeAt(n);
9061
+ }
9062
+
9063
+ return new Blob([u8arr], {
9064
+ type: mime
9065
+ });
9066
+ }
9067
+
9068
+ function downloadFileByBase64(base64, name) {
9069
+ var myBlob = dataURLtoBlob(base64);
9070
+ var myUrl = URL.createObjectURL(myBlob);
9071
+ return myUrl;
9072
+ }
9073
+ /**
9074
+ * 前端与插件链接成功后,接收插件返回的信息
9075
+ * @param {*} evt
9076
+ * @returns
9077
+ */
9078
+
9079
+
9080
+ function socketMessage(evt) {
9081
+ if (evt.data == null || evt.data == '') {
9082
+ return;
9083
+ }
9084
+
9085
+ window.dhPlayerControl.wsSession = data && data.session || window.dhPlayerControl.wsSession;
9086
+ var data = JSON.parse(evt.data); // 获取屏幕分辨率
9087
+
9088
+ if (data.method === 'window.osRatio') {
9089
+ window.osRatio = data.info.dpi;
9090
+ } // 保证 hwnd 是 number 类型
9091
+
9092
+
9093
+ if (data.info && typeof data.info.hwnd === 'number') {
9094
+ var videoInfo = window.dhPlayerControl.videoList[window.dhPlayerControl.hwndList[data.info.hwnd]];
9095
+ var hwndInfo = videoInfo.setting;
9096
+
9097
+ if (typeof data.info.snum === 'number') {
9098
+ var channelInfo = hwndInfo.channelList.filter(function (item) {
9099
+ return item.snum === data.info.snum;
9100
+ })[0];
9101
+ }
9102
+
9103
+ switch (data.method) {
9104
+ case 'video.change.substream':
9105
+ channelInfo.streamType = Number(data.info.substream);
9106
+ videoInfo.startReal([channelInfo]);
9107
+ break;
9108
+
9109
+ case 'video.notifyrealmonitor':
9110
+ // 表示成功
9111
+ if (Number(data.info.result) === 0) {
9112
+ hwndInfo.realSuccess && hwndInfo.realSuccess(channelInfo, hwndInfo.channelList);
9113
+ } // 拉流失败
9114
+
9115
+
9116
+ if (Number(data.info.result) === 10704) {
9117
+ hwndInfo.realError && hwndInfo.realError(channelInfo, {
9118
+ code: 10704,
9119
+ message: '打开视频失败'
9120
+ });
9121
+ }
9122
+
9123
+ videoInfo.setWindowDragEnable();
9124
+ break;
9125
+
9126
+ case 'video.notifyplayback':
9127
+ // 表示成功
9128
+ if (Number(data.info.result) === 0) {
9129
+ hwndInfo.playbackSuccess && hwndInfo.playbackSuccess(channelInfo, hwndInfo.channelList);
9130
+ }
9131
+
9132
+ videoInfo.setWindowDragEnable();
9133
+ break;
9134
+
9135
+ case 'web.seekRecord':
9136
+ hwndInfo.channelList.forEach(function (item, index) {
9137
+ if (item.snum === data.info.snum) {
9138
+ // 非集成状态下,抛出回调
9139
+ if (item.byUrl) {
9140
+ hwndInfo.switchStartTime && hwndInfo.switchStartTime({
9141
+ startTime: data.info.seekTime,
9142
+ snum: data.info.snum
9143
+ });
9144
+ return;
9145
+ }
9146
+
9147
+ if (data.info.seekTime < item.startTime) {
9148
+ hwndInfo.playbackError && hwndInfo.playbackError(channelInfo, {
9149
+ code: 201,
9150
+ message: '当前时间不得小于开始时间, 请重新播放录像'
9151
+ });
9152
+ hwndInfo.channelList.splice(index, 1);
9153
+ return;
9154
+ }
9155
+
9156
+ if (data.info.seekTime > item.endTime) {
9157
+ hwndInfo.playbackError && hwndInfo.playbackError(channelInfo, {
9158
+ code: 201,
9159
+ message: '当前时间不得大于结束时间,请重新播放录像'
9160
+ });
9161
+ hwndInfo.channelList.splice(index, 1);
9162
+ return;
9163
+ }
9164
+
9165
+ item.records && item.records.forEach(function (r, currentIndex) {
9166
+ // 如果当前拖拽后的时间在某个时间段内, 改变currentIndex的时间
9167
+ if (Number(r.startTime) <= data.info.seekTime && Number(r.endTime) >= data.info.seekTime) {
9168
+ item.currentIndex = currentIndex;
9169
+ console.log("\u5F53\u524D\u62D6\u62FD\u5230\u7B2C".concat(item.currentIndex, "\u5F55\u50CF"));
9170
+ return;
9171
+ }
9172
+ });
9173
+ item.currentPlayTime = data.info.seekTime;
9174
+ item.bBack = Number(data.info.bBack);
9175
+ videoInfo.closeVideo(data.info.snum);
9176
+ videoInfo.startPlayback(item, true);
9177
+ }
9178
+ });
9179
+ break;
9180
+
9181
+ case 'web.replay':
9182
+ hwndInfo.channelList.forEach(function (item, index) {
9183
+ if (item.snum === data.info.snum) {
9184
+ // 非集成状态下
9185
+ if (item.byUrl) {
9186
+ hwndInfo.replay && hwndInfo.replay(data.info.snum);
9187
+ return;
9188
+ }
9189
+
9190
+ item.bBack = data.info.bBack;
9191
+
9192
+ if (!item.bBack) {
9193
+ if (item.currentIndex === item.records.length - 1) {
9194
+ hwndInfo.playbackFinish && hwndInfo.playbackFinish({
9195
+ snum: data.info.snum,
9196
+ channelId: data.info.channelId,
9197
+ code: 201,
9198
+ message: '录像已全部播放完成'
9199
+ });
9200
+ videoInfo.closeVideo(data.info.snum);
9201
+ videoInfo.chooseWindow(data.info.snum);
9202
+ hwndInfo.channelList.splice(index, 1);
9203
+ return;
9204
+ }
9205
+
9206
+ item.currentIndex++;
9207
+ item.currentPlayTime = item.records[item.currentIndex].startTime;
9208
+ } else {
9209
+ if (item.currentIndex === 0) {
9210
+ hwndInfo.playbackFinish && hwndInfo.playbackFinish({
9211
+ snum: data.info.snum,
9212
+ channelId: data.info.channelId,
9213
+ code: 201,
9214
+ message: '录像已全部播放完成'
9215
+ });
9216
+ videoInfo.closeVideo(data.info.snum);
9217
+ videoInfo.chooseWindow(data.info.snum);
9218
+ hwndInfo.channelList.splice(index, 1);
9219
+ return;
9220
+ }
9221
+
9222
+ item.currentIndex--;
9223
+ item.currentPlayTime = item.records[item.currentIndex].endTime;
9224
+ }
9225
+
9226
+ videoInfo.startPlayback(item, true, true);
9227
+ }
9228
+ });
9229
+ break;
9230
+
9231
+ case 'video.close':
9232
+ var i = -1;
9233
+ hwndInfo.channelList.forEach(function (item, index) {
9234
+ // 获取到要被删除的数据 (插件内部关闭且存在窗口统一)
9235
+ if (item.snum === data.info.snum) {
9236
+ if (!item.closed) {
9237
+ i = index;
9238
+ } else {
9239
+ delete item.closed;
9240
+ }
9241
+ }
9242
+ });
9243
+
9244
+ if (i >= 0) {
9245
+ hwndInfo.channelList.splice(i, 1); // 删除掉窗口和channelId都匹配上的
9246
+
9247
+ hwndInfo.closeWindowSuccess && hwndInfo.closeWindowSuccess({
9248
+ snum: data.info.snum
9249
+ });
9250
+ }
9251
+
9252
+ break;
9253
+
9254
+ case 'video.notifytalk':
9255
+ // 判断是否有对讲
9256
+ if (data.info.bOpen) {
9257
+ var talkFlag = false;
9258
+ hwndInfo.channelList.forEach(function (item) {
9259
+ if (item.byUrl) {
9260
+ talkFlag = true; // 告诉前端传入url对讲回调
9261
+
9262
+ hwndInfo.notifyTalk && hwndInfo.notifyTalk({
9263
+ channelId: data.info.channelId,
9264
+ snum: data.info.snum
9265
+ });
9266
+ return;
9267
+ }
9268
+
9269
+ if (item.isTalk) {
9270
+ talkFlag = true;
9271
+ hwndInfo.request.stopTalk && hwndInfo.request.stopTalk(getAjaxParam(item, 'stopTalk')).then(function () {
9272
+ delete item.isTalk;
9273
+ videoInfo.startTalk(data.info.snum);
9274
+ }).catch(function (err) {
9275
+ // 表示当前不存在
9276
+ if (err.code === 2051) {
9277
+ videoInfo.startTalk(data.info.snum);
9278
+ }
9279
+ });
9280
+ }
9281
+ });
9282
+ !talkFlag && videoInfo.startTalk(data.info.snum);
9283
+ } else {
9284
+ hwndInfo.channelList.forEach(function (item) {
9285
+ if (item.snum === data.info.snum) {
9286
+ hwndInfo.request.stopTalk && hwndInfo.request.stopTalk(getAjaxParam(item, 'stopTalk')).then(function () {
9287
+ console.log('关闭对讲');
9288
+ });
9289
+ }
9290
+
9291
+ videoInfo.closeTalk();
9292
+ });
9293
+ }
9294
+
9295
+ case 'talk.close':
9296
+ hwndInfo.snum = data.info.wndId;
9297
+ hwndInfo.closeTalkSuccess && hwndInfo.closeTalkSuccess(data.info.wndId);
9298
+ break;
9299
+
9300
+ case 'web.captureCallBack':
9301
+ var imageUrl = data.info.PicBuf ? downloadFileByBase64(data.info.PicBuf) : '';
9302
+ hwndInfo.snapshotSuccess && hwndInfo.snapshotSuccess({
9303
+ base64Url: data.info.PicBuf,
9304
+ path: imageUrl
9305
+ });
9306
+ break;
9307
+
9308
+ case 'window.LocalRecordFinish':
9309
+ hwndInfo.videoDownloadSuccess && hwndInfo.videoDownloadSuccess(data.info.path);
9310
+ break;
9311
+
9312
+ case 'video.window.clicked':
9313
+ channelInfo = hwndInfo.channelList.filter(function (item) {
9314
+ return item.snum === data.info.wndIndex;
9315
+ })[0];
9316
+ hwndInfo.clickWindow && hwndInfo.clickWindow(data.info.wndIndex, channelInfo);
9317
+ break;
9318
+
9319
+ case 'video.window.dbclicked':
9320
+ channelInfo = hwndInfo.channelList.filter(function (item) {
9321
+ return item.snum === data.info.wndIndex;
9322
+ })[0];
9323
+ hwndInfo.dbClickWindow && hwndInfo.dbClickWindow(data.info.wndIndex, channelInfo);
9324
+ break;
9325
+
9326
+ case 'video.division.change':
9327
+ hwndInfo.division = data.info.division;
9328
+ hwndInfo.changeDivision && hwndInfo.changeDivision(data.info.division);
9329
+ videoInfo.setWindowDragEnable();
9330
+ break;
9331
+
9332
+ case 'video.customDivision.change':
9333
+ hwndInfo.division = JSON.stringify(data.info);
9334
+ hwndInfo.changeDivision && hwndInfo.changeDivision(JSON.stringify(data.info));
9335
+ videoInfo.setWindowDragEnable();
9336
+ break;
9337
+
9338
+ case 'video.downloadFileSize':
9339
+ hwndInfo.downloadProgress && hwndInfo.downloadProgress(data.info);
9340
+ break;
9341
+
9342
+ case 'video.downloadByTime':
9343
+ hwndInfo.downloadRecordSuccess && hwndInfo.downloadRecordSuccess(data.info);
9344
+ }
9345
+ }
9346
+
9347
+ var onError = null;
9348
+ var onSuccess = null;
9349
+
9350
+ if (window.dhPlayerControl.callBackList[data['id']]) {
9351
+ onError = window.dhPlayerControl.callBackList[data['id']].onError;
9352
+ onSuccess = window.dhPlayerControl.callBackList[data['id']].onSuccess;
9353
+ }
9354
+
9355
+ if (data.code != 0) {
9356
+ if (onError && typeof onError === 'function') {
9357
+ onError(data);
9358
+ delete window.dhPlayerControl.callBackList[data['id']];
9359
+ }
9360
+
9361
+ return;
9362
+ }
9363
+
9364
+ if (onSuccess && typeof onSuccess === 'function') {
9365
+ onSuccess(data);
9366
+ delete window.dhPlayerControl.callBackList[data['id']];
9367
+ }
9368
+ } //主动关闭socket
9369
+
9370
+
9371
+ function socketClose() {
9372
+ window.dhPlayerControl.videoWS && window.dhPlayerControl.videoWS.close();
9373
+ window.dhPlayerControl.videoWS = null;
9374
+ window.wsHeart = clearInterval(window.wsHeart);
9375
+ }
9376
+ /**
9377
+ * @desc 获取操作系统
9378
+ */
9379
+
9380
+
9381
+ function getOsInfo() {
9382
+ var userAgent = window.navigator.userAgent.toLowerCase();
9383
+ var version = '';
9384
+
9385
+ if (userAgent.indexOf('win') > -1) {
9386
+ if (userAgent.indexOf('windows nt 5.0') > -1 || userAgent.indexOf('Windows 2000') > -1) {
9387
+ version = 'Windows 2000';
9388
+ } else if (userAgent.indexOf('windows nt 5.1') > -1 || userAgent.indexOf('Windows XP') > -1) {
9389
+ version = 'Windows XP';
9390
+ } else if (userAgent.indexOf('windows nt 5.2') > -1 || userAgent.indexOf('Windows 2003') > -1) {
9391
+ version = 'Windows 2003';
9392
+ } else if (userAgent.indexOf('windows nt 6.0') > -1 || userAgent.indexOf('Windows Vista') > -1) {
9393
+ version = 'Windows Vista';
9394
+ } else if (userAgent.indexOf('windows nt 6.1') > -1 || userAgent.indexOf('windows 7') > -1) {
9395
+ version = 'Windows 7';
9396
+ } else if (userAgent.indexOf('windows nt 6.2') > -1 || userAgent.indexOf('windows 8') > -1) {
9397
+ version = 'Windows 8';
9398
+ } else if (userAgent.indexOf('windows nt 6.3') > -1) {
9399
+ version = 'Windows 8.1';
9400
+ } else if (userAgent.indexOf('windows nt 6.4') > -1 || userAgent.indexOf('windows nt 10') > -1) {
9401
+ version = 'Windows 10';
9402
+ } else {
9403
+ version = 'Unknown';
9404
+ }
9405
+ } else if (userAgent.indexOf('iphone') > -1) {
9406
+ version = 'Iphone';
9407
+ } else if (userAgent.indexOf('mac') > -1) {
9408
+ version = 'Mac';
9409
+ } else if (userAgent.indexOf('x11') > -1 || userAgent.indexOf('unix') > -1 || userAgent.indexOf('sunname') > -1 || userAgent.indexOf('bsd') > -1) {
9410
+ version = 'Unix';
9411
+ } else if (userAgent.indexOf('linux') > -1) {
9412
+ if (userAgent.indexOf('android') > -1) {
9413
+ version = 'Android';
9414
+ } else {
9415
+ version = 'Linux';
9416
+ }
9417
+ } else {
9418
+ version = 'Unknown';
9419
+ }
9420
+
9421
+ return version;
9422
+ }
9423
+ /**
9424
+ * @desc 获取浏览器和对应浏览器版本
9425
+ */
9426
+
9427
+
9428
+ function getBroswerVersion() {
9429
+ // 浏览器判断和版本号读取
9430
+ var Sys = {};
9431
+ var userAgent = navigator.userAgent.toLowerCase();
9432
+ var s;
9433
+ (s = userAgent.match(/edge\/([\d.]+)/)) ? Sys.edge = s[1] : (s = userAgent.match(/rv:([\d.]+)\) like gecko/)) ? Sys.ie = s[1] : (s = userAgent.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] : (s = userAgent.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] : (s = userAgent.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] : (s = userAgent.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] : (s = userAgent.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
9434
+ if (Sys.edge) return {
9435
+ broswer: 'Edge',
9436
+ version: Sys.edge
9437
+ };
9438
+ if (Sys.ie) return {
9439
+ broswer: 'IE',
9440
+ version: Sys.ie
9441
+ };
9442
+ if (Sys.firefox) return {
9443
+ broswer: 'Firefox',
9444
+ version: Sys.firefox
9445
+ };
9446
+ if (Sys.chrome) return {
9447
+ broswer: 'Chrome',
9448
+ version: Sys.chrome
9449
+ };
9450
+ if (Sys.opera) return {
9451
+ broswer: 'Opera',
9452
+ version: Sys.opera
9453
+ };
9454
+ if (Sys.safari) return {
9455
+ broswer: 'Safari',
9456
+ version: Sys.safari
9457
+ };
9458
+ return {
9459
+ broswer: '',
9460
+ version: '0'
9461
+ };
9462
+ }
9463
+
9464
+ function broswerInfo() {
9465
+ var _version = getBroswerVersion();
9466
+
9467
+ if (_version.broswer === 'IE') {
9468
+ return 0;
9469
+ } else if (_version.broswer === 'Chrome') {
9470
+ if (Number(_version.version.split('.')[0]) > 80) {
9471
+ return 2;
9472
+ }
9473
+
9474
+ return 1;
9475
+ } else if (_version.broswer === 'Firefox') {
9476
+ return 2;
9477
+ } else {
9478
+ return -1;
9479
+ }
9480
+ }
9481
+ /**
9482
+ * 内部方法
9483
+ * @desc 判断当前操作系统和浏览器版本类型是否支持DHPlayer
9484
+ */
9485
+
9486
+
9487
+ function isSupport() {
9488
+ var supportedOS = ['Windows 7', 'Windows 10', ''];
9489
+ var supportedBroswer = ['Chrome', 'Firefox', 'Edge'];
9490
+ var osVersion = getOsInfo();
9491
+
9492
+ var _getBroswerVersion = getBroswerVersion(),
9493
+ broswer = _getBroswerVersion.broswer,
9494
+ version = _getBroswerVersion.version;
9495
+
9496
+ if (!supportedOS.includes(osVersion)) {
9497
+ return {
9498
+ code: 1002,
9499
+ success: false,
9500
+ message: '电脑系统不支持!仅支持win7 和 win10 系统'
9501
+ };
9502
+ }
9503
+
9504
+ if (!supportedBroswer.includes(broswer)) {
9505
+ return {
9506
+ code: 1002,
9507
+ success: false,
9508
+ message: '当前浏览器不支持! 仅支持谷歌,火狐,edge浏览器'
9509
+ };
9510
+ }
9511
+
9512
+ if (Number(version.split('.')[0]) < 76) {
9513
+ return {
9514
+ code: 1002,
9515
+ success: false,
9516
+ message: '当前的浏览器版本不支持!请使用较高版本的浏览器!'
9517
+ };
9518
+ }
9519
+
9520
+ return {
9521
+ code: 1000,
9522
+ success: true
9523
+ };
9524
+ } // 获取父iframe的遮挡位置
9525
+
9526
+
9527
+ function getParentIframeRect(name) {
9528
+ var el = window.top.document.querySelector(".".concat(name));
9529
+ return el && el.getBoundingClientRect() || null;
9530
+ } // 获取位置
9531
+
9532
+
9533
+ function getRect(name) {
9534
+ var el = '';
9535
+ var videoId = this.setting.videoId;
9536
+
9537
+ if (name) {
9538
+ el = document.getElementsByClassName(name)[0];
9539
+ } else {
9540
+ el = document.getElementById(videoId);
9541
+ }
9542
+
9543
+ if (!el) {
9544
+ return {};
9545
+ }
9546
+
9547
+ var rect = el.getBoundingClientRect();
9548
+ var outLeft = 0;
9549
+ var outTop = 0;
9550
+ var pOutContent;
9551
+
9552
+ if (window.dhPlayerControl.isPIframe) {
9553
+ pOutContent = this.setting.pIframeRect;
9554
+ outLeft = pOutContent.left || 0;
9555
+ outTop = pOutContent.top || 0;
9556
+ } else {
9557
+ var iframes = window.parent.document.getElementsByTagName('iframe');
9558
+ var pIframe = null;
9559
+
9560
+ for (var i = 0; i < iframes.length; i++) {
9561
+ var dom = '';
9562
+
9563
+ if (name) {
9564
+ dom = iframes[i].contentWindow.document.getElementsByClassName(name)[0];
9565
+ } else {
9566
+ dom = iframes[i].contentWindow.document.getElementById(videoId);
9567
+ }
9568
+
9569
+ if (dom) {
9570
+ pIframe = iframes[i];
9571
+ break;
9572
+ }
9573
+ }
9574
+
9575
+ if (pIframe) {
9576
+ pOutContent = pIframe.getBoundingClientRect();
9577
+ outLeft = pOutContent.left;
9578
+ outTop = pOutContent.top;
9579
+ }
9580
+ }
9581
+
9582
+ var left = rect.left + (this.setting.outContent.left || outLeft);
9583
+ var top = rect.top + (this.setting.outContent.top || outTop);
9584
+ var right = left + rect.width;
9585
+ var bottom = top + rect.height;
9586
+ return {
9587
+ left: left,
9588
+ top: top,
9589
+ right: right,
9590
+ bottom: bottom,
9591
+ width: rect.width,
9592
+ height: rect.height
9593
+ };
9594
+ } // 请求录像文件信息
9595
+
9596
+
9597
+ function queryRecord(param) {
9598
+ var _this2 = this;
9599
+
9600
+ var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'queryRecord';
9601
+ return new Promise(function (resolve, reject) {
9602
+ // 查询录像
9603
+ if (param.records && param.records.length) {
9604
+ resolve(param);
9605
+ }
9606
+
9607
+ if (!_this2.setting.request[type]) {
9608
+ reject({
9609
+ code: 207,
9610
+ message: '请传入查询录像接口'
9611
+ });
9612
+ return;
9613
+ }
9614
+
9615
+ _this2.setting.request[type](getAjaxParam(param, type)).then(function (res) {
9616
+ if (!param.records || param.records === []) {
9617
+ if (!res.records || !res.records.length) {
9618
+ reject({
9619
+ code: 201,
9620
+ message: "\u901A\u9053 ".concat(param.name || '未知', " \u672A\u67E5\u8BE2\u5230\u5F55\u50CF\u6587\u4EF6")
9621
+ });
9622
+ return;
9623
+ }
9624
+
9625
+ param.records = res.records.sort(function (a, b) {
9626
+ return a.startTime - b.startTime;
9627
+ });
9628
+ param.currentIndex = 0;
9629
+ _this2.setting.channelList[_this2.setting.channelList.findIndex(function (item) {
9630
+ return item.channelId === param.channelId;
9631
+ })] = param;
9632
+ }
9633
+
9634
+ resolve(res);
9635
+ }).catch(function (err) {
9636
+ reject(err);
9637
+ });
9638
+ });
9639
+ } // 处理获取过来的rtsp流
9640
+
9641
+
9642
+ function processRtsp(data, param) {
9643
+ // 内外网环境会有多个rtspUrl
9644
+ data.records = param.records;
9645
+ data.rtspUrl = dealUrl(data);
9646
+ return data;
9647
+ }
9648
+ /**
9649
+ * 根据文件获取流
9650
+ * @param {*} param
9651
+ */
9652
+
9653
+
9654
+ function getPlayBackRtspByFile(param) {
9655
+ var _this3 = this;
9656
+
9657
+ var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'playbackByFile';
9658
+ var that = this;
9659
+ return new Promise(function (resolve, reject) {
9660
+ var byFileParam = getAjaxParam(param, type);
9661
+ queryRecord.call(_this3, param).then(function (res) {
9662
+ if (!that.setting.request[type]) {
9663
+ reject({
9664
+ code: 207,
9665
+ message: '请传入 “根据时间查询录像” 接口'
9666
+ });
9667
+ return;
9668
+ }
9669
+
9670
+ var records = res.records[param.currentIndex]; // let rec = records[0]
9671
+
9672
+ param.playStartTime = records.startTime;
9673
+ param.playEndTime = records.endTime;
9674
+ byFileParam.data = {
9675
+ ssId: records.ssId,
9676
+ optional: '/evo-apigw/admin/API/SS/Playback/StartPlaybackByFile',
9677
+ startTime: param.bBack === 0 ? param.currentPlayTime : param.playStartTime,
9678
+ endTime: param.bBack === 0 ? param.playEndTime : param.currentPlayTime,
9679
+ fileName: records.recordName,
9680
+ diskId: records.diskId,
9681
+ nvrId: '',
9682
+ recordSource: param.recordSource,
9683
+ channelId: records.channelId,
9684
+ playbackMode: '0',
9685
+ streamId: records.streamId
9686
+ };
9687
+ that.setting.request[type](byFileParam).then(function (res) {
9688
+ resolve(processRtsp(res, param));
9689
+ }).catch(function (err) {
9690
+ reject(err);
9691
+ });
9692
+ }).catch(function (err) {
9693
+ reject(err);
9694
+ });
9695
+ });
9696
+ }
9697
+ /**
9698
+ * 根据时间获取流
9699
+ * @param {*} option
9700
+ * @returns
9701
+ */
9702
+
9703
+
9704
+ function getPlayBackRtspByTime(param) {
9705
+ var _this4 = this;
9706
+
9707
+ var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'playbackByTime';
9708
+ // 设备录像也需要去查询当日有录像的时间段
9709
+ return new Promise(function (resolve, reject) {
9710
+ queryRecord.call(_this4, param).then(function () {
9711
+ if (!_this4.setting.request[type]) {
9712
+ reject({
9713
+ code: 207,
9714
+ message: '请传入 “通过时间播放录像” 接口'
9715
+ });
9716
+ return;
9717
+ }
9718
+
9719
+ _this4.setting.request[type](getAjaxParam(param, type)).then(function (res) {
9720
+ resolve(processRtsp(res, param));
9721
+ }).catch(function (err) {
9722
+ reject(err);
9723
+ });
9724
+ }).catch(function (err) {
9725
+ reject(err);
9726
+ });
9727
+ });
9728
+ }
9729
+
9730
+ var VideoPlayer = function VideoPlayer(option) {
9731
+ if (!option) {
9732
+ throw new Error('请传入配置参数');
9733
+ }
9734
+
9735
+ if (this instanceof VideoPlayer) {
9736
+ var _setting = {
9737
+ isResetConnect: true,
9738
+ // websocket连接断开时,是否自动重新连接, true表示是, false表示否
9739
+ // isIE: !!window.ActiveXObject || 'ActiveXObject' in window, //判断是否为IE
9740
+ videoId: 'DHVideoPlayer',
9741
+ windowType: 0,
9742
+ // 0-实时预览,3-录像回放,7-录像回放(支持倒放)
9743
+ outContent: {
9744
+ left: 0,
9745
+ right: 0,
9746
+ width: 0,
9747
+ height: 0
9748
+ },
9749
+ show: true,
9750
+ //当前窗口显示状态,隐藏:false,显示:true
9751
+ option_id: {},
9752
+ refreshTimer: null,
9753
+ browserType: 1,
9754
+ version: 0,
9755
+ stopRefresh: false,
9756
+ //停止一直刷新
9757
+ showBar: true,
9758
+ //是否显示下方控制栏。 true: 显示, false:隐藏
9759
+ hwnd: '',
9760
+ //窗口句柄
9761
+ division: 1,
9762
+ //子窗口数
9763
+ pIframeShieldData: [],
9764
+ // 跨域iframe下的遮挡信息
9765
+ topInnerWidth: 0,
9766
+ // iframe模式下的顶层宽度
9767
+ topInnerHeight: 0,
9768
+ // iframe模式下的顶层高度
9769
+ parentIframeShieldRect: [],
9770
+ // iframe模式下遮罩的数据信息
9771
+ pIframeRect: [],
9772
+ // iframe模式下 iframe的数据信息
9773
+ oldPosition: '',
9774
+ // 存储循环数据中的上次位置数据
9775
+ oldShield: '',
9776
+ // 存储循环数据中的上次遮挡数据
9777
+ request: {},
9778
+ // 存储请求
9779
+ channelList: [],
9780
+ // 存储当前播放器正在播放的视频
9781
+ draggable: false,
9782
+ // 是否支持拖拽,默认不支持
9783
+ visible: true // 控制播放器的显示和隐藏
9784
+
9785
+ };
9786
+ this.setting = Object.assign({}, _setting, option);
9787
+ this.adjustCount = 0;
9788
+ this.focus = false;
9789
+ this.init();
9790
+ } else {
9791
+ return new VideoPlayer(option);
9792
+ }
9793
+ };
9794
+
9795
+ VideoPlayer.fn = VideoPlayer.prototype = {
9796
+ //浏览器关闭或者刷新
9797
+ onbeforeunload: function onbeforeunload() {
9798
+ var _this5 = this;
9799
+
9800
+ this.destroy().then(function () {
9801
+ socketClose.call(_this5);
9802
+ });
9803
+ },
9804
+ // 改变setting的参数值
9805
+ _update: function _update(param) {
9806
+ var paramType = function paramType(value, type) {
9807
+ return Object.prototype.toString.call(value).includes(type);
9808
+ };
9809
+
9810
+ var windowType = param.windowType,
9811
+ isResetConnect = param.isResetConnect,
9812
+ request = param.request,
9813
+ division = param.division,
9814
+ visible = param.visible,
9815
+ draggable = param.draggable,
9816
+ showBar = param.showBar,
9817
+ shieldClass = param.shieldClass,
9818
+ coverShieldClass = param.coverShieldClass,
9819
+ parentIframeShieldClass = param.parentIframeShieldClass; // 断线重连 (不对外开放,默认支持断线重连)
9820
+
9821
+ paramType(isResetConnect, 'Boolean') && !(isResetConnect === this.setting.isResetConnect) && (this.setting.isResetConnect = isResetConnect); // 显隐播放器
9822
+
9823
+ paramType(visible, 'Boolean') && !(visible === this.setting.visible) && (this.setting.visible = visible, visible ? this.show() : this.hide()); // 显影控制栏
9824
+
9825
+ paramType(showBar, 'Boolean') && !(showBar === this.setting.showBar) && this.showControlBar(showBar); // 播放器是否支持拖拽
9826
+
9827
+ paramType(draggable, 'Boolean') && !(draggable === this.setting.draggable) && (this.setting.draggable = draggable, this.setWindowDragEnable()); // 窗口分割
9828
+
9829
+ !(division == this.setting.division) && this.changeDivision(division); // 接口转换
9830
+
9831
+ paramType(request, 'Object') && (this.setting.request = _objectSpread2({}, request)); // 遮挡类的改变
9832
+
9833
+ paramType(shieldClass, 'Array') && (this.setting.shieldClass = shieldClass);
9834
+ paramType(parentIframeShieldClass, 'Array') && (this.setting.parentIframeShieldClass = parentIframeShieldClass);
9835
+ paramType(coverShieldClass, 'Array') && (this.setting.coverShieldClass = coverShieldClass); // 重新创建
9836
+
9837
+ if (paramType(windowType, 'Number') && windowType !== this.setting.windowType) {
9838
+ this.setting.windowType = param.windowType;
9839
+ this.create();
9840
+ }
9841
+ },
9842
+ //发送消息
9843
+ send: function send(option, callBack) {
9844
+ option.session = window.dhPlayerControl.wsSession;
9845
+ option.id = window.dhPlayerControl.wsConnectCount++;
9846
+
9847
+ if (option.info) {
9848
+ option.info.browserType = this.setting.browserType;
9849
+
9850
+ if (option.method !== 'window.destroy') {
9851
+ option.info.hwnd = option.method === 'window.create' ? undefined : this.setting.hwnd;
9852
+ }
9853
+ }
9854
+
9855
+ if (callBack && Object.keys(callBack).length) {
9856
+ window.dhPlayerControl.callBackList[option['id']] = callBack;
9857
+ }
9858
+
9859
+ if (!['window.change', 'window.shield', 'browserFocusBlur'].includes(option.method)) {
9860
+ console.log('web', option);
9861
+ }
9862
+
9863
+ window.dhPlayerControl.videoWS && window.dhPlayerControl.videoWS.readyState == 1 && window.dhPlayerControl.videoWS.send(JSON.stringify(option));
9864
+ },
9865
+ // 创建视频窗口
9866
+ create: function create() {
9867
+ var _this6 = this;
9868
+
9869
+ var rect = getRect.call(this);
9870
+
9871
+ var _info = Object.assign({}, {}, rect);
9872
+
9873
+ var windowSize = getWindowSize.call(this);
9874
+ var zoom = detectZoom();
9875
+ _info.isCustomDivision = isNaN(this.setting.division);
9876
+ _info.num = isNaN(this.setting.division) ? null : this.setting.division; // 窗口数量
9877
+
9878
+ _info.customDivision = isNaN(this.setting.division) ? JSON.parse(this.setting.division) : null;
9879
+ _info.toolBar = this.setting.showBar ? 1 : 0; // 是否显示控制栏
9880
+
9881
+ _info.windowType = this.setting.windowType; // 判断当前为实时预览还是录像回放 0-实时预览 3-录像回放
9882
+
9883
+ _info.clientAreaHeight = windowSize.height * zoom / 100;
9884
+ _info.clientAreaWidth = windowSize.width * zoom / 100;
9885
+ this.setTopBind = this.setTop.myBind(this);
9886
+ this.onbeforeunloadBind = this.onbeforeunload.myBind(this);
9887
+ this.visibilitychangeBind = this.setVisible.myBind(this);
9888
+ var that = this;
9889
+ this.destroy().then(function () {
9890
+ _this6.send({
9891
+ method: 'window.create',
9892
+ info: _info
9893
+ }, {
9894
+ onSuccess: function onSuccess(data) {
9895
+ if (data.data && typeof data.data.hwnd === 'number') {
9896
+ var hwnd = data.data.hwnd;
9897
+ console.log("==================\u521B\u5EFA\u6210\u529F hwnd: ".concat(hwnd, "=================="));
9898
+ that.setting.hwnd = hwnd;
9899
+ window.dhPlayerControl.videoList[that.setting.videoId].setting = that.setting;
9900
+ window.dhPlayerControl.hwndList[hwnd] = that.setting.videoId;
9901
+ }
9902
+
9903
+ that.setTopBind = that.setTop.myBind(that);
9904
+ window.addEventListener('beforeunload', that.onbeforeunloadBind);
9905
+ document.addEventListener('click', that.setTopBind);
9906
+ that.handleAdjust();
9907
+ var i = 0;
9908
+
9909
+ while (i <= 3) {
9910
+ that.setting.oldPosition = '';
9911
+ that.setting.oldShield = '';
9912
+ that.changePosition();
9913
+ i++;
9914
+ }
9915
+
9916
+ that.setTabControlBtn();
9917
+ that.setWindowDragEnable();
9918
+ that.setting.createSuccess && that.setting.createSuccess(); // 初始化的时候手动调用show方法,避免出现播放器不显示的问题
9919
+ // 前提条件: 保证在当前页面上时触发,否则不触发。
9920
+
9921
+ document.visibilityState === 'visible' && that.show();
9922
+ document.addEventListener('visibilitychange', that.visibilitychangeBind, true);
9923
+ },
9924
+ onError: function onError() {
9925
+ that.setting.createError && that.setting.createError();
9926
+ }
9927
+ });
9928
+ });
9929
+ },
9930
+ // 设置播放器上方的操作按钮
9931
+ setTabControlBtn: function setTabControlBtn(btnList, snum) {
9932
+ // let allBtn = ["BTN_STREAM", "BTN_PTZ", "BTN_QUICKPLAY", "BTN_VOICE", "BTN_TALK", "BTN_RECORD", "BTN_PIC", "BTN_ENLARGE", "BTN_CLOSE"]
9933
+ var showBtn = ['BTN_STREAM', 'BTN_VOICE', 'BTN_TALK', 'BTN_RECORD', 'BTN_PIC', 'BTN_ENLARGE', 'BTN_CLOSE'];
9934
+ this.send({
9935
+ method: 'video.toolbar.showButton',
9936
+ info: {
9937
+ space: 15,
9938
+ snum: snum,
9939
+ btns: btnList || showBtn
9940
+ }
9941
+ });
9942
+ },
9943
+ // 判断当前浏览器是否在tab页面上
9944
+ setVisible: function setVisible() {
9945
+ document.visibilityState == 'hidden' ? this.hide() : this.show();
9946
+ },
9947
+ //页面聚焦
9948
+ setTop: function setTop() {
9949
+ this.focus = true;
9950
+ document.visibilityState == 'visible' && this.browserFocusBlur();
9951
+ },
9952
+ browserFocusBlur: function browserFocusBlur() {
9953
+ this.send({
9954
+ method: 'browserFocusBlur',
9955
+ info: {
9956
+ show: this.setting.show,
9957
+ focus: this.focus
9958
+ }
9959
+ });
9960
+ },
9961
+ //刷新窗口位置
9962
+ handleAdjust: function handleAdjust() {
9963
+ if (!window.dhPlayerControl.isPIframe && this.setting.stopRefresh) {
9964
+ return;
9965
+ }
9966
+
9967
+ var _this = this; // 每帧执行一次,减少DHplayer延时
9968
+
9969
+
9970
+ this.changePosition();
9971
+ this.windowShield(this.cover());
9972
+ this.setting.refreshTimer = window.requestAnimationFrame(function () {
9973
+ return _this.handleAdjust();
9974
+ });
9975
+ },
9976
+ removeClickEventListener: function removeClickEventListener() {
9977
+ document.removeEventListener('click', this.setTopBind);
9978
+ },
9979
+ addClickEventListener: function addClickEventListener() {
9980
+ document.addEventListener('click', this.setTopBind);
9981
+ },
9982
+
9983
+ /**
9984
+ * 销毁当前播放器
9985
+ * @return Promise对象
9986
+ */
9987
+ destroy: function destroy() {
9988
+ var _this7 = this;
9989
+
9990
+ return new Promise(function (resolve, reject) {
9991
+ var that = window.dhPlayerControl.videoList[_this7.setting.videoId];
9992
+
9993
+ if (!that || that.setting && typeof that.setting.hwnd !== 'number') {
9994
+ resolve();
9995
+ } else {
9996
+ _this7.send({
9997
+ method: 'window.destroy',
9998
+ info: {
9999
+ hwnd: that.setting.hwnd
10000
+ }
10001
+ });
10002
+
10003
+ document.removeEventListener('click', _this7.setTopBind);
10004
+ document.removeEventListener('visibilitychange', _this7.visibilitychangeBind, true);
10005
+ window.removeEventListener('beforeunload', _this7.onbeforeunloadBind);
10006
+ console.log("==================\u9500\u6BC1\u6210\u529F, hwnd: ".concat(that.setting.hwnd, " =================="));
10007
+ resolve();
10008
+ }
10009
+ });
10010
+ },
10011
+
10012
+ /**
10013
+ * 设置水印
10014
+ * @param { Object } option 参数
10015
+ * @param { Number } snum 窗口数量
10016
+ * @param { String } item.color 水印颜色
10017
+ * @param { Number } item.fontSize 水印尺寸
10018
+ * @param { Number } item.fontWeight 字体粗细
10019
+ * @param { String } item.position 水印位置
10020
+ * @param { Number } item.text 文本
10021
+ */
10022
+ waterMark: function waterMark(option) {
10023
+ var _this8 = this;
10024
+
10025
+ option.forEach(function (item) {
10026
+ var rgb = item.color.split(',');
10027
+ var position = item.position.split(',');
10028
+
10029
+ _this8.send({
10030
+ method: 'video.setOSDInfo',
10031
+ info: {
10032
+ snum: item.snum,
10033
+ R: rgb[0] || 255,
10034
+ G: rgb[1] || 255,
10035
+ B: rgb[2] || 255,
10036
+ fontSize: item.fontSize || 14,
10037
+ positionX: position[0] || 1,
10038
+ positionY: position[1] || 1,
10039
+ osdInfo: item.text || '',
10040
+ fontWeight: item.fontWeight || 0
10041
+ }
10042
+ });
10043
+ });
10044
+ },
10045
+ // 设置窗口是否支持拖拽
10046
+ setWindowDragEnable: function setWindowDragEnable() {
10047
+ this.send({
10048
+ method: 'window.enableDrag',
10049
+ info: {
10050
+ enable: this.setting.draggable
10051
+ }
10052
+ });
10053
+ },
10054
+ // 设置全屏
10055
+ setFullScreen: function setFullScreen() {
10056
+ this.send({
10057
+ method: 'video.fullScreen',
10058
+ info: {}
10059
+ });
10060
+ },
10061
+
10062
+ /**
10063
+ * @method chooseWindow 支持用户选择子窗口
10064
+ * @param { Number } snum 选择的子窗口,从0开始
10065
+ * @param { Function } cb 选中窗口回调
10066
+ */
10067
+ chooseWindow: function chooseWindow(snum, cb) {
10068
+ this.send({
10069
+ method: 'window.select',
10070
+ info: {
10071
+ snum: snum
10072
+ }
10073
+ });
10074
+ cb && cb(this.setting.channelList.filter(function (item) {
10075
+ return item.snum === snum;
10076
+ })[0]);
10077
+ },
10078
+
10079
+ /**
10080
+ * @method openAudio 开启、关闭声音
10081
+ * @param { Number } option.isEnable 0-关闭,1-开启
10082
+ * @param { Number } option.snum 选择的子窗口,从0开始
10083
+ */
10084
+ openAudio: function openAudio(option) {
10085
+ this.send({
10086
+ method: 'video.enableAudio',
10087
+ info: {
10088
+ snum: option.snum,
10089
+ isEnable: option.isEnable,
10090
+ videoType: Number(this.setting.windowType) === 0 ? 0 : 1 // 0-预览音频,1-回放音频
10091
+
10092
+ }
10093
+ });
10094
+ },
10095
+
10096
+ /**
10097
+ * @method startReal 实时预览集成
10098
+ * @param { Array } option
10099
+ * @param { String } item.channelId 通道Id (必传)
10100
+ * @param { Number } item.streamType 码流类型 1 主码流 2 辅码流 (默认主码流)
10101
+ * @param { Number } item.dataType 音视频类型 1-视频 2-音频 3-音视频 (默认视频)
10102
+ * @param { Number } item.deviceType 设备类别(用于对讲)
10103
+ * @param { Number|String } item.cameraType 摄像头类型(用于云台)
10104
+ * @param { Number } item.capability 能力集(用于云台)
10105
+ */
10106
+ startReal: function startReal(option) {
10107
+ var _this9 = this;
10108
+
10109
+ var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'real';
10110
+ var tempList = []; // 切换窗口数
10111
+
10112
+ var maxNum = option.map(function (item) {
10113
+ return item.snum + 1;
10114
+ }).sort(function (a, b) {
10115
+ return b - a;
10116
+ })[0];
10117
+
10118
+ if (!isNaN(this.setting.division) && this.setting.division < maxNum) {
10119
+ this.changeDivision(maxNum);
10120
+ }
10121
+
10122
+ option.forEach(function (item) {
10123
+ var flag = false;
10124
+ _this9.setting.channelList = _this9.setting.channelList.map(function (realItem) {
10125
+ if (realItem.snum === item.snum) {
10126
+ flag = true;
10127
+ return _objectSpread2(_objectSpread2({}, item), {}, {
10128
+ closed: true
10129
+ }); // close标识位:表示外部主动删除
10130
+ }
10131
+
10132
+ return realItem;
10133
+ });
10134
+
10135
+ if (!flag) {
10136
+ tempList.push(_objectSpread2({}, item));
10137
+ }
10138
+
10139
+ flag && _this9.closeVideo(item.snum);
10140
+
10141
+ if (!_this9.setting.request[type]) {
10142
+ _this9.setting.realError && _this9.setting.realError(item, {
10143
+ code: 207,
10144
+ message: '请传入实时预览接口'
10145
+ });
10146
+ return;
10147
+ }
10148
+
10149
+ _this9.setting.request[type](getAjaxParam(item, type)).then(function (res) {
10150
+ if (res.url) {
10151
+ _this9.realByUrl({
10152
+ path: dealUrl(res),
10153
+ channelId: item.channelId,
10154
+ snum: item.snum,
10155
+ redirect: false
10156
+ }, true);
10157
+ }
10158
+ }).catch(function (err) {
10159
+ _this9.setting.channelList = _this9.setting.channelList.filter(function (realItem) {
10160
+ return realItem.snum !== item.snum;
10161
+ });
10162
+ _this9.setting.realError && _this9.setting.realError(item, err);
10163
+ });
10164
+ });
10165
+ this.setting.channelList = [].concat(_toConsumableArray(this.setting.channelList), tempList);
10166
+ },
10167
+
10168
+ /**
10169
+ * @method realByUrl 通过rtsp流地址进行实时预览
10170
+ * @param { Number } option.snum 选择的子窗口,从0开始
10171
+ * @param { String } option.channelId 通道id
10172
+ * @param { String } option.path rtsp地址
10173
+ * @param { Boolean } option.redirect 重定向,默认false (拼接地址需要改为true,接口返回地址为false)
10174
+ * @param { String } option.camerType 软/硬解码 1-软解 2-硬解
10175
+ */
10176
+ realByUrl: function realByUrl(option, isProj) {
10177
+ // 非集成情况
10178
+ if (!isProj) {
10179
+ var index = this.setting.channelList.findIndex(function (item) {
10180
+ return item.snum === option.snum;
10181
+ });
10182
+
10183
+ if (index >= 0) {
10184
+ this.setting.channelList[index] = _objectSpread2(_objectSpread2({}, option), {}, {
10185
+ byUrl: true
10186
+ });
10187
+ } else {
10188
+ this.setting.channelList.push(_objectSpread2(_objectSpread2({}, option), {}, {
10189
+ byUrl: true
10190
+ }));
10191
+ }
10192
+ }
10193
+
10194
+ this.closeVideo(option.snum);
10195
+ this.send({
10196
+ method: 'video.realmonitor',
10197
+ info: {
10198
+ snum: option.snum,
10199
+ path: option.path,
10200
+ channelId: option.channelId,
10201
+ redirect: typeof option.redirect === 'boolean' ? option.redirect : false,
10202
+ camerType: option.camerType || (this.setting.channelList.length > 15 ? '1' : '2')
10203
+ }
10204
+ });
10205
+ },
10206
+
10207
+ /**
10208
+ * @method startTalk 对讲集成
10209
+ * @param { Number } snum 选择的子窗口,从0开始
10210
+ */
10211
+ startTalk: function () {
10212
+ var _startTalk = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
10213
+ var _this10 = this;
10214
+
10215
+ var snum,
10216
+ type,
10217
+ talkIndex,
10218
+ talkParam,
10219
+ param,
10220
+ _args = arguments;
10221
+ return regeneratorRuntime.wrap(function _callee$(_context) {
10222
+ while (1) {
10223
+ switch (_context.prev = _context.next) {
10224
+ case 0:
10225
+ snum = _args.length > 0 && _args[0] !== undefined ? _args[0] : 0;
10226
+ type = _args.length > 1 && _args[1] !== undefined ? _args[1] : 'talk';
10227
+ talkIndex = this.setting.channelList.findIndex(function (item) {
10228
+ return item.snum === snum;
10229
+ });
10230
+
10231
+ if (!(talkIndex < 0)) {
10232
+ _context.next = 5;
10233
+ break;
10234
+ }
10235
+
10236
+ return _context.abrupt("return", this.setting.talkError(talkParam, '当前窗口无实时预览'));
10237
+
10238
+ case 5:
10239
+ talkParam = this.setting.channelList[talkIndex];
10240
+ param = getAjaxParam(talkParam, type).data;
10241
+
10242
+ if (this.setting.request[type]) {
10243
+ _context.next = 10;
10244
+ break;
10245
+ }
10246
+
10247
+ this.setting.talkError && this.setting.talkError(talkParam, {
10248
+ code: 207,
10249
+ message: '请传入对讲接口和停止对讲接口'
10250
+ });
10251
+ return _context.abrupt("return");
10252
+
10253
+ case 10:
10254
+ this.setting.request[type]({
10255
+ data: param
10256
+ }).then(function (res) {
10257
+ talkParam.session = res.session; // 保证所有参数都统一
10258
+
10259
+ var audioBit = res.audioBit,
10260
+ audioType = res.audioType,
10261
+ sampleRate = res.sampleRate;
10262
+ talkParam.isTalk = true; // 重新赋值调用接口
10263
+
10264
+ param.audioBit = audioBit;
10265
+ param.audioType = audioType;
10266
+ param.sampleRate = sampleRate;
10267
+ _this10.setting.request.stopTalk && _this10.setting.request.stopTalk(getAjaxParam(talkParam, 'stopTalk')).then(function () {
10268
+ _this10.setting.request[type]({
10269
+ data: param
10270
+ }).then(function (res) {
10271
+ talkParam.session = res.session;
10272
+
10273
+ _this10.talkByUrl({
10274
+ redirect: false,
10275
+ audioBit: audioBit,
10276
+ audioType: audioType,
10277
+ sampleRate: sampleRate,
10278
+ path: dealUrl(res),
10279
+ channelId: talkParam.channelId,
10280
+ talkType: getTalkType(talkParam.deviceType),
10281
+ snum: snum
10282
+ });
10283
+ });
10284
+ }).catch(function (err) {
10285
+ if (err.code === 2051) {
10286
+ _this10.startTalk(snum);
10287
+ }
10288
+ });
10289
+ }).catch(function (err) {
10290
+ _this10.setting.talkError && _this10.setting.talkError(talkParam, err);
10291
+ });
10292
+
10293
+ case 11:
10294
+ case "end":
10295
+ return _context.stop();
10296
+ }
10297
+ }
10298
+ }, _callee, this);
10299
+ }));
10300
+
10301
+ function startTalk() {
10302
+ return _startTalk.apply(this, arguments);
10303
+ }
10304
+
10305
+ return startTalk;
10306
+ }(),
10307
+
10308
+ /**
10309
+ * @method talkByUrl 通过rtsp流进行对讲
10310
+ * @param { Number } option.snum 窗口号
10311
+ * @param { String } option.channelId 通道id
10312
+ * @param { String } option.path rtsp地址
10313
+ * @param { Number } option.audioType 音频类型 0-default 1-PCM 2-G711a 3-AMR 4-G711U 5-G726 6-AAC 7-G722 8-G711
10314
+ * @param { Number } option.audioBit 位数 8 、16
10315
+ * @param { Number } option.sampleRate 采样频率 8000、16000、32000、48000、8192
10316
+ * @param { Number } option.talkType 对讲类型 1-设备 2-通道
10317
+ */
10318
+ talkByUrl: function talkByUrl(option) {
10319
+ // 关闭声音
10320
+ this.openAudio({
10321
+ snum: option.snum,
10322
+ isEnable: 0
10323
+ }); // 发送对讲
10324
+
10325
+ this.send({
10326
+ method: 'video.starttalk',
10327
+ info: {
10328
+ snum: option.snum,
10329
+ path: option.path,
10330
+ channelId: option.channelId,
10331
+ redirect: false,
10332
+ // 写死
10333
+ audioType: option.audioType,
10334
+ audioBit: option.audioBit,
10335
+ sampleRate: option.sampleRate,
10336
+ talkType: option.talkType
10337
+ }
10338
+ });
10339
+ },
10340
+
10341
+ /**
10342
+ * @method startPlayback 录像回放集成
10343
+ * @param { Array } option
10344
+ * @param { String } item.channelId 通道Id
10345
+ * @param { String } item.name 通道名称
10346
+ * @param { Number } item.streamType 码流类型 0 所有码流 1 主码流 2 辅码流 (默认所有码流)
10347
+ * @param { String } item.startTime 开始时间 '2022-10-26 00:00:00'
10348
+ * @param { String } item.endTime 结束时间 '2022-10-26 23:59:59'
10349
+ * @param { Number } item.recordSource 录像类型 2-设备录像 3-中心录像
10350
+ * @param { Number } option.snum 窗口号
10351
+ */
10352
+ startPlayback: function startPlayback(option, isConnect, bContinue) {
10353
+ var _this11 = this;
10354
+
10355
+ var timeFormatter = function timeFormatter(time) {
10356
+ return parseInt(new Date(time).getTime() / 1000);
10357
+ };
10358
+
10359
+ var getPlayBackRtsp = function getPlayBackRtsp(param) {
10360
+ if (Number(param.recordSource) === 3) {
10361
+ // 中心录像-按文件
10362
+ getPlayBackRtspByFile.call(_this11, param).then(function (res) {
10363
+ if (res.code === 201) {
10364
+ return _this11.setting.playbackError && _this11.setting.playbackError(param, res);
10365
+ }
10366
+
10367
+ param.endTime = Number(param.records[param.records.length - 1].endTime);
10368
+
10369
+ _this11.playbackByUrl({
10370
+ snum: param.snum,
10371
+ channelId: param.channelId,
10372
+ path: res.rtspUrl,
10373
+ records: res.records,
10374
+ startTime: param.startTime,
10375
+ endTime: param.endTime,
10376
+ playStartTime: param.playStartTime,
10377
+ playEndTime: param.playEndTime,
10378
+ currentPlayTime: param.currentPlayTime,
10379
+ bBack: param.bBack,
10380
+ redirect: false,
10381
+ bContinue: bContinue
10382
+ }, true);
10383
+ }).catch(function (err) {
10384
+ _this11.setting.playbackError && _this11.setting.playbackError(param, err);
10385
+ });
10386
+ } else if (Number(param.recordSource) === 2) {
10387
+ // 设备录像-按时间
10388
+ getPlayBackRtspByTime.call(_this11, param).then(function (res) {
10389
+ param.endTime = Number(param.records[param.records.length - 1].endTime);
10390
+
10391
+ _this11.playbackByUrl({
10392
+ snum: param.snum,
10393
+ channelId: param.channelId,
10394
+ path: res.rtspUrl,
10395
+ records: res.records,
10396
+ startTime: param.startTime,
10397
+ endTime: param.endTime,
10398
+ playStartTime: param.startTime,
10399
+ playEndTime: param.endTime,
10400
+ currentPlayTime: param.currentPlayTime,
10401
+ bBack: param.bBack,
10402
+ redirect: false,
10403
+ bContinue: bContinue
10404
+ }, true);
10405
+ }).catch(function (err) {
10406
+ _this11.setting.playbackError && _this11.setting.playbackError(param, err);
10407
+ });
10408
+ } else {
10409
+ _this11.setting.playbackError && _this11.setting.playbackError(param, {
10410
+ code: 404,
10411
+ message: '只能播放设备录像和中心录像!'
10412
+ });
10413
+ }
10414
+ };
10415
+
10416
+ if (isConnect) {
10417
+ getPlayBackRtsp(option);
10418
+ } else {
10419
+ var channelList = []; // 切换窗口数
10420
+
10421
+ var maxNum = option.map(function (item) {
10422
+ return item.snum + 1;
10423
+ }).sort(function (a, b) {
10424
+ return b - a;
10425
+ })[0];
10426
+
10427
+ if (!isNaN(this.setting.division) && this.setting.division < maxNum) {
10428
+ this.changeDivision(maxNum);
10429
+ }
10430
+
10431
+ option.forEach(function (item) {
10432
+ // 对时间做格式化处理
10433
+ item.startTime = timeFormatter(item.startTime);
10434
+ item.endTime = timeFormatter(item.endTime); // 如果开始时间大于结束时间,则调换位置
10435
+
10436
+ if (item.startTime > item.endTime) {
10437
+ var tempTime = item.startTime;
10438
+ item.startTime = item.endTime;
10439
+ item.endTime = tempTime;
10440
+ }
10441
+
10442
+ item.bBack = 0;
10443
+ item.currentPlayTime = item.startTime;
10444
+ var flag = true;
10445
+
10446
+ _this11.setting.channelList.forEach(function (oItem, oIndex) {
10447
+ if (oItem.snum === item.snum) {
10448
+ flag = false;
10449
+ _this11.setting.channelList[oIndex] = _objectSpread2(_objectSpread2({}, item), {}, {
10450
+ closed: true
10451
+ });
10452
+
10453
+ _this11.closeVideo(item.snum);
10454
+
10455
+ getPlayBackRtsp(item);
10456
+ }
10457
+ });
10458
+
10459
+ if (flag) {
10460
+ channelList.push(item);
10461
+ }
10462
+ });
10463
+ channelList.forEach(function (item) {
10464
+ getPlayBackRtsp(item);
10465
+ });
10466
+ this.setting.channelList = this.setting.channelList.concat(channelList);
10467
+ }
10468
+ },
10469
+
10470
+ /**
10471
+ * @method playbackByUrl 通过rtsp录像回放
10472
+ * @param { Number } option.snum 选择的子窗口,从0开始
10473
+ * @param { String } option.channelId 通道id
10474
+ * @param { String } option.path rtsp地址
10475
+ * @param { Array } option.records 包含某个时间段的录像文件信息
10476
+ * @param { Date } option.startTime 时间相关均为时间戳(new Date().getTime() / 1000)
10477
+ * @param { Date } option.endTime 时间相关均为时间戳(new Date().getTime() / 1000)
10478
+ * @param { Boolean } option.redirect 重定向,默认false (拼接地址需要改为true,接口返回地址为false)
10479
+ * @param { Boolean } option.bContinue 是否继续播放录像 true-是 false-否
10480
+ */
10481
+ playbackByUrl: function playbackByUrl(option, isProj) {
10482
+ // 非集成情况
10483
+ if (!isProj) {
10484
+ var index = this.setting.channelList.findIndex(function (item) {
10485
+ return item.snum === option.snum;
10486
+ });
10487
+
10488
+ if (index >= 0) {
10489
+ this.setting.channelList[index] = _objectSpread2(_objectSpread2({}, option), {}, {
10490
+ byUrl: true
10491
+ });
10492
+ } else {
10493
+ this.setting.channelList.push(_objectSpread2(_objectSpread2({}, option), {}, {
10494
+ byUrl: true
10495
+ }));
10496
+ }
10497
+ }
10498
+
10499
+ this.send({
10500
+ method: 'video.playback',
10501
+ info: {
10502
+ snum: option.snum,
10503
+ path: option.path,
10504
+ records: option.records,
10505
+ startTime: option.startTime,
10506
+ endTime: option.endTime,
10507
+ playStartTime: option.playStartTime || option.startTime,
10508
+ playEndTime: option.playEndTime || option.endTime,
10509
+ currentPlayTime: option.currentPlayTime || option.startTime,
10510
+ channelId: option.channelId,
10511
+ redirect: typeof option.redirect === 'boolean' ? option.redirect : false,
10512
+ bBack: option.bBack || 0,
10513
+ bContinue: !!option.bContinue
10514
+ }
10515
+ });
10516
+ },
10517
+
10518
+ /**
10519
+ * 处理DHPlayer位置
10520
+ * @param {*} option
10521
+ * @param {*} callBack
10522
+ * @returns
10523
+ */
10524
+ changePosition: function changePosition(option, callBack) {
10525
+ var _this12 = this;
10526
+
10527
+ var windowSize = getWindowSize.call(this);
10528
+ var zoom = detectZoom();
10529
+ var rect = getRect.call(this);
10530
+
10531
+ for (var i in rect) {
10532
+ rect[i] = rect[i] * zoom / 100;
10533
+ }
10534
+
10535
+ var _info = Object.assign({}, {}, rect, option);
10536
+
10537
+ _info.clientAreaHeight = windowSize.height * zoom / 100;
10538
+ _info.clientAreaWidth = windowSize.width * zoom / 100;
10539
+ _info.browserScreenX = getScreenX(); // 暂时用不到
10540
+
10541
+ _info.screenX = window.screenX;
10542
+ _info.screenY = window.screenY;
10543
+ delete _info.width;
10544
+ delete _info.height;
10545
+ _info.show = document.visibilityState === 'hidden' ? false : true;
10546
+ _info.title = document.title;
10547
+
10548
+ var sendPosition = function sendPosition() {
10549
+ _this12.send({
10550
+ method: 'window.change',
10551
+ info: _info
10552
+ }, callBack);
10553
+ }; // 位置改变后就触发遮挡
10554
+
10555
+
10556
+ if (this.setting.oldPosition === JSON.stringify(_info)) {
10557
+ // 位置固定后,改变三次位置,强制触发三次遮挡,处理位置偏移问题。
10558
+ while (this.adjustCount < 3) {
10559
+ this.adjustCount++;
10560
+ sendPosition();
10561
+ this.windowShield(this.cover(), true);
10562
+ }
10563
+
10564
+ return;
10565
+ } // 位置发生改变,强制触发遮挡事件
10566
+
10567
+
10568
+ this.adjustCount = 0;
10569
+ this.setting.oldPosition = JSON.stringify(_info);
10570
+ sendPosition();
10571
+ },
10572
+ // 隐藏视频
10573
+ hide: function hide() {
10574
+ this.setting.show = false;
10575
+ this.setting.stopRefresh = true;
10576
+ this.send({
10577
+ method: 'window.show',
10578
+ info: {
10579
+ show: false
10580
+ }
10581
+ });
10582
+ },
10583
+ //显示视频
10584
+ show: function show() {
10585
+ var that = this;
10586
+ this.setting.stopRefresh = false;
10587
+ this.setting.show = true;
10588
+ this.send({
10589
+ method: 'window.show',
10590
+ info: {
10591
+ show: true
10592
+ }
10593
+ }, {
10594
+ onSuccess: function onSuccess() {
10595
+ if (that.setting.refreshTimer) {
10596
+ window.cancelAnimationFrame(that.setting.refreshTimer);
10597
+ }
10598
+
10599
+ that.setting.oldPosition = '';
10600
+ that.handleAdjust();
10601
+ that.setting.showWindowSuccess && that.setting.showWindowSuccess();
10602
+ },
10603
+ onError: this.setting.showWindowError
10604
+ });
10605
+ },
10606
+
10607
+ /**
10608
+ * @method downloadRecord 录像下载
10609
+ * @param { Object } option
10610
+ * @param { Number } option.snum 选择的子窗口,从0开始
10611
+ * @param { String } option.url 下载地址
10612
+ * @param { Array } option.records 包含某个时间段的录像文件信息
10613
+ * @param { Number } option.startTime 时间相关均为时间戳,具体参考大华播放控件开发手册
10614
+ * @param { Number } option.endTime 时间相关均为时间戳,具体参考大华播放控件开发手册
10615
+ * @param { Boolean } option.redirect 默认 false
10616
+ */
10617
+ downloadRecord: function downloadRecord(option) {
10618
+ this.send({
10619
+ method: 'video.downloadByTime',
10620
+ info: {
10621
+ snum: option.snum,
10622
+ url: option.url,
10623
+ records: option.records,
10624
+ startTime: option.startTime,
10625
+ endTime: option.endTime,
10626
+ redirect: typeof option.redirect === 'boolean' ? option.redirect : false
10627
+ }
10628
+ });
10629
+ },
10630
+
10631
+ /**
10632
+ * @method closeVideo 关闭指定窗口视频或全部关闭
10633
+ * @param { Number } option.snum 选择的子窗口, 不传默认全部关闭
10634
+ */
10635
+ closeVideo: function closeVideo(snum) {
10636
+ this.send({
10637
+ method: 'video.close',
10638
+ info: {
10639
+ snum: typeof snum === 'number' ? snum : 0,
10640
+ isAll: typeof snum === 'number' ? false : true
10641
+ }
10642
+ });
10643
+ },
10644
+
10645
+ /**
10646
+ * @method closeTalk 关闭对讲
10647
+ */
10648
+ closeTalk: function closeTalk() {
10649
+ this.send({
10650
+ method: 'video.closetalk',
10651
+ info: {
10652
+ snum: 0,
10653
+ isAll: true
10654
+ }
10655
+ });
10656
+ },
10657
+
10658
+ /**
10659
+ * @method continuePlayback 操作录像
10660
+ * @param { Number } option.snum 选择的子窗口,从0开始
10661
+ * @param { Number } option.state 窗口状态:0-暂停,1-继续
10662
+ */
10663
+ controlPlayback: function controlPlayback(option) {
10664
+ this.send({
10665
+ method: 'video.playbackChangeState',
10666
+ info: {
10667
+ snum: option.snum,
10668
+ state: option.state
10669
+ }
10670
+ });
10671
+ },
10672
+ //显示下方控制栏, show: true-显示,false-隐藏
10673
+ showControlBar: function showControlBar() {
10674
+ var show = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
10675
+ this.setting.showBar = show;
10676
+ this.send({
10677
+ method: 'video.setToolBarShow',
10678
+ info: {
10679
+ isShow: show ? 1 : 0
10680
+ }
10681
+ });
10682
+ },
10683
+
10684
+ /**
10685
+ * @method continuePlayback 本地录像下载
10686
+ * @param { Number } snum 选择的子窗口,从0开始
10687
+ */
10688
+ localRecordDownload: function localRecordDownload(snum) {
10689
+ this.send({
10690
+ method: 'vidoe.localRecord',
10691
+ info: {
10692
+ snum: snum
10693
+ }
10694
+ });
10695
+ },
10696
+
10697
+ /**
10698
+ * @method video.division.change 切换当前控件展示的窗口数量
10699
+ * @param {*} division 当前控件展示的窗口数量
10700
+ * @param {String} 分割窗口数类型 normal-正常 custom-自定义
10701
+ * @desc 代码手动调用该方法没有提供回调,此处添加回调
10702
+ */
10703
+ changeDivision: function changeDivision(info) {
10704
+ if (info) {
10705
+ // 自定义的情况
10706
+ if (isNaN(info)) {
10707
+ this.setting.division = info;
10708
+ this.send({
10709
+ method: 'video.customDivision.change',
10710
+ info: JSON.parse(info)
10711
+ });
10712
+ this.setting.changeDivision && this.setting.changeDivision(info);
10713
+ } else {
10714
+ this.setting.division = Number(info);
10715
+ this.send({
10716
+ method: 'video.division.change',
10717
+ info: {
10718
+ division: this.setting.division
10719
+ }
10720
+ });
10721
+ this.setting.changeDivision && this.setting.changeDivision(this.setting.division);
10722
+ }
10723
+
10724
+ this.setWindowDragEnable();
10725
+ }
10726
+ },
10727
+ //窗口抓图
10728
+ snapshot: function snapshot(snum) {
10729
+ this.send({
10730
+ method: 'video.snapic',
10731
+ info: {
10732
+ snum: snum
10733
+ }
10734
+ });
10735
+ },
10736
+ // 视频被遮挡处理
10737
+ windowShield: function windowShield(option, flag, callBack) {
10738
+ var windowSize = getWindowSize.call(this);
10739
+ var zoom = detectZoom();
10740
+ var _info = {};
10741
+ _info.region = this.getShieldRect(option).map(function (item) {
10742
+ return item * zoom / 100;
10743
+ });
10744
+ _info.clientAreaHeight = windowSize.height * zoom / 100;
10745
+ _info.clientAreaWidth = windowSize.width * zoom / 100;
10746
+
10747
+ if (!flag && this.setting.oldShield === JSON.stringify(_info)) {
10748
+ return;
10749
+ }
10750
+
10751
+ this.setting.oldShield = JSON.stringify(_info);
10752
+ this.send({
10753
+ method: 'window.shield',
10754
+ info: _info
10755
+ }, callBack);
10756
+ },
10757
+ // 视频插件版本号
10758
+ version: function version(callBack) {
10759
+ this.send({
10760
+ method: 'common.version',
10761
+ info: {}
10762
+ }, callBack);
10763
+ },
10764
+
10765
+ /**
10766
+ * 视频是否显示规划线
10767
+ * @param { Object } option
10768
+ * @param { Number } snum 窗口号
10769
+ * @param { isEnableIVS } 是否显示规则框 true-显示 false-隐藏
10770
+ * @param { ivsType } 规则框类型 1-智能规则框,2-智能目标框 (不传默认为1)
10771
+ */
10772
+ isEnableIvs: function isEnableIvs(option) {
10773
+ this.send({
10774
+ method: 'video.enableIvs',
10775
+ info: {
10776
+ snum: option.snum,
10777
+ isEnableIVS: option.isEnableIVS,
10778
+ ivsType: option.ivsType
10779
+ }
10780
+ });
10781
+ },
10782
+ //
10783
+ getWindowState: function getWindowState(callBack) {
10784
+ this.send({
10785
+ method: 'window.getWindowState',
10786
+ info: {}
10787
+ }, callBack);
10788
+ },
10789
+ // 防止插件超出浏览器显示
10790
+ cover: function cover() {
10791
+ var rect = getRect.call(this);
10792
+ var left = rect.left,
10793
+ top = rect.top,
10794
+ right = rect.right,
10795
+ bottom = rect.bottom,
10796
+ width = rect.width,
10797
+ height = rect.height,
10798
+ arr = [],
10799
+ windowSize = getWindowSize.call(this);
10800
+
10801
+ var shieldFn = function shieldFn(domSize) {
10802
+ if (domSize && domSize[0]) {
10803
+ // 超过上方则遮挡
10804
+ if (top < domSize[0].top) {
10805
+ arr.push(left, top, width + 1, domSize[0].top - top);
10806
+ } // 超过下方则遮挡
10807
+
10808
+
10809
+ if (bottom > domSize[0].bottom) {
10810
+ arr.push(left, domSize[0].bottom, width + 1, bottom - domSize[0].bottom);
10811
+ } // 左侧遮挡
10812
+
10813
+
10814
+ if (left < domSize[0].left) {
10815
+ arr.push(left, top, domSize[0].left - left, height);
10816
+ } // 右侧遮挡
10817
+
10818
+
10819
+ if (right > domSize[0].right) {
10820
+ arr.push(domSize[0].right, top, right - domSize[0].right, height);
10821
+ }
10822
+ }
10823
+ }; // 处理有iframe下, 超出最外侧body遮挡的问题
10824
+
10825
+
10826
+ shieldFn([{
10827
+ top: 0,
10828
+ left: 0,
10829
+ right: windowSize.width,
10830
+ bottom: windowSize.height
10831
+ }]); // 处理当前window下的遮挡问题
10832
+
10833
+ var pOutContent;
10834
+
10835
+ if (window.dhPlayerControl.isPIframe) {
10836
+ pOutContent = this.setting.pIframeRect;
10837
+ outLeft = pOutContent.left;
10838
+ outTop = pOutContent.top;
10839
+ } else {
10840
+ var iframes = window.parent.document.getElementsByTagName('iframe');
10841
+ var pIframe = null;
10842
+
10843
+ for (var i = 0; i < iframes.length; i++) {
10844
+ var dom = iframes[i].contentWindow.document.getElementById(this.setting.videoId);
10845
+
10846
+ if (dom) {
10847
+ pIframe = iframes[i];
10848
+ break;
10849
+ }
10850
+ }
10851
+
10852
+ if (pIframe) {
10853
+ pOutContent = pIframe.getBoundingClientRect();
10854
+ }
10855
+ }
10856
+
10857
+ pOutContent && shieldFn([{
10858
+ top: pOutContent.top,
10859
+ left: pOutContent.left,
10860
+ width: window.width,
10861
+ height: window.height
10862
+ }]); // 处理DOM元素遮挡问题,主要用于滚动页面,超出隐藏的问题
10863
+
10864
+ if (this.setting.coverShieldClass && this.setting.coverShieldClass.length) {
10865
+ this.setting.coverShieldClass.forEach(function (item) {
10866
+ var dom = document.getElementsByClassName(item)[0];
10867
+ var domSize = dom ? dom.getClientRects() : null;
10868
+ domSize && shieldFn(domSize);
10869
+ });
10870
+ }
10871
+
10872
+ return arr;
10873
+ },
10874
+ // 扩展方法
10875
+ extendOption: function extendOption(ids, option) {
10876
+ var map = {};
10877
+
10878
+ for (var i = 0; i < ids.length; i++) {
10879
+ map[ids[i]] = this.setting[ids[i]];
10880
+ }
10881
+
10882
+ return Object.assign({}, map, option);
10883
+ },
10884
+ //遮挡部分位置获取
10885
+ getShieldRect: function getShieldRect(option) {
10886
+ var shieldClass = this.setting.shieldClass || [];
10887
+ var rect,
10888
+ arr = option || [];
10889
+
10890
+ for (var i = 0; i < shieldClass.length; i++) {
10891
+ rect = getRect.call(this, shieldClass[i]);
10892
+
10893
+ if (rect && (rect.width || rect.height)) {
10894
+ arr.push(rect.left, rect.top, rect.width, rect.height);
10895
+ }
10896
+ }
10897
+
10898
+ if (window.dhPlayerControl.isPIframe) {
10899
+ arr.push.apply(arr, _toConsumableArray(this.setting.pIframeShieldData));
10900
+ } else {
10901
+ var parentIframeShieldClass = this.setting.parentIframeShieldClass || [];
10902
+
10903
+ for (i = 0; i < parentIframeShieldClass.length; i++) {
10904
+ rect = getParentIframeRect.call(this, parentIframeShieldClass[i]);
10905
+
10906
+ if (rect && (rect.width || rect.height)) {
10907
+ arr.push(rect.left, rect.top, rect.width, rect.height);
10908
+ }
10909
+ }
10910
+ }
10911
+
10912
+ return arr;
10913
+ },
10914
+ MainCall: function MainCall(option) {
10915
+ var dom = document.getElementById(this.setting.ieDom);
10916
+ this.setting.option_id[option.id] = option;
10917
+ dom && dom.MainCall(option.method, JSON.stringify(option));
10918
+ },
10919
+ init: function init() {
10920
+ var _this13 = this;
10921
+
10922
+ // 判断是不是跨域
10923
+ try {
10924
+ // 不是跨域
10925
+ console.log(window.top.origin);
10926
+ window.dhPlayerControl.isPIframe = false;
10927
+ this.initPlayer();
10928
+ } catch (err) {
10929
+ // 是跨域
10930
+ addEventListener('message', function (e) {
10931
+ window.dhPlayerControl.isPIframe = true;
10932
+
10933
+ if (e.data.methods === 'rect') {
10934
+ _this13.setting.topInnerWidth = e.data.topInnerWidth;
10935
+ _this13.setting.topInnerHeight = e.data.topInnerHeight;
10936
+ _this13.setting.pIframeRect = e.data.pIframeRect;
10937
+ }
10938
+
10939
+ if (e.data.methods == 'shieldRect') {
10940
+ _this13.setting.pIframeShieldData = e.data.pIframeShieldData;
10941
+ }
10942
+
10943
+ _this13.initPlayer();
10944
+ });
10945
+ }
10946
+ },
10947
+ initPlayer: function initPlayer() {
10948
+ var hwnd = '';
10949
+
10950
+ if (window.dhPlayerControl.videoList[this.setting.videoId]) {
10951
+ hwnd = window.dhPlayerControl.videoList[this.setting.videoId].setting.hwnd;
10952
+ }
10953
+
10954
+ window.dhPlayerControl.videoList[this.setting.videoId] = this;
10955
+ this.setting.hwnd = hwnd;
10956
+
10957
+ if (!window.dhPlayerControl.wsConnect) {
10958
+ window.dhPlayerControl.wsConnect = true;
10959
+ socketPort.call(this);
10960
+ } else {
10961
+ if (window.dhPlayerControl.windowState === 'wsSuccess') {
10962
+ this.create();
10963
+ } else if (!window.dhPlayerControl.DHPlayerVersion) {
10964
+ this.setting.createError && this.setting.createError({
10965
+ code: 1001,
10966
+ success: false,
10967
+ message: '插件未安装!'
10968
+ });
10969
+ }
10970
+ }
10971
+
10972
+ this.setting.browserType = broswerInfo();
10973
+ }
10974
+ };
10975
+ window.VideoPlayer = window.VideoPlayer || VideoPlayer;
10976
+ })();
10977
+
10978
+ function DhPlayer(_ref, ref) {
10979
+ var playersRef = _ref.playersRef,
10980
+ _ref$videoId = _ref.videoId,
10981
+ videoId = _ref$videoId === void 0 ? 'dhplayer' : _ref$videoId,
10982
+ _ref$showBg = _ref.showBg,
10983
+ showBg = _ref$showBg === void 0 ? false : _ref$showBg,
10984
+ height = _ref.height,
10985
+ num = _ref.num,
10986
+ _ref$visible = _ref.visible,
10987
+ visible = _ref$visible === void 0 ? true : _ref$visible,
10988
+ _ref$draggable = _ref.draggable,
10989
+ draggable = _ref$draggable === void 0 ? false : _ref$draggable,
10990
+ division = _ref.division,
10991
+ shieldClass = _ref.shieldClass,
10992
+ coverShieldClass = _ref.coverShieldClass,
10993
+ parentIframeShieldClass = _ref.parentIframeShieldClass,
10994
+ _ref$windowType = _ref.windowType,
10995
+ windowType = _ref$windowType === void 0 ? 0 : _ref$windowType,
10996
+ _ref$showBar = _ref.showBar,
10997
+ showBar = _ref$showBar === void 0 ? true : _ref$showBar,
10998
+ request = _ref.request,
10999
+ _createSuccess = _ref.createSuccess,
11000
+ _createError = _ref.createError,
11001
+ _realSuccess = _ref.realSuccess,
11002
+ _realError = _ref.realError,
11003
+ _playbackSuccess = _ref.playbackSuccess,
11004
+ _playbackError = _ref.playbackError,
11005
+ _playbackFinish = _ref.playbackFinish,
11006
+ _switchStartTime = _ref.switchStartTime,
11007
+ _changeDivision = _ref.changeDivision,
11008
+ _replay = _ref.replay,
11009
+ _videoDownloadSuccess = _ref.videoDownloadSuccess,
11010
+ _closeWindowSuccess = _ref.closeWindowSuccess,
11011
+ _clickWindow = _ref.clickWindow,
11012
+ _dbClickWindow = _ref.dbClickWindow,
11013
+ _downloadProgress = _ref.downloadProgress,
11014
+ _downloadRecordSuccess = _ref.downloadRecordSuccess,
11015
+ destroySuccess = _ref.destroySuccess;
11016
+ var playerRef = React.useRef(null);
11017
+
11018
+ var _useState = React.useState(null),
11019
+ _useState2 = _slicedToArray(_useState, 2),
11020
+ videoPlayer = _useState2[0],
11021
+ setVideoPlayer = _useState2[1];
11022
+
11023
+ var _useState3 = React.useState(null),
11024
+ _useState4 = _slicedToArray(_useState3, 2),
11025
+ realPanControl = _useState4[0],
11026
+ setRealPanControl = _useState4[1];
11027
+
11028
+ var _useState5 = React.useState('插件加载中...'),
11029
+ _useState6 = _slicedToArray(_useState5, 2),
11030
+ dhErrorMsg = _useState6[0],
11031
+ setDhErrorMsg = _useState6[1];
11032
+
11033
+ var _notification$useNoti = antd.notification.useNotification(),
11034
+ _notification$useNoti2 = _slicedToArray(_notification$useNoti, 2),
11035
+ api = _notification$useNoti2[0],
11036
+ contextHolder = _notification$useNoti2[1];
11037
+
11038
+ var initVideo = function initVideo() {
11039
+ var vmPlayer = new VideoPlayer({
11040
+ videoId: videoId,
11041
+ windowType: windowType || 0,
11042
+ shieldClass: shieldClass || [],
11043
+ coverShieldClass: coverShieldClass || [],
11044
+ parentIframeShieldClass: parentIframeShieldClass || [],
11045
+ showBar: showBar,
11046
+ division: division,
11047
+ visible: visible,
11048
+ draggable: draggable,
11049
+ request: request || {
11050
+ real: null,
11051
+ talk: null,
11052
+ stopTalk: null,
11053
+ playbackByTime: null,
11054
+ playbackByFile: null,
11055
+ queryRecord: null // 查询录像
11056
+
11057
+ },
11058
+ // 创建播放器成功
11059
+ createSuccess: function createSuccess() {
11060
+ _createSuccess === null || _createSuccess === void 0 ? void 0 : _createSuccess();
11061
+ },
11062
+ // 播放器创建失败
11063
+ createError: function createError(err) {
11064
+ console.log('-----播放器加载失败,错误原因:', err);
11065
+ sessionStorage.setItem('dhplayer-info', err.message);
11066
+ setDhErrorMsg(err.message);
11067
+
11068
+ if (err.code == 1001) {
11069
+ api.error({
11070
+ message: "".concat(err.message),
11071
+ description: /*#__PURE__*/React__default['default'].createElement("span", null, "\u8BF7\u4E0B\u8F7D\u63D2\u4EF6\u540E\uFF0C\u53CC\u51FB\u8FD0\u884C\uFF1A", /*#__PURE__*/React__default['default'].createElement("a", {
11072
+ href: "https://static.eblssmart.com/lfhz/DHPlayer_x64.zip"
11073
+ }, "\u70B9\u51FB\u4E0B\u8F7D")),
11074
+ placement: 'top',
11075
+ duration: null
11076
+ });
11077
+ }
11078
+
11079
+ _createError && _createError(err);
11080
+ },
11081
+ //抓图成功
11082
+ // snapshotSuccess: ({ base64Url, path }) => {
11083
+ // this.$emit('picCap', {
11084
+ // base64Url,
11085
+ // path
11086
+ // })
11087
+ // },
11088
+ // 实时预览成功回调
11089
+ realSuccess: function realSuccess(info) {
11090
+ _realSuccess && _realSuccess(info);
11091
+ },
11092
+ // 实时预览错误回调
11093
+ realError: function realError(info, err) {
11094
+ console.log(info, err);
11095
+ _realError && _realError(info, err);
11096
+ },
11097
+ // // 对讲成功回调
11098
+ // talkSuccess: (info) => {
11099
+ // this.$emit('talkSuccess', info)
11100
+ // },
11101
+ // // 对讲错误回调
11102
+ // talkError: (info, err) => {
11103
+ // console.log(info, err)
11104
+ // this.$emit('talkError', info, err)
11105
+ // },
11106
+ // 录像回放成功回调
11107
+ playbackSuccess: function playbackSuccess(info) {
11108
+ _playbackSuccess && _playbackSuccess(info);
11109
+ },
11110
+ // 录像错误,录像播放完成回调
11111
+ playbackError: function playbackError(info, err) {
11112
+ console.log(info, err, 'playbackError');
11113
+ _playbackError && _playbackError(info, err);
11114
+ },
11115
+ // 录像播放完成
11116
+ playbackFinish: function playbackFinish(info) {
11117
+ _playbackFinish && _playbackFinish(info);
11118
+ },
11119
+ // // 点击对讲按钮的回调
11120
+ // notifyTalk: ({ channelId, snum }) => {
11121
+ // this.$emit('notifyTalk', { channelId, snum })
11122
+ // },
11123
+ //录像回放时间栏拖拽回调
11124
+ // 拖拽后需要重新掉接口获取rtsp地址传入播放器
11125
+ switchStartTime: function switchStartTime(_ref2) {
11126
+ var startTime = _ref2.startTime,
11127
+ snum = _ref2.snum;
11128
+ _switchStartTime && _switchStartTime(startTime, snum);
11129
+ },
11130
+ replay: function replay(snum) {
11131
+ //录像回放播放结束回调,返回窗口
11132
+ // this.$emit('replay', snum)
11133
+ _replay && _replay(snum);
11134
+ },
11135
+ // 本地录像下载成功回调
11136
+ videoDownloadSuccess: function videoDownloadSuccess(path) {
11137
+ _videoDownloadSuccess && _videoDownloadSuccess(path);
11138
+ },
11139
+ //关闭视频窗口回调
11140
+ closeWindowSuccess: function closeWindowSuccess(_ref3) {
11141
+ var isAll = _ref3.isAll,
11142
+ snum = _ref3.snum;
11143
+ console.log("\u5173\u95ED\u7B2C".concat(snum, "\u4E2A\u6B63\u5728\u64AD\u653E\u7684\u89C6\u9891"));
11144
+ _closeWindowSuccess && _closeWindowSuccess({
11145
+ isAll: isAll,
11146
+ snum: snum
11147
+ });
11148
+ },
11149
+ // 窗口单击回调
11150
+ clickWindow: function clickWindow(snum, info) {
11151
+ console.log("\u5F53\u524D\u70B9\u51FB\u4E86\u7B2C".concat(snum, "\u4E2A\u7A97\u53E3"));
11152
+ _clickWindow && _clickWindow(snum, info);
11153
+
11154
+ if (windowType === 0) {
11155
+ usePanTilt(info);
11156
+ }
11157
+ },
11158
+ // 窗口双击回调
11159
+ dbClickWindow: function dbClickWindow(snum, info) {
11160
+ console.log("\u5F53\u524D\u53CC\u51FB\u4E86\u7B2C".concat(snum, "\u4E2A\u7A97\u53E3"));
11161
+ _dbClickWindow && _dbClickWindow(snum, info);
11162
+ },
11163
+ // 改变当前窗口数回调
11164
+ changeDivision: function changeDivision(division) {
11165
+ console.log("\u5F53\u524D\u7A97\u53E3\u6570\u91CF: ".concat(division));
11166
+ _changeDivision && _changeDivision(division);
11167
+ },
11168
+ // 下载录像进度
11169
+ downloadProgress: function downloadProgress(info) {
11170
+ _downloadProgress && _downloadProgress(info);
11171
+ },
11172
+ // 下载录像成功回调
11173
+ downloadRecordSuccess: function downloadRecordSuccess(info) {
11174
+ _downloadRecordSuccess && _downloadRecordSuccess(info);
11175
+ }
11176
+ });
11177
+ playersRef = vmPlayer;
11178
+ playerRef.current = vmPlayer;
11179
+ setVideoPlayer(vmPlayer);
11180
+ };
11181
+
11182
+ var __update = function __update() {
11183
+ var params = {
11184
+ showBar: showBar,
11185
+ division: division,
11186
+ visible: visible,
11187
+ draggable: draggable,
11188
+ request: request
11189
+ };
11190
+ videoPlayer && videoPlayer._update(params);
11191
+ };
11192
+
11193
+ React.useImperativeHandle(ref, function () {
11194
+ return {
11195
+ videoPlayer: playerRef,
11196
+ initPanTilt: initPanTilt,
11197
+ usePanTilt: usePanTilt,
11198
+ startReal: startReal,
11199
+ realByUrl: realByUrl,
11200
+ setFullScreen: setFullScreen,
11201
+ hideWindow: hideWindow,
11202
+ changeDivision: handlechangeDivision,
11203
+ showWindow: showWindow,
11204
+ chooseWindow: chooseWindow,
11205
+ closeVideo: closeVideo
11206
+ };
11207
+ });
11208
+ /**
11209
+ * 云台功能初始化
11210
+ */
11211
+
11212
+ var initPanTilt = function initPanTilt(el) {// setRealPanControl(new PanTilt({
11213
+ // el, // 云台容器id
11214
+ // // setPtzDirection: request.setPtzDirection, // 云台方向控制接口
11215
+ // // setPtzCamera: request.setPtzCamera // 云台镜头控制接口
11216
+ // }))
11217
+ }; // 使用云台
11218
+
11219
+
11220
+ var usePanTilt = function usePanTilt(info) {
11221
+ info && info.channelId && realPanControl && realPanControl.setChannel({
11222
+ id: info.channelId,
11223
+ cameraType: info.cameraType,
11224
+ capability: info.capability
11225
+ });
11226
+ };
11227
+ /**
11228
+ * @param startReal 实时预览集成
11229
+ * @param list [array]
11230
+ * @param item.channelId 通道Id (必传)
11231
+ * @param item.streamType 码流类型 0 所有码流 1 主码流 2 辅码流 (默认所有码流)
11232
+ * @param item.dataType 音视频类型 1-视频 2-音频 3-音视频 (默认视频)
11233
+ * @param item.snum 窗口号
11234
+ */
11235
+
11236
+
11237
+ var startReal = function startReal(list) {
11238
+ videoPlayer.startReal(list);
11239
+ setTimeout(function () {
11240
+ usePanTilt(list[0]);
11241
+ }, 300);
11242
+ }; // 实时预览
11243
+
11244
+
11245
+ var realByUrl = function realByUrl(o) {
11246
+ videoPlayer.realByUrl(o);
11247
+ }; // 全屏
11248
+
11249
+
11250
+ var setFullScreen = function setFullScreen() {
11251
+ videoPlayer.setFullScreen();
11252
+ }; // // 改变当前播放器的窗口数
11253
+
11254
+
11255
+ var handlechangeDivision = function handlechangeDivision(division) {
11256
+ playerRef.current.changeDivision(division);
11257
+ }; //隐藏窗口
11258
+
11259
+
11260
+ var hideWindow = function hideWindow() {
11261
+ setDhErrorMsg('插件已隐藏');
11262
+ videoPlayer.hide();
11263
+ }; //显示窗口
11264
+
11265
+
11266
+ var showWindow = function showWindow() {
11267
+ videoPlayer.show();
11268
+ }; // 选择窗口
11269
+
11270
+
11271
+ var chooseWindow = function chooseWindow(snum) {
11272
+ videoPlayer.chooseWindow(snum, function (info) {
11273
+ info && usePanTilt(info);
11274
+ });
11275
+ }; // 关闭视频(不传默认全部关闭)
11276
+
11277
+
11278
+ var closeVideo = function closeVideo(snum) {
11279
+ videoPlayer.closeVideo(snum);
11280
+ };
11281
+
11282
+ React.useEffect(function () {
11283
+ initVideo();
11284
+ }, []);
11285
+ React.useEffect(function () {
11286
+ __update();
11287
+ }, [num, showBar, visible, draggable, division, request]);
11288
+ React.useEffect(function () {
11289
+ return function () {
11290
+ videoPlayer && videoPlayer.destroy().then(function () {
11291
+ setDhErrorMsg('插件已销毁');
11292
+ destroySuccess && destroySuccess();
11293
+ });
11294
+ };
11295
+ }, [videoPlayer]);
11296
+ return /*#__PURE__*/React__default['default'].createElement("div", {
11297
+ style: {
11298
+ height: "".concat(height ? height + 'px' : '100%')
11299
+ }
11300
+ }, contextHolder, /*#__PURE__*/React__default['default'].createElement("div", {
11301
+ id: videoId,
11302
+ className: "dh-bg",
11303
+ style: {
11304
+ height: '100%'
11305
+ }
11306
+ }, showBg && /*#__PURE__*/React__default['default'].createElement("div", {
11307
+ className: "dh-desc"
11308
+ }, /*#__PURE__*/React__default['default'].createElement("span", null, dhErrorMsg))));
11309
+ }
11310
+
11311
+ var index$7 = /*#__PURE__*/React.forwardRef(DhPlayer);
8595
11312
 
8596
11313
  var _excluded$m = ["id", "videoUrls", "definitionList", "isLoop", "muted", "currentIndex", "setCurrentIndex", "className", "style", "visible", "autoplay", "videoInit", "enableMemory", "lastPlayTimeHideDelay"];
8597
11314
 
@@ -8600,7 +11317,7 @@ var DEFAULT_PLAY_BACK_RATE = [0.5, 0.75, 1, 1.5, 2]; // 默认记忆提示文字
8600
11317
  var DEFAULT_LAST_PLAY_TIME_DELAY = 5; // 默认音量大小
8601
11318
 
8602
11319
  var DEFAULT_VOLUME = 0.6;
8603
- var index$7 = /*#__PURE__*/React.forwardRef(function (_ref, playerRef) {
11320
+ var index$8 = /*#__PURE__*/React.forwardRef(function (_ref, playerRef) {
8604
11321
  var id = _ref.id,
8605
11322
  _ref$videoUrls = _ref.videoUrls,
8606
11323
  videoUrls = _ref$videoUrls === void 0 ? [] : _ref$videoUrls,
@@ -9488,7 +12205,7 @@ function NtTable(_ref) {
9488
12205
  NtTable.defaultProps = {
9489
12206
  rowKey: 'key'
9490
12207
  };
9491
- var index$8 = /*#__PURE__*/React.memo(NtTable);
12208
+ var index$9 = /*#__PURE__*/React.memo(NtTable);
9492
12209
 
9493
12210
  /*
9494
12211
  * @Author: lijin
@@ -10272,10 +12989,10 @@ function WaterLevelCharts(config) {
10272
12989
  /*
10273
12990
  * @Author: lijin
10274
12991
  * @Date: 2021-09-09 11:02:54
10275
- * @LastEditTime: 2023-05-10 14:18:03
12992
+ * @LastEditTime: 2023-05-10 19:07:53
10276
12993
  * @LastEditors: lijin
10277
12994
  * @Description:
10278
- * @FilePath: \wargerm\src\index.ts
12995
+ * @FilePath: \wargerm-components\src\index.ts
10279
12996
  * 可以输入预定的版权声明、个性签名、空行等
10280
12997
  */
10281
12998
  console.log(REACT_APP_ENV, 'REACT_APP_ENV');
@@ -10294,6 +13011,7 @@ exports.Cascader = WCascader;
10294
13011
  exports.Checkbox = Index$4;
10295
13012
  exports.CountUp = Index$a;
10296
13013
  exports.DatePicker = Index$2;
13014
+ exports.DhPlayer = index$7;
10297
13015
  exports.DragBox = DragBox;
10298
13016
  exports.IconFont = index;
10299
13017
  exports.Input = Index;
@@ -10302,7 +13020,7 @@ exports.LineEcharts = LineEcharts;
10302
13020
  exports.Modal = Modal;
10303
13021
  exports.ModalForm = ModalForm$1;
10304
13022
  exports.ModalTips = Modal$1;
10305
- exports.NtTable = index$8;
13023
+ exports.NtTable = index$9;
10306
13024
  exports.Number = Index$9;
10307
13025
  exports.NumericInput = NumericInput;
10308
13026
  exports.Radio = Index$3;
@@ -10314,7 +13032,7 @@ exports.TabelCard = index$4;
10314
13032
  exports.Table = index$1;
10315
13033
  exports.TreeSelect = Index$7;
10316
13034
  exports.Upload = Upload;
10317
- exports.Video = index$7;
13035
+ exports.Video = index$8;
10318
13036
  exports.VideoPlayer = index$6;
10319
13037
  exports.WDatePicker = Index$6;
10320
13038
  exports.WForm = WForm$1;