@vtx/player 1.7.14 → 1.7.15
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 +141 -108
- 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 +244 -79
- 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 +125 -125
|
@@ -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,45 @@ 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
|
-
|
|
65
|
-
|
|
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
|
+
|
|
66
92
|
var playRefs = (0, _react.useRef)({});
|
|
67
93
|
var wrapRef = (0, _react.useRef)(null);
|
|
68
94
|
var latestGrid = (0, _react.useRef)(defaultGrid || DEFAULT_GRID);
|
|
95
|
+
|
|
69
96
|
var _useFullscreen = (0, _ahooks.useFullscreen)(wrapRef),
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// 实时视频轮询
|
|
97
|
+
_useFullscreen2 = _slicedToArray(_useFullscreen, 2),
|
|
98
|
+
isFullscreen = _useFullscreen2[0],
|
|
99
|
+
toggleFullscreen = _useFullscreen2[1].toggleFullscreen;
|
|
100
|
+
|
|
101
|
+
var channelRef = (0, _react.useRef)(DEFAULT_CHANNELS); // 实时视频轮询
|
|
75
102
|
// useInterval(() => {
|
|
76
103
|
// // 是否有视频正在播放
|
|
77
104
|
// const hasVideo = channelRef.current.some((item) => item.channelNum);
|
|
@@ -85,6 +112,7 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
85
112
|
// }, 0);
|
|
86
113
|
// }
|
|
87
114
|
// }, polling);
|
|
115
|
+
|
|
88
116
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
89
117
|
return {
|
|
90
118
|
setGrid: function setGrid(grid) {
|
|
@@ -94,6 +122,7 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
94
122
|
var index = channelRef.current.findIndex(function (c) {
|
|
95
123
|
return c.channelId && channel.channelId && c.channelId === channel.channelId;
|
|
96
124
|
});
|
|
125
|
+
|
|
97
126
|
if (~index) {
|
|
98
127
|
setState({
|
|
99
128
|
activeIndex: index
|
|
@@ -101,6 +130,7 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
101
130
|
} else {
|
|
102
131
|
// 播放该通道
|
|
103
132
|
var newChannels = _toConsumableArray(channelRef.current);
|
|
133
|
+
|
|
104
134
|
newChannels[state.activeIndex] = channel;
|
|
105
135
|
var activeIndex = getActiveIndex(newChannels, latestGrid.current, state.activeIndex);
|
|
106
136
|
channelRef.current = newChannels;
|
|
@@ -115,10 +145,11 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
115
145
|
var adapt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
116
146
|
var grid = latestGrid.current;
|
|
117
147
|
var newChannels = [],
|
|
118
|
-
|
|
119
|
-
|
|
148
|
+
activeIndex = state.activeIndex; // 每次清空已经在播放的视频
|
|
149
|
+
|
|
120
150
|
if (init) {
|
|
121
151
|
adapt && (grid = getGrid(channels.length));
|
|
152
|
+
|
|
122
153
|
for (var i = 0; i < Number(grid); i++) {
|
|
123
154
|
newChannels.push(channels[i] ? channels[i] : {
|
|
124
155
|
channelNum: '',
|
|
@@ -133,26 +164,30 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
133
164
|
adapt && (grid = getGrid(channelLength));
|
|
134
165
|
newChannels = _toConsumableArray(new Array(grid)).map(function (item, index) {
|
|
135
166
|
var _a, _b;
|
|
167
|
+
|
|
136
168
|
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
169
|
return channelRef.current[index];
|
|
138
170
|
}
|
|
171
|
+
|
|
139
172
|
return {
|
|
140
173
|
channelNum: '',
|
|
141
174
|
channelId: ''
|
|
142
175
|
};
|
|
143
176
|
});
|
|
177
|
+
|
|
144
178
|
var _loop = function _loop(_i2) {
|
|
145
179
|
var isRepeat = newChannels.find(function (item) {
|
|
146
180
|
var _a, _b;
|
|
181
|
+
|
|
147
182
|
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
|
-
|
|
183
|
+
}); // 如果之前在播放,则不需重复打开新窗口
|
|
184
|
+
|
|
150
185
|
if (!isRepeat) {
|
|
151
|
-
var index = getActiveIndex(newChannels, grid, activeIndex);
|
|
152
|
-
// 如果相等,说明没有空闲窗口
|
|
186
|
+
var index = getActiveIndex(newChannels, grid, activeIndex); // 如果相等,说明没有空闲窗口
|
|
153
187
|
// if (index === activeIndex) {
|
|
154
188
|
// break;
|
|
155
189
|
// }
|
|
190
|
+
|
|
156
191
|
if (activeIndex === grid) return "break";
|
|
157
192
|
newChannels[index] = channels[_i2] || {
|
|
158
193
|
channelNum: '',
|
|
@@ -161,11 +196,14 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
161
196
|
activeIndex = index + 1;
|
|
162
197
|
}
|
|
163
198
|
};
|
|
199
|
+
|
|
164
200
|
for (var _i2 = 0; _i2 < channels.length; _i2++) {
|
|
165
201
|
var _ret = _loop(_i2);
|
|
202
|
+
|
|
166
203
|
if (_ret === "break") break;
|
|
167
204
|
}
|
|
168
205
|
}
|
|
206
|
+
|
|
169
207
|
latestGrid.current = grid;
|
|
170
208
|
channelRef.current = newChannels;
|
|
171
209
|
setState({
|
|
@@ -178,9 +216,11 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
178
216
|
var index = channelRef.current.findIndex(function (c) {
|
|
179
217
|
return c.channelId === channelId;
|
|
180
218
|
});
|
|
219
|
+
|
|
181
220
|
if (~index) {
|
|
182
221
|
// 卸载通道
|
|
183
222
|
var newChannels = _toConsumableArray(channelRef.current);
|
|
223
|
+
|
|
184
224
|
newChannels[index] = {
|
|
185
225
|
channelNum: '',
|
|
186
226
|
channelId: ''
|
|
@@ -198,6 +238,7 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
198
238
|
}));
|
|
199
239
|
}
|
|
200
240
|
}, [state.channels]);
|
|
241
|
+
|
|
201
242
|
var handleCloseAll = function handleCloseAll() {
|
|
202
243
|
setState({
|
|
203
244
|
activeIndex: DEFAULT_ACTIVE
|
|
@@ -206,14 +247,17 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
206
247
|
updateChannels(DEFAULT_CHANNELS);
|
|
207
248
|
onVideoCloseAll && onVideoCloseAll();
|
|
208
249
|
};
|
|
250
|
+
|
|
209
251
|
var handleExpand = function handleExpand() {
|
|
210
252
|
onExpandChange && onExpandChange(!state.expand);
|
|
211
253
|
setState({
|
|
212
254
|
expand: !state.expand
|
|
213
255
|
});
|
|
214
256
|
};
|
|
257
|
+
|
|
215
258
|
var updateGrid = function updateGrid(grid) {
|
|
216
259
|
var newChannels = _toConsumableArray(channelRef.current);
|
|
260
|
+
|
|
217
261
|
if (grid > newChannels.length) {
|
|
218
262
|
newChannels = DEFAULT_CHANNELS.slice(0, grid).map(function (item, index) {
|
|
219
263
|
return newChannels[index] ? newChannels[index] : item;
|
|
@@ -221,23 +265,26 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
221
265
|
} else {
|
|
222
266
|
newChannels = newChannels.slice(0, grid);
|
|
223
267
|
}
|
|
268
|
+
|
|
224
269
|
latestGrid.current = grid;
|
|
225
270
|
channelRef.current = newChannels;
|
|
226
271
|
setState({
|
|
227
272
|
grid: grid,
|
|
228
273
|
channels: newChannels
|
|
229
|
-
});
|
|
230
|
-
|
|
274
|
+
}); // 重置视频大小
|
|
275
|
+
|
|
231
276
|
resizeAll();
|
|
232
277
|
};
|
|
278
|
+
|
|
233
279
|
var updateScale = function updateScale(scale) {
|
|
234
280
|
setState({
|
|
235
281
|
scale: scale
|
|
236
|
-
});
|
|
237
|
-
|
|
282
|
+
}); // 重置视频大小
|
|
283
|
+
|
|
238
284
|
resizeAll();
|
|
239
|
-
};
|
|
240
|
-
|
|
285
|
+
}; // 重置所有视频大小
|
|
286
|
+
|
|
287
|
+
|
|
241
288
|
var resizeAll = function resizeAll() {
|
|
242
289
|
var timer = setTimeout(function () {
|
|
243
290
|
Object.values(playRefs.current).forEach(function (player) {
|
|
@@ -246,16 +293,20 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
246
293
|
clearTimeout(timer);
|
|
247
294
|
}, 100);
|
|
248
295
|
};
|
|
296
|
+
|
|
249
297
|
var updateChannels = function updateChannels(channels) {
|
|
250
298
|
channelRef.current = channels;
|
|
251
299
|
setState({
|
|
252
300
|
channels: channels
|
|
253
301
|
});
|
|
254
|
-
};
|
|
255
|
-
|
|
302
|
+
}; // 关闭视频
|
|
303
|
+
|
|
304
|
+
|
|
256
305
|
var closeVideo = function closeVideo(i) {
|
|
257
306
|
var currChannels = _toConsumableArray(channelRef.current);
|
|
307
|
+
|
|
258
308
|
var newChannels = _toConsumableArray(channelRef.current);
|
|
309
|
+
|
|
259
310
|
newChannels[i] = {
|
|
260
311
|
channelNum: '',
|
|
261
312
|
channelId: ''
|
|
@@ -263,8 +314,10 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
263
314
|
updateChannels(newChannels);
|
|
264
315
|
onVideoClose && onVideoClose(currChannels[i], newChannels);
|
|
265
316
|
};
|
|
317
|
+
|
|
266
318
|
var getGridItems = function getGridItems() {
|
|
267
319
|
var items = [];
|
|
320
|
+
|
|
268
321
|
var _loop2 = function _loop2(i) {
|
|
269
322
|
var element = (0, _jsxRuntime.jsx)(GridItem, {
|
|
270
323
|
ref: function ref(_ref) {
|
|
@@ -288,6 +341,7 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
288
341
|
});
|
|
289
342
|
return;
|
|
290
343
|
}
|
|
344
|
+
|
|
291
345
|
closeVideo(i);
|
|
292
346
|
},
|
|
293
347
|
scale: state.scale,
|
|
@@ -295,28 +349,14 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
295
349
|
}, i);
|
|
296
350
|
items.push(element);
|
|
297
351
|
};
|
|
352
|
+
|
|
298
353
|
for (var i = 0; i < Number(latestGrid.current); i++) {
|
|
299
354
|
_loop2(i);
|
|
300
355
|
}
|
|
356
|
+
|
|
301
357
|
return items;
|
|
302
358
|
};
|
|
303
|
-
|
|
304
|
-
var index = 0;
|
|
305
|
-
if (!el || !el.parentNode) {
|
|
306
|
-
return -1;
|
|
307
|
-
}
|
|
308
|
-
// previousElementSibling:上一个兄弟元素
|
|
309
|
-
while (el && (el = el.previousElementSibling)) {
|
|
310
|
-
index++;
|
|
311
|
-
}
|
|
312
|
-
return index;
|
|
313
|
-
}
|
|
314
|
-
function findParent(el, className) {
|
|
315
|
-
if (el.className && typeof el.className == 'string' && el.className.indexOf(className) > -1) {
|
|
316
|
-
return el;
|
|
317
|
-
}
|
|
318
|
-
return findParent(el.parentNode, className);
|
|
319
|
-
}
|
|
359
|
+
|
|
320
360
|
return (0, _jsxRuntime.jsxs)("div", Object.assign({
|
|
321
361
|
className: "vtx-live-control-v2",
|
|
322
362
|
ref: wrapRef,
|
|
@@ -326,32 +366,7 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
326
366
|
}
|
|
327
367
|
}, {
|
|
328
368
|
children: [(0, _jsxRuntime.jsx)("div", Object.assign({
|
|
329
|
-
className: "player-grid-container _".concat(state.grid)
|
|
330
|
-
onDragStart: function onDragStart(e) {
|
|
331
|
-
dragRef.current = e.target;
|
|
332
|
-
},
|
|
333
|
-
onDragOver: function onDragOver(e) {
|
|
334
|
-
if (!e.target) {
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
var target = e.target;
|
|
338
|
-
if (target == null) {
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
target = findParent(target, 'grid-item-container');
|
|
342
|
-
var indexDraging = _index(dragRef.current),
|
|
343
|
-
indexTarget = _index(target);
|
|
344
|
-
try {
|
|
345
|
-
if (indexDraging < indexTarget) {
|
|
346
|
-
// 目标比元素大,插到其后面
|
|
347
|
-
// extSibling下一个兄弟元素
|
|
348
|
-
target.parentNode.insertBefore(dragRef.current, target.nextSibling);
|
|
349
|
-
} else if (indexDraging > indexTarget) {
|
|
350
|
-
// 目标比元素小,插到其前面
|
|
351
|
-
target.parentNode.insertBefore(dragRef.current, target);
|
|
352
|
-
}
|
|
353
|
-
} catch (e) {}
|
|
354
|
-
}
|
|
369
|
+
className: "player-grid-container _".concat(state.grid)
|
|
355
370
|
}, {
|
|
356
371
|
children: getGridItems()
|
|
357
372
|
})), (0, _jsxRuntime.jsxs)("div", Object.assign({
|
|
@@ -429,21 +444,23 @@ var LiveControlV2 = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
429
444
|
LiveControlV2.displayName = 'LiveControlV2';
|
|
430
445
|
var GridItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
431
446
|
var active = props.active,
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
447
|
+
onClick = props.onClick,
|
|
448
|
+
channel = props.channel,
|
|
449
|
+
onClose = props.onClose,
|
|
450
|
+
onScreenshot = props.onScreenshot,
|
|
451
|
+
scale = props.scale;
|
|
437
452
|
var empty = !channel.channelNum && !channel.channelId;
|
|
453
|
+
|
|
438
454
|
var _useState = (0, _react.useState)({}),
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
// const { data, loading } = useRequest(() => getPreviewUrl(channel as Required<ChannelType>), {
|
|
455
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
456
|
+
actData = _useState2[0],
|
|
457
|
+
setActData = _useState2[1];
|
|
458
|
+
|
|
459
|
+
var loading = false; // const { data, loading } = useRequest(() => getPreviewUrl(channel as Required<ChannelType>), {
|
|
444
460
|
// ready: !!channel.channelNum || !!channel.channelId,
|
|
445
461
|
// refreshDeps: [channel.channelNum, channel.channelId],
|
|
446
462
|
// });
|
|
463
|
+
|
|
447
464
|
(0, _react.useEffect)(function () {
|
|
448
465
|
if ((channel === null || channel === void 0 ? void 0 : channel.channelNum) || channel.channelId) {
|
|
449
466
|
(0, _api.getPreviewUrl)(channel).then(function (res) {
|
|
@@ -454,15 +471,17 @@ var GridItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
454
471
|
}
|
|
455
472
|
}, [channel === null || channel === void 0 ? void 0 : channel.channelNum, channel === null || channel === void 0 ? void 0 : channel.channelId]);
|
|
456
473
|
var name = "".concat(actData === null || actData === void 0 ? void 0 : actData.deviceName, "-").concat(actData === null || actData === void 0 ? void 0 : actData.channelName);
|
|
474
|
+
|
|
457
475
|
var _useSetState3 = (0, _ahooks.useSetState)({
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
476
|
+
width: '100%',
|
|
477
|
+
height: '100%'
|
|
478
|
+
}),
|
|
479
|
+
_useSetState4 = _slicedToArray(_useSetState3, 2),
|
|
480
|
+
_useSetState4$ = _useSetState4[0],
|
|
481
|
+
width = _useSetState4$.width,
|
|
482
|
+
height = _useSetState4$.height,
|
|
483
|
+
setState = _useSetState4[1];
|
|
484
|
+
|
|
466
485
|
var gridItemRef = (0, _react.useRef)(null);
|
|
467
486
|
var gridItemSize = (0, _ahooks.useSize)(gridItemRef);
|
|
468
487
|
(0, _react.useEffect)(function () {
|
|
@@ -474,6 +493,7 @@ var GridItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
474
493
|
height: gridItemSize.height - 26
|
|
475
494
|
});
|
|
476
495
|
break;
|
|
496
|
+
|
|
477
497
|
case '4*3':
|
|
478
498
|
if (gridItemSize.width / 4 < (gridItemSize.height - 26) / 3) {
|
|
479
499
|
setState({
|
|
@@ -486,7 +506,9 @@ var GridItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
486
506
|
height: '100%'
|
|
487
507
|
});
|
|
488
508
|
}
|
|
509
|
+
|
|
489
510
|
break;
|
|
511
|
+
|
|
490
512
|
case '16*9':
|
|
491
513
|
if (gridItemSize.width / 16 < (gridItemSize.height - 26) / 9) {
|
|
492
514
|
setState({
|
|
@@ -499,10 +521,12 @@ var GridItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
499
521
|
height: '100%'
|
|
500
522
|
});
|
|
501
523
|
}
|
|
524
|
+
|
|
502
525
|
break;
|
|
503
526
|
}
|
|
504
527
|
}
|
|
505
528
|
}, [gridItemSize, scale]);
|
|
529
|
+
|
|
506
530
|
var handlePtzType = function handlePtzType(type) {
|
|
507
531
|
var types = {
|
|
508
532
|
1: 'all',
|
|
@@ -512,11 +536,11 @@ var GridItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
512
536
|
};
|
|
513
537
|
return types[type];
|
|
514
538
|
};
|
|
539
|
+
|
|
515
540
|
return (0, _jsxRuntime.jsx)("div", Object.assign({
|
|
516
541
|
className: "grid-item-container ".concat(active ? 'active' : '', " ").concat(loading ? '' : 'emptyImg'),
|
|
517
542
|
onClick: onClick,
|
|
518
|
-
ref: gridItemRef
|
|
519
|
-
draggable: true
|
|
543
|
+
ref: gridItemRef
|
|
520
544
|
}, {
|
|
521
545
|
children: (actData === null || actData === void 0 ? void 0 : actData.url) && (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
522
546
|
children: [!empty && (0, _jsxRuntime.jsx)(_controls.PlayerHeader, {
|
|
@@ -575,31 +599,40 @@ GridItem.displayName = 'grid-item';
|
|
|
575
599
|
* @param currentIndex 当前索引
|
|
576
600
|
* @returns
|
|
577
601
|
*/
|
|
602
|
+
|
|
578
603
|
var getActiveIndex = function getActiveIndex(channels, grid, currentIndex) {
|
|
579
604
|
var currentChannels = channels.slice(0, Number(grid));
|
|
605
|
+
|
|
580
606
|
for (var i = currentIndex; i < currentChannels.length; i++) {
|
|
581
607
|
if (!currentChannels[i].channelNum && !currentChannels[i].channelId) return i;
|
|
582
608
|
}
|
|
609
|
+
|
|
583
610
|
for (var _i3 = 0; _i3 < currentIndex; _i3++) {
|
|
584
611
|
if (!currentChannels[_i3].channelNum && !currentChannels[_i3].channelId) return _i3;
|
|
585
612
|
}
|
|
613
|
+
|
|
586
614
|
return currentIndex;
|
|
587
615
|
};
|
|
616
|
+
|
|
588
617
|
var grids = [1, 4, 6, 8, 9, 13, 17, 16, 22, 25];
|
|
589
618
|
/**
|
|
590
619
|
* 获取布局
|
|
591
620
|
* @param len 通道数量
|
|
592
621
|
*/
|
|
622
|
+
|
|
593
623
|
var getGrid = function getGrid(len) {
|
|
594
624
|
var grid;
|
|
625
|
+
|
|
595
626
|
for (var i = 0; i < grids.length; i++) {
|
|
596
627
|
if (grids[i] - len >= 0) {
|
|
597
628
|
grid = grids[i];
|
|
598
629
|
break;
|
|
599
630
|
}
|
|
600
631
|
}
|
|
632
|
+
|
|
601
633
|
return grid > 25 ? 25 : grid;
|
|
602
634
|
};
|
|
635
|
+
|
|
603
636
|
var _default = LiveControlV2;
|
|
604
637
|
exports["default"] = _default;
|
|
605
638
|
//# sourceMappingURL=index.js.map
|