@cloud-app-dev/vidc 3.0.12 → 3.0.13
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/.prettierrc
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ILivePlayerProps } from './interface';
|
|
3
3
|
import './index.less';
|
|
4
|
-
declare function LivePlayer({ list, children, onIndexChange, onClose, onCloseAll, snapshot, defaultScreen, screenChange, defaultSelectIndex
|
|
4
|
+
declare function LivePlayer({ list, children, onIndexChange, onClose, onCloseAll, snapshot, defaultScreen, screenChange, defaultSelectIndex }: ILivePlayerProps): JSX.Element;
|
|
5
|
+
declare namespace LivePlayer {
|
|
6
|
+
var defaultProps: {
|
|
7
|
+
list: any[];
|
|
8
|
+
};
|
|
9
|
+
}
|
|
5
10
|
export default LivePlayer;
|
package/es/ScreenPlayer/Live.js
CHANGED
|
@@ -28,8 +28,7 @@ import useVideoFit from './useVideoFit';
|
|
|
28
28
|
import "./index.css";
|
|
29
29
|
|
|
30
30
|
function LivePlayer(_ref) {
|
|
31
|
-
var
|
|
32
|
-
list = _ref$list === void 0 ? [] : _ref$list,
|
|
31
|
+
var list = _ref.list,
|
|
33
32
|
children = _ref.children,
|
|
34
33
|
onIndexChange = _ref.onIndexChange,
|
|
35
34
|
onClose = _ref.onClose,
|
|
@@ -177,4 +176,7 @@ function LivePlayer(_ref) {
|
|
|
177
176
|
}));
|
|
178
177
|
}
|
|
179
178
|
|
|
179
|
+
LivePlayer.defaultProps = {
|
|
180
|
+
list: []
|
|
181
|
+
};
|
|
180
182
|
export default LivePlayer;
|
|
@@ -17,5 +17,5 @@ interface IToolsProps {
|
|
|
17
17
|
disabled: boolean;
|
|
18
18
|
snapshot?: (base64?: string) => void;
|
|
19
19
|
}
|
|
20
|
-
declare function LiveTools({ containerRef, updateState, screenNum, getPlayerItem, mode, toggleFit, fit, onClose, onCloseAll, disabled, snapshot
|
|
20
|
+
declare function LiveTools({ containerRef, updateState, screenNum, getPlayerItem, mode, toggleFit, fit, onClose, onCloseAll, disabled, snapshot }: IToolsProps): JSX.Element;
|
|
21
21
|
export default LiveTools;
|
|
@@ -16,7 +16,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
16
16
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
17
|
|
|
18
18
|
import moment from 'moment';
|
|
19
|
-
import {
|
|
19
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
20
20
|
var hours = [1, 6, 12, 24];
|
|
21
21
|
var currentColor = '#FF000A';
|
|
22
22
|
var normalLineColor = '#ffffff';
|
|
@@ -133,10 +133,15 @@ function useTimeSlider(canvasRef, _ref2) {
|
|
|
133
133
|
});
|
|
134
134
|
};
|
|
135
135
|
|
|
136
|
-
var clearCanvas =
|
|
136
|
+
var clearCanvas = function clearCanvas() {
|
|
137
137
|
return ctx.clearRect(0, 0, width, height);
|
|
138
|
-
}
|
|
139
|
-
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* 绘制覆盖时间刻度颜色,表示有录像的部分
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
var drawOverlay = function drawOverlay() {
|
|
140
145
|
segments.forEach(function (item) {
|
|
141
146
|
var _a;
|
|
142
147
|
|
|
@@ -147,12 +152,13 @@ function useTimeSlider(canvasRef, _ref2) {
|
|
|
147
152
|
ctx.fillStyle = item.url ? ((_a = item.style) === null || _a === void 0 ? void 0 : _a.background) || hoverLineColor : '#242C3D';
|
|
148
153
|
ctx.fillRect(beginX, height - 10, scale_width + 1, height);
|
|
149
154
|
});
|
|
150
|
-
}
|
|
155
|
+
};
|
|
151
156
|
/**
|
|
152
157
|
* 绘制刻度相关的
|
|
153
158
|
*/
|
|
154
159
|
|
|
155
|
-
|
|
160
|
+
|
|
161
|
+
var drawScale = function drawScale() {
|
|
156
162
|
var px_per_min = width / (state.hoursPer * 60); // px/min
|
|
157
163
|
|
|
158
164
|
var px_per_ms = width / (state.hoursPer * 60 * 60 * 1000); // px/ms
|
|
@@ -226,13 +232,14 @@ function useTimeSlider(canvasRef, _ref2) {
|
|
|
226
232
|
|
|
227
233
|
drawLine(ctx, graduation_left, height - lineH, graduation_left, height, normalLineColor, 2);
|
|
228
234
|
}
|
|
229
|
-
}
|
|
235
|
+
};
|
|
230
236
|
/**
|
|
231
237
|
* 绘制当前刻度
|
|
232
238
|
* @returns
|
|
233
239
|
*/
|
|
234
240
|
|
|
235
|
-
|
|
241
|
+
|
|
242
|
+
var drawCurrentLine = function drawCurrentLine() {
|
|
236
243
|
var currentTime = state.currentTime,
|
|
237
244
|
begin = state.begin,
|
|
238
245
|
hoursPer = state.hoursPer;
|
|
@@ -255,13 +262,13 @@ function useTimeSlider(canvasRef, _ref2) {
|
|
|
255
262
|
text: formartTimestemp(time)
|
|
256
263
|
});
|
|
257
264
|
drawLine(ctx, left, 20, left, height, currentColor, 2); //中间当前点线
|
|
258
|
-
|
|
259
|
-
}, [ctx, height, width, state.currentTime, state.begin, state.hoursPer]);
|
|
265
|
+
};
|
|
260
266
|
/**
|
|
261
267
|
* 绘制提示时间
|
|
262
268
|
*/
|
|
263
269
|
|
|
264
|
-
|
|
270
|
+
|
|
271
|
+
var drawHoverLine = function drawHoverLine() {
|
|
265
272
|
drawText(ctx, {
|
|
266
273
|
fillStyle: hoverLineColor,
|
|
267
274
|
font: '12px Arial',
|
|
@@ -270,12 +277,13 @@ function useTimeSlider(canvasRef, _ref2) {
|
|
|
270
277
|
text: formartTimestemp(state.hover.time)
|
|
271
278
|
});
|
|
272
279
|
drawLine(ctx, state.hover.x, 20, state.hover.x, height, hoverLineColor, 1);
|
|
273
|
-
}
|
|
280
|
+
};
|
|
274
281
|
/**
|
|
275
282
|
* 获取鼠标posx
|
|
276
283
|
* @param {*} e
|
|
277
284
|
*/
|
|
278
285
|
|
|
286
|
+
|
|
279
287
|
var get_cursor_x_position = function get_cursor_x_position(e) {
|
|
280
288
|
var posx = 0;
|
|
281
289
|
|
|
@@ -313,8 +321,9 @@ function useTimeSlider(canvasRef, _ref2) {
|
|
|
313
321
|
drawScale();
|
|
314
322
|
drawCurrentLine();
|
|
315
323
|
state.hover.time && drawHoverLine();
|
|
316
|
-
}
|
|
317
|
-
|
|
324
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
325
|
+
|
|
326
|
+
}, [canvas, state.begin, state.currentTime, state.hoursPer, segments, state.hover]);
|
|
318
327
|
|
|
319
328
|
_useUpdateEffect(function () {
|
|
320
329
|
return update({
|
|
@@ -333,6 +342,10 @@ function useTimeSlider(canvasRef, _ref2) {
|
|
|
333
342
|
currentTime: currentTime
|
|
334
343
|
});
|
|
335
344
|
}, [currentTime]);
|
|
345
|
+
/**
|
|
346
|
+
* 触发绘制范围单位(hour)
|
|
347
|
+
*/
|
|
348
|
+
|
|
336
349
|
|
|
337
350
|
_useEventListener('mousewheel', function (event) {
|
|
338
351
|
event.preventDefault();
|
|
@@ -358,7 +371,7 @@ function useTimeSlider(canvasRef, _ref2) {
|
|
|
358
371
|
}
|
|
359
372
|
}
|
|
360
373
|
|
|
361
|
-
var new_begin = middle_time - state.hoursPer * 3600 * 1000 / 2; //
|
|
374
|
+
var new_begin = middle_time - state.hoursPer * 3600 * 1000 / 2; //new_begin = 当前中间的时间 - hoursPer/2
|
|
362
375
|
|
|
363
376
|
setState(function (old) {
|
|
364
377
|
return Object.assign(Object.assign({}, old), {
|
|
@@ -373,6 +386,10 @@ function useTimeSlider(canvasRef, _ref2) {
|
|
|
373
386
|
}, {
|
|
374
387
|
target: canvasRef
|
|
375
388
|
});
|
|
389
|
+
/**
|
|
390
|
+
* 用于处理canvas移除hover效果
|
|
391
|
+
*/
|
|
392
|
+
|
|
376
393
|
|
|
377
394
|
_useEventListener('mouseout', function () {
|
|
378
395
|
return setState(function (old) {
|
|
@@ -386,6 +403,10 @@ function useTimeSlider(canvasRef, _ref2) {
|
|
|
386
403
|
}, {
|
|
387
404
|
target: canvasRef
|
|
388
405
|
});
|
|
406
|
+
/**
|
|
407
|
+
* hover效果绘制
|
|
408
|
+
*/
|
|
409
|
+
|
|
389
410
|
|
|
390
411
|
_useEventListener('mousemove', function (e) {
|
|
391
412
|
if (extRef.current.mousedownTime) {
|
|
@@ -415,6 +436,10 @@ function useTimeSlider(canvasRef, _ref2) {
|
|
|
415
436
|
}, {
|
|
416
437
|
target: canvasRef
|
|
417
438
|
});
|
|
439
|
+
/**
|
|
440
|
+
* 标记点击、拖动的触发器
|
|
441
|
+
*/
|
|
442
|
+
|
|
418
443
|
|
|
419
444
|
_useEventListener('mousedown', function (e) {
|
|
420
445
|
extRef.current.mousedownTime = Date.now();
|
|
@@ -422,9 +447,14 @@ function useTimeSlider(canvasRef, _ref2) {
|
|
|
422
447
|
}, {
|
|
423
448
|
target: canvasRef
|
|
424
449
|
});
|
|
450
|
+
/**
|
|
451
|
+
* 处理点击、结束拖动的处理
|
|
452
|
+
*/
|
|
453
|
+
|
|
425
454
|
|
|
426
455
|
_useEventListener('mouseup', function (e) {
|
|
427
456
|
if (!extRef.current.mousedownTime) {
|
|
457
|
+
// 未在canvas上触发mousedown 过滤
|
|
428
458
|
return;
|
|
429
459
|
}
|
|
430
460
|
|
|
@@ -461,6 +491,10 @@ function useTimeSlider(canvasRef, _ref2) {
|
|
|
461
491
|
}, {
|
|
462
492
|
target: document
|
|
463
493
|
});
|
|
494
|
+
/**
|
|
495
|
+
* 拖动处理
|
|
496
|
+
*/
|
|
497
|
+
|
|
464
498
|
|
|
465
499
|
_useEventListener('mousemove', function (e) {
|
|
466
500
|
if (!extRef.current.mousedownTime) {
|