@vtx/player 1.7.14 → 1.7.16
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/README.md +2 -2
- package/lib/api/fetch.js +91 -62
- package/lib/api/fetch.js.map +1 -1
- package/lib/api/index.js +63 -18
- package/lib/api/index.js.map +1 -1
- package/lib/api/types.d.ts +5 -5
- package/lib/bd/PlayerManager.js +68 -38
- package/lib/bd/PlayerManager.js.map +1 -1
- package/lib/bill-player/index.d.ts +1 -1
- package/lib/bill-player/index.js +121 -66
- package/lib/bill-player/index.js.map +1 -1
- package/lib/bill-player/style/css.js +9 -0
- package/lib/bill-player/style/css.js.map +1 -1
- package/lib/bill-player/style/index.js +9 -0
- package/lib/bill-player/style/index.js.map +1 -1
- package/lib/bill-player/style/index.less +297 -297
- package/lib/components/set-tag-video/index.js +34 -6
- package/lib/components/set-tag-video/index.js.map +1 -1
- package/lib/components/set-tag-video/style/css.js.map +1 -1
- package/lib/components/set-tag-video/style/index.js.map +1 -1
- package/lib/components/set-tag-video/style/index.less +125 -125
- package/lib/components/split-screen/index.d.ts +1 -1
- package/lib/components/split-screen/index.js +14 -3
- package/lib/components/split-screen/index.js.map +1 -1
- package/lib/components/split-screen/style/css.js.map +1 -1
- package/lib/components/split-screen/style/index.js.map +1 -1
- package/lib/components/tag-video/index.js +38 -10
- package/lib/components/tag-video/index.js.map +1 -1
- package/lib/components/tag-video/style/css.js.map +1 -1
- package/lib/components/tag-video/style/index.js.map +1 -1
- package/lib/components/tag-video/style/index.less +69 -69
- package/lib/components/video-scale/index.d.ts +1 -1
- package/lib/components/video-scale/index.js +9 -2
- package/lib/components/video-scale/index.js.map +1 -1
- package/lib/components/video-scale/style/css.js.map +1 -1
- package/lib/components/video-scale/style/index.js.map +1 -1
- package/lib/context/index.js +4 -0
- package/lib/context/index.js.map +1 -1
- package/lib/controls/index.d.ts +11 -11
- package/lib/controls/index.js +99 -34
- package/lib/controls/index.js.map +1 -1
- package/lib/controls/style/css.js +5 -0
- package/lib/controls/style/css.js.map +1 -1
- package/lib/controls/style/index.js +5 -0
- package/lib/controls/style/index.js.map +1 -1
- package/lib/controls/style/index.less +188 -188
- package/lib/h264/PlayerManager.js +27 -18
- package/lib/h264/PlayerManager.js.map +1 -1
- package/lib/history-control/index.d.ts +2 -2
- package/lib/history-control/index.js +121 -61
- package/lib/history-control/index.js.map +1 -1
- package/lib/history-control/style/css.js +6 -0
- package/lib/history-control/style/css.js.map +1 -1
- package/lib/history-control/style/index.js +6 -0
- package/lib/history-control/style/index.js.map +1 -1
- package/lib/history-control/style/index.less +252 -252
- package/lib/history-control-v2/components/grid-item/index.js +79 -38
- package/lib/history-control-v2/components/grid-item/index.js.map +1 -1
- package/lib/history-control-v2/components/panel/index.js +114 -44
- package/lib/history-control-v2/components/panel/index.js.map +1 -1
- package/lib/history-control-v2/context.js +2 -0
- package/lib/history-control-v2/context.js.map +1 -1
- package/lib/history-control-v2/index.d.ts +4 -4
- package/lib/history-control-v2/index.js +166 -97
- package/lib/history-control-v2/index.js.map +1 -1
- package/lib/history-control-v2/style/css.js +10 -0
- package/lib/history-control-v2/style/css.js.map +1 -1
- package/lib/history-control-v2/style/index.js +10 -0
- package/lib/history-control-v2/style/index.js.map +1 -1
- package/lib/history-control-v2/style/index.less +437 -437
- package/lib/history-control-v2/utils.js +21 -1
- package/lib/history-control-v2/utils.js.map +1 -1
- package/lib/history-player/index.d.ts +3 -3
- package/lib/history-player/index.js +210 -146
- package/lib/history-player/index.js.map +1 -1
- package/lib/history-player/style/css.js +3 -0
- package/lib/history-player/style/css.js.map +1 -1
- package/lib/history-player/style/index.js +3 -0
- package/lib/history-player/style/index.js.map +1 -1
- package/lib/history-player/style/index.less +102 -102
- package/lib/hooks/useSettings.js +6 -1
- package/lib/hooks/useSettings.js.map +1 -1
- package/lib/icc/PlayerManager.js +57 -26
- package/lib/icc/PlayerManager.js.map +1 -1
- package/lib/icc/api.d.ts +68 -0
- package/lib/icc/api.js +16 -2
- package/lib/icc/api.js.map +1 -1
- package/lib/icons/index.d.ts +36 -36
- package/lib/icons/index.js +171 -23
- package/lib/icons/index.js.map +1 -1
- package/lib/icons/index.less +32 -32
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -1
- package/lib/live-channel-player/index.d.ts +1 -1
- package/lib/live-channel-player/index.js +67 -31
- package/lib/live-channel-player/index.js.map +1 -1
- package/lib/live-channel-player/style/css.js +1 -0
- package/lib/live-channel-player/style/css.js.map +1 -1
- package/lib/live-channel-player/style/index.js +1 -0
- package/lib/live-channel-player/style/index.js.map +1 -1
- package/lib/live-control/index.d.ts +2 -2
- package/lib/live-control/index.js +86 -35
- package/lib/live-control/index.js.map +1 -1
- package/lib/live-control/style/css.js +4 -0
- package/lib/live-control/style/css.js.map +1 -1
- package/lib/live-control/style/index.js +4 -0
- package/lib/live-control/style/index.js.map +1 -1
- package/lib/live-control/style/index.less +99 -99
- package/lib/live-control-v2/index.d.ts +3 -3
- package/lib/live-control-v2/index.js +153 -65
- package/lib/live-control-v2/index.js.map +1 -1
- package/lib/live-control-v2/style/css.js +7 -0
- package/lib/live-control-v2/style/css.js.map +1 -1
- package/lib/live-control-v2/style/index.js +7 -0
- package/lib/live-control-v2/style/index.js.map +1 -1
- package/lib/live-control-v2/style/index.less +192 -192
- package/lib/live-player/index.js +136 -95
- package/lib/live-player/index.js.map +1 -1
- package/lib/live-player/style/css.js +2 -0
- package/lib/live-player/style/css.js.map +1 -1
- package/lib/live-player/style/index.js +2 -0
- package/lib/live-player/style/index.js.map +1 -1
- package/lib/live-player/style/index.less +75 -75
- package/lib/player/index.d.ts +1 -1
- package/lib/player/index.js +243 -78
- package/lib/player/index.js.map +1 -1
- package/lib/rsl/PlayerManager.js +64 -18
- package/lib/rsl/PlayerManager.js.map +1 -1
- package/lib/typings/@vtx/utils/index.d.ts +28 -28
- package/lib/typings/h5player.d.ts +146 -146
- package/lib/typings/webrtcplayer.d.ts +56 -56
- package/lib/typings/wsplayer.d.ts +99 -99
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +91 -12
- package/lib/utils/index.js.map +1 -1
- package/lib/vite-env.d.ts +1 -1
- package/lib/vtxHls/PlayerManager.js +20 -6
- package/lib/vtxHls/PlayerManager.js.map +1 -1
- package/lib/vtxHls/WhepManager.js +72 -9
- package/lib/vtxHls/WhepManager.js.map +1 -1
- package/lib/webrtc/PlayerManager.js +41 -28
- package/lib/webrtc/PlayerManager.js.map +1 -1
- package/package.json +124 -124
|
@@ -4,29 +4,53 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
+
|
|
7
8
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
|
|
8
10
|
var _react = require("react");
|
|
11
|
+
|
|
9
12
|
var _api = require("../api");
|
|
13
|
+
|
|
10
14
|
var _splitScreen = _interopRequireDefault(require("../components/split-screen"));
|
|
15
|
+
|
|
11
16
|
var _videoScale = _interopRequireDefault(require("../components/video-scale"));
|
|
17
|
+
|
|
12
18
|
var _controls = require("../controls");
|
|
19
|
+
|
|
13
20
|
var _icons = require("../icons");
|
|
21
|
+
|
|
14
22
|
var _livePlayer = _interopRequireDefault(require("../live-player"));
|
|
23
|
+
|
|
15
24
|
var _utils = require("../utils");
|
|
25
|
+
|
|
16
26
|
var _icons2 = require("@ant-design/icons");
|
|
27
|
+
|
|
17
28
|
var _ahooks = require("ahooks");
|
|
29
|
+
|
|
18
30
|
var _space = _interopRequireDefault(require("antd/lib/space"));
|
|
31
|
+
|
|
19
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
33
|
+
|
|
20
34
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
35
|
+
|
|
21
36
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
37
|
+
|
|
22
38
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
39
|
+
|
|
23
40
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
41
|
+
|
|
24
42
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
43
|
+
|
|
25
44
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
45
|
+
|
|
26
46
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
27
|
-
|
|
28
|
-
function
|
|
47
|
+
|
|
48
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
49
|
+
|
|
50
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
51
|
+
|
|
29
52
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
53
|
+
|
|
30
54
|
var DEFAULT_GRID = 4;
|
|
31
55
|
var DEFAULT_ACTIVE = 0;
|
|
32
56
|
var DEFAULT_CHANNELS = Array(25).fill({
|
|
@@ -36,42 +60,46 @@ var DEFAULT_CHANNELS = Array(25).fill({
|
|
|
36
60
|
/**
|
|
37
61
|
* 实时分屏组件
|
|
38
62
|
*/
|
|
63
|
+
|
|
39
64
|
var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
40
65
|
var _props$height = props.height,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
66
|
+
height = _props$height === void 0 ? '100%' : _props$height,
|
|
67
|
+
_props$width = props.width,
|
|
68
|
+
width = _props$width === void 0 ? '100%' : _props$width,
|
|
69
|
+
onExpandChange = props.onExpandChange,
|
|
70
|
+
onPlayingChannelChange = props.onPlayingChannelChange,
|
|
71
|
+
onVideoClose = props.onVideoClose,
|
|
72
|
+
onVideoCloseAll = props.onVideoCloseAll,
|
|
73
|
+
onCloseVideoInRotation = props.onCloseVideoInRotation,
|
|
74
|
+
extraDom = props.extraDom,
|
|
75
|
+
_props$gridChange = props.gridChange,
|
|
76
|
+
gridChange = _props$gridChange === void 0 ? true : _props$gridChange,
|
|
77
|
+
onScreenshot = props.onScreenshot,
|
|
78
|
+
scale = props.scale,
|
|
79
|
+
defaultGrid = props.defaultGrid;
|
|
80
|
+
|
|
55
81
|
var _useSetState = (0, _ahooks.useSetState)({
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
82
|
+
expand: true,
|
|
83
|
+
grid: defaultGrid || DEFAULT_GRID,
|
|
84
|
+
activeIndex: DEFAULT_ACTIVE,
|
|
85
|
+
channels: DEFAULT_CHANNELS,
|
|
86
|
+
scale: scale || '100%'
|
|
87
|
+
}),
|
|
88
|
+
_useSetState2 = _slicedToArray(_useSetState, 2),
|
|
89
|
+
state = _useSetState2[0],
|
|
90
|
+
setState = _useSetState2[1];
|
|
91
|
+
|
|
65
92
|
var dragRef = (0, _react.useRef)(null);
|
|
66
93
|
var playRefs = (0, _react.useRef)({});
|
|
67
94
|
var wrapRef = (0, _react.useRef)(null);
|
|
68
95
|
var latestGrid = (0, _react.useRef)(defaultGrid || DEFAULT_GRID);
|
|
96
|
+
|
|
69
97
|
var _useFullscreen = (0, _ahooks.useFullscreen)(wrapRef),
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// 实时视频轮询
|
|
98
|
+
_useFullscreen2 = _slicedToArray(_useFullscreen, 2),
|
|
99
|
+
isFullscreen = _useFullscreen2[0],
|
|
100
|
+
toggleFullscreen = _useFullscreen2[1].toggleFullscreen;
|
|
101
|
+
|
|
102
|
+
var channelRef = (0, _react.useRef)(DEFAULT_CHANNELS); // 实时视频轮询
|
|
75
103
|
// useInterval(() => {
|
|
76
104
|
// // 是否有视频正在播放
|
|
77
105
|
// const hasVideo = channelRef.current.some((item) => item.channelNum);
|
|
@@ -85,6 +113,7 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
85
113
|
// }, 0);
|
|
86
114
|
// }
|
|
87
115
|
// }, polling);
|
|
116
|
+
|
|
88
117
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
89
118
|
return {
|
|
90
119
|
setGrid: function setGrid(grid) {
|
|
@@ -94,6 +123,7 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
94
123
|
var index = channelRef.current.findIndex(function (c) {
|
|
95
124
|
return c.channelId && channel.channelId && c.channelId === channel.channelId;
|
|
96
125
|
});
|
|
126
|
+
|
|
97
127
|
if (~index) {
|
|
98
128
|
setState({
|
|
99
129
|
activeIndex: index
|
|
@@ -101,6 +131,7 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
101
131
|
} else {
|
|
102
132
|
// 播放该通道
|
|
103
133
|
var newChannels = _toConsumableArray(channelRef.current);
|
|
134
|
+
|
|
104
135
|
newChannels[state.activeIndex] = channel;
|
|
105
136
|
var activeIndex = getActiveIndex(newChannels, latestGrid.current, state.activeIndex);
|
|
106
137
|
channelRef.current = newChannels;
|
|
@@ -115,10 +146,11 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
115
146
|
var adapt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
116
147
|
var grid = latestGrid.current;
|
|
117
148
|
var newChannels = [],
|
|
118
|
-
|
|
119
|
-
|
|
149
|
+
activeIndex = state.activeIndex; // 每次清空已经在播放的视频
|
|
150
|
+
|
|
120
151
|
if (init) {
|
|
121
152
|
adapt && (grid = getGrid(channels.length));
|
|
153
|
+
|
|
122
154
|
for (var i = 0; i < Number(grid); i++) {
|
|
123
155
|
newChannels.push(channels[i] ? channels[i] : {
|
|
124
156
|
channelNum: '',
|
|
@@ -133,26 +165,30 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
133
165
|
adapt && (grid = getGrid(channelLength));
|
|
134
166
|
newChannels = _toConsumableArray(new Array(grid)).map(function (item, index) {
|
|
135
167
|
var _a, _b;
|
|
168
|
+
|
|
136
169
|
if (((_a = channelRef.current[index]) === null || _a === void 0 ? void 0 : _a.channelNum) || ((_b = channelRef.current[index]) === null || _b === void 0 ? void 0 : _b.channelId)) {
|
|
137
170
|
return channelRef.current[index];
|
|
138
171
|
}
|
|
172
|
+
|
|
139
173
|
return {
|
|
140
174
|
channelNum: '',
|
|
141
175
|
channelId: ''
|
|
142
176
|
};
|
|
143
177
|
});
|
|
178
|
+
|
|
144
179
|
var _loop = function _loop(_i2) {
|
|
145
180
|
var isRepeat = newChannels.find(function (item) {
|
|
146
181
|
var _a, _b;
|
|
182
|
+
|
|
147
183
|
return (item === null || item === void 0 ? void 0 : item.channelNum) === ((_a = channels[_i2]) === null || _a === void 0 ? void 0 : _a.channelNum) || (item === null || item === void 0 ? void 0 : item.channelId) === ((_b = channels[_i2]) === null || _b === void 0 ? void 0 : _b.channelId);
|
|
148
|
-
});
|
|
149
|
-
|
|
184
|
+
}); // 如果之前在播放,则不需重复打开新窗口
|
|
185
|
+
|
|
150
186
|
if (!isRepeat) {
|
|
151
|
-
var index = getActiveIndex(newChannels, grid, activeIndex);
|
|
152
|
-
// 如果相等,说明没有空闲窗口
|
|
187
|
+
var index = getActiveIndex(newChannels, grid, activeIndex); // 如果相等,说明没有空闲窗口
|
|
153
188
|
// if (index === activeIndex) {
|
|
154
189
|
// break;
|
|
155
190
|
// }
|
|
191
|
+
|
|
156
192
|
if (activeIndex === grid) return "break";
|
|
157
193
|
newChannels[index] = channels[_i2] || {
|
|
158
194
|
channelNum: '',
|
|
@@ -161,11 +197,14 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
161
197
|
activeIndex = index + 1;
|
|
162
198
|
}
|
|
163
199
|
};
|
|
200
|
+
|
|
164
201
|
for (var _i2 = 0; _i2 < channels.length; _i2++) {
|
|
165
202
|
var _ret = _loop(_i2);
|
|
203
|
+
|
|
166
204
|
if (_ret === "break") break;
|
|
167
205
|
}
|
|
168
206
|
}
|
|
207
|
+
|
|
169
208
|
latestGrid.current = grid;
|
|
170
209
|
channelRef.current = newChannels;
|
|
171
210
|
setState({
|
|
@@ -178,9 +217,11 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
178
217
|
var index = channelRef.current.findIndex(function (c) {
|
|
179
218
|
return c.channelId === channelId;
|
|
180
219
|
});
|
|
220
|
+
|
|
181
221
|
if (~index) {
|
|
182
222
|
// 卸载通道
|
|
183
223
|
var newChannels = _toConsumableArray(channelRef.current);
|
|
224
|
+
|
|
184
225
|
newChannels[index] = {
|
|
185
226
|
channelNum: '',
|
|
186
227
|
channelId: ''
|
|
@@ -198,6 +239,7 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
198
239
|
}));
|
|
199
240
|
}
|
|
200
241
|
}, [state.channels]);
|
|
242
|
+
|
|
201
243
|
var handleCloseAll = function handleCloseAll() {
|
|
202
244
|
setState({
|
|
203
245
|
activeIndex: DEFAULT_ACTIVE
|
|
@@ -206,14 +248,17 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
206
248
|
updateChannels(DEFAULT_CHANNELS);
|
|
207
249
|
onVideoCloseAll && onVideoCloseAll();
|
|
208
250
|
};
|
|
251
|
+
|
|
209
252
|
var handleExpand = function handleExpand() {
|
|
210
253
|
onExpandChange && onExpandChange(!state.expand);
|
|
211
254
|
setState({
|
|
212
255
|
expand: !state.expand
|
|
213
256
|
});
|
|
214
257
|
};
|
|
258
|
+
|
|
215
259
|
var updateGrid = function updateGrid(grid) {
|
|
216
260
|
var newChannels = _toConsumableArray(channelRef.current);
|
|
261
|
+
|
|
217
262
|
if (grid > newChannels.length) {
|
|
218
263
|
newChannels = DEFAULT_CHANNELS.slice(0, grid).map(function (item, index) {
|
|
219
264
|
return newChannels[index] ? newChannels[index] : item;
|
|
@@ -221,23 +266,26 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
221
266
|
} else {
|
|
222
267
|
newChannels = newChannels.slice(0, grid);
|
|
223
268
|
}
|
|
269
|
+
|
|
224
270
|
latestGrid.current = grid;
|
|
225
271
|
channelRef.current = newChannels;
|
|
226
272
|
setState({
|
|
227
273
|
grid: grid,
|
|
228
274
|
channels: newChannels
|
|
229
|
-
});
|
|
230
|
-
|
|
275
|
+
}); // 重置视频大小
|
|
276
|
+
|
|
231
277
|
resizeAll();
|
|
232
278
|
};
|
|
279
|
+
|
|
233
280
|
var updateScale = function updateScale(scale) {
|
|
234
281
|
setState({
|
|
235
282
|
scale: scale
|
|
236
|
-
});
|
|
237
|
-
|
|
283
|
+
}); // 重置视频大小
|
|
284
|
+
|
|
238
285
|
resizeAll();
|
|
239
|
-
};
|
|
240
|
-
|
|
286
|
+
}; // 重置所有视频大小
|
|
287
|
+
|
|
288
|
+
|
|
241
289
|
var resizeAll = function resizeAll() {
|
|
242
290
|
var timer = setTimeout(function () {
|
|
243
291
|
Object.values(playRefs.current).forEach(function (player) {
|
|
@@ -246,16 +294,20 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
246
294
|
clearTimeout(timer);
|
|
247
295
|
}, 100);
|
|
248
296
|
};
|
|
297
|
+
|
|
249
298
|
var updateChannels = function updateChannels(channels) {
|
|
250
299
|
channelRef.current = channels;
|
|
251
300
|
setState({
|
|
252
301
|
channels: channels
|
|
253
302
|
});
|
|
254
|
-
};
|
|
255
|
-
|
|
303
|
+
}; // 关闭视频
|
|
304
|
+
|
|
305
|
+
|
|
256
306
|
var closeVideo = function closeVideo(i) {
|
|
257
307
|
var currChannels = _toConsumableArray(channelRef.current);
|
|
308
|
+
|
|
258
309
|
var newChannels = _toConsumableArray(channelRef.current);
|
|
310
|
+
|
|
259
311
|
newChannels[i] = {
|
|
260
312
|
channelNum: '',
|
|
261
313
|
channelId: ''
|
|
@@ -263,8 +315,10 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
263
315
|
updateChannels(newChannels);
|
|
264
316
|
onVideoClose && onVideoClose(currChannels[i], newChannels);
|
|
265
317
|
};
|
|
318
|
+
|
|
266
319
|
var getGridItems = function getGridItems() {
|
|
267
320
|
var items = [];
|
|
321
|
+
|
|
268
322
|
var _loop2 = function _loop2(i) {
|
|
269
323
|
var element = (0, _jsxRuntime.jsx)(GridItem, {
|
|
270
324
|
ref: function ref(_ref) {
|
|
@@ -288,6 +342,7 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
288
342
|
});
|
|
289
343
|
return;
|
|
290
344
|
}
|
|
345
|
+
|
|
291
346
|
closeVideo(i);
|
|
292
347
|
},
|
|
293
348
|
scale: state.scale,
|
|
@@ -295,28 +350,37 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
295
350
|
}, i);
|
|
296
351
|
items.push(element);
|
|
297
352
|
};
|
|
353
|
+
|
|
298
354
|
for (var i = 0; i < Number(latestGrid.current); i++) {
|
|
299
355
|
_loop2(i);
|
|
300
356
|
}
|
|
357
|
+
|
|
301
358
|
return items;
|
|
302
359
|
};
|
|
360
|
+
|
|
303
361
|
function _index(el) {
|
|
304
362
|
var index = 0;
|
|
363
|
+
|
|
305
364
|
if (!el || !el.parentNode) {
|
|
306
365
|
return -1;
|
|
307
|
-
}
|
|
308
|
-
|
|
366
|
+
} // previousElementSibling:上一个兄弟元素
|
|
367
|
+
|
|
368
|
+
|
|
309
369
|
while (el && (el = el.previousElementSibling)) {
|
|
310
370
|
index++;
|
|
311
371
|
}
|
|
372
|
+
|
|
312
373
|
return index;
|
|
313
374
|
}
|
|
375
|
+
|
|
314
376
|
function findParent(el, className) {
|
|
315
377
|
if (el.className && typeof el.className == 'string' && el.className.indexOf(className) > -1) {
|
|
316
378
|
return el;
|
|
317
379
|
}
|
|
380
|
+
|
|
318
381
|
return findParent(el.parentNode, className);
|
|
319
382
|
}
|
|
383
|
+
|
|
320
384
|
return (0, _jsxRuntime.jsxs)("div", Object.assign({
|
|
321
385
|
className: "vtx-live-control-v2",
|
|
322
386
|
ref: wrapRef,
|
|
@@ -334,13 +398,18 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
334
398
|
if (!e.target) {
|
|
335
399
|
return;
|
|
336
400
|
}
|
|
401
|
+
|
|
337
402
|
var target = e.target;
|
|
403
|
+
|
|
338
404
|
if (target == null) {
|
|
339
405
|
return;
|
|
340
406
|
}
|
|
407
|
+
|
|
341
408
|
target = findParent(target, 'grid-item-container');
|
|
409
|
+
|
|
342
410
|
var indexDraging = _index(dragRef.current),
|
|
343
|
-
|
|
411
|
+
indexTarget = _index(target);
|
|
412
|
+
|
|
344
413
|
try {
|
|
345
414
|
if (indexDraging < indexTarget) {
|
|
346
415
|
// 目标比元素大,插到其后面
|
|
@@ -429,21 +498,23 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
429
498
|
LiveControlV2.displayName = 'LiveControlV2';
|
|
430
499
|
var GridItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
431
500
|
var active = props.active,
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
501
|
+
onClick = props.onClick,
|
|
502
|
+
channel = props.channel,
|
|
503
|
+
onClose = props.onClose,
|
|
504
|
+
onScreenshot = props.onScreenshot,
|
|
505
|
+
scale = props.scale;
|
|
437
506
|
var empty = !channel.channelNum && !channel.channelId;
|
|
507
|
+
|
|
438
508
|
var _useState = (0, _react.useState)({}),
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
// const { data, loading } = useRequest(() => getPreviewUrl(channel as Required<ChannelType>), {
|
|
509
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
510
|
+
actData = _useState2[0],
|
|
511
|
+
setActData = _useState2[1];
|
|
512
|
+
|
|
513
|
+
var loading = false; // const { data, loading } = useRequest(() => getPreviewUrl(channel as Required<ChannelType>), {
|
|
444
514
|
// ready: !!channel.channelNum || !!channel.channelId,
|
|
445
515
|
// refreshDeps: [channel.channelNum, channel.channelId],
|
|
446
516
|
// });
|
|
517
|
+
|
|
447
518
|
(0, _react.useEffect)(function () {
|
|
448
519
|
if ((channel === null || channel === void 0 ? void 0 : channel.channelNum) || channel.channelId) {
|
|
449
520
|
(0, _api.getPreviewUrl)(channel).then(function (res) {
|
|
@@ -454,15 +525,17 @@ var GridItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
454
525
|
}
|
|
455
526
|
}, [channel === null || channel === void 0 ? void 0 : channel.channelNum, channel === null || channel === void 0 ? void 0 : channel.channelId]);
|
|
456
527
|
var name = "".concat(actData === null || actData === void 0 ? void 0 : actData.deviceName, "-").concat(actData === null || actData === void 0 ? void 0 : actData.channelName);
|
|
528
|
+
|
|
457
529
|
var _useSetState3 = (0, _ahooks.useSetState)({
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
530
|
+
width: '100%',
|
|
531
|
+
height: '100%'
|
|
532
|
+
}),
|
|
533
|
+
_useSetState4 = _slicedToArray(_useSetState3, 2),
|
|
534
|
+
_useSetState4$ = _useSetState4[0],
|
|
535
|
+
width = _useSetState4$.width,
|
|
536
|
+
height = _useSetState4$.height,
|
|
537
|
+
setState = _useSetState4[1];
|
|
538
|
+
|
|
466
539
|
var gridItemRef = (0, _react.useRef)(null);
|
|
467
540
|
var gridItemSize = (0, _ahooks.useSize)(gridItemRef);
|
|
468
541
|
(0, _react.useEffect)(function () {
|
|
@@ -474,6 +547,7 @@ var GridItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
474
547
|
height: gridItemSize.height - 26
|
|
475
548
|
});
|
|
476
549
|
break;
|
|
550
|
+
|
|
477
551
|
case '4*3':
|
|
478
552
|
if (gridItemSize.width / 4 < (gridItemSize.height - 26) / 3) {
|
|
479
553
|
setState({
|
|
@@ -486,7 +560,9 @@ var GridItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
486
560
|
height: '100%'
|
|
487
561
|
});
|
|
488
562
|
}
|
|
563
|
+
|
|
489
564
|
break;
|
|
565
|
+
|
|
490
566
|
case '16*9':
|
|
491
567
|
if (gridItemSize.width / 16 < (gridItemSize.height - 26) / 9) {
|
|
492
568
|
setState({
|
|
@@ -499,10 +575,12 @@ var GridItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
499
575
|
height: '100%'
|
|
500
576
|
});
|
|
501
577
|
}
|
|
578
|
+
|
|
502
579
|
break;
|
|
503
580
|
}
|
|
504
581
|
}
|
|
505
582
|
}, [gridItemSize, scale]);
|
|
583
|
+
|
|
506
584
|
var handlePtzType = function handlePtzType(type) {
|
|
507
585
|
var types = {
|
|
508
586
|
1: 'all',
|
|
@@ -512,6 +590,7 @@ var GridItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
512
590
|
};
|
|
513
591
|
return types[type];
|
|
514
592
|
};
|
|
593
|
+
|
|
515
594
|
return (0, _jsxRuntime.jsx)("div", Object.assign({
|
|
516
595
|
className: "grid-item-container ".concat(active ? 'active' : '', " ").concat(loading ? '' : 'emptyImg'),
|
|
517
596
|
onClick: onClick,
|
|
@@ -575,31 +654,40 @@ GridItem.displayName = 'grid-item';
|
|
|
575
654
|
* @param currentIndex 当前索引
|
|
576
655
|
* @returns
|
|
577
656
|
*/
|
|
657
|
+
|
|
578
658
|
var getActiveIndex = function getActiveIndex(channels, grid, currentIndex) {
|
|
579
659
|
var currentChannels = channels.slice(0, Number(grid));
|
|
660
|
+
|
|
580
661
|
for (var i = currentIndex; i < currentChannels.length; i++) {
|
|
581
662
|
if (!currentChannels[i].channelNum && !currentChannels[i].channelId) return i;
|
|
582
663
|
}
|
|
664
|
+
|
|
583
665
|
for (var _i3 = 0; _i3 < currentIndex; _i3++) {
|
|
584
666
|
if (!currentChannels[_i3].channelNum && !currentChannels[_i3].channelId) return _i3;
|
|
585
667
|
}
|
|
668
|
+
|
|
586
669
|
return currentIndex;
|
|
587
670
|
};
|
|
671
|
+
|
|
588
672
|
var grids = [1, 4, 6, 8, 9, 13, 17, 16, 22, 25];
|
|
589
673
|
/**
|
|
590
674
|
* 获取布局
|
|
591
675
|
* @param len 通道数量
|
|
592
676
|
*/
|
|
677
|
+
|
|
593
678
|
var getGrid = function getGrid(len) {
|
|
594
679
|
var grid;
|
|
680
|
+
|
|
595
681
|
for (var i = 0; i < grids.length; i++) {
|
|
596
682
|
if (grids[i] - len >= 0) {
|
|
597
683
|
grid = grids[i];
|
|
598
684
|
break;
|
|
599
685
|
}
|
|
600
686
|
}
|
|
687
|
+
|
|
601
688
|
return grid > 25 ? 25 : grid;
|
|
602
689
|
};
|
|
690
|
+
|
|
603
691
|
var _default = LiveControlV2;
|
|
604
692
|
exports["default"] = _default;
|
|
605
693
|
//# sourceMappingURL=index.js.map
|