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