wargerm 0.4.21 → 0.4.24
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/Video/example/VideoDemo/demo1.d.ts +3 -0
- package/dist/components/Video/example/VideoDemo/demo2.d.ts +3 -0
- package/dist/components/Video/example/VideoDemo/demo3.d.ts +3 -0
- package/dist/components/Video/example/VideoDemo/demo4.d.ts +3 -0
- package/dist/components/Video/example/VideoDemo/demo5.d.ts +3 -0
- package/dist/components/Video/example/VideoDemo/demo6.d.ts +3 -0
- package/dist/components/Video/example/VideoDemo/demo7.d.ts +3 -0
- package/dist/components/Video/example/VideoDemo/demo8.d.ts +3 -0
- package/dist/components/Video/example/VideoDemo/demo9.d.ts +3 -0
- package/dist/components/Video/index.d.ts +35 -0
- package/dist/index.css +33 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.css +33 -4
- package/dist/index.esm.js +239 -7
- package/dist/index.js +238 -5
- package/package.json +2 -2
@@ -0,0 +1,35 @@
|
|
1
|
+
import { CSSProperties } from 'react';
|
2
|
+
import { IPlayerOptions } from 'xgplayer';
|
3
|
+
/** 清晰度视频项目,name 为清晰度,url 为视频源 */
|
4
|
+
export interface DefinitionItemProps {
|
5
|
+
name: string;
|
6
|
+
url: string;
|
7
|
+
}
|
8
|
+
/** 视频属性配置,继承 xgplayer 配置属性 */
|
9
|
+
interface VideoProps extends Omit<IPlayerOptions, 'url' | 'loop'> {
|
10
|
+
/** 唯一id值 */
|
11
|
+
id: string;
|
12
|
+
/** 视频路径数组 */
|
13
|
+
videoUrls: string[];
|
14
|
+
/** 清晰度视频数组,顺序应与 videoUrls 保持一致 */
|
15
|
+
definitionList?: DefinitionItemProps[][];
|
16
|
+
/** 是否循环播放 */
|
17
|
+
isLoop?: boolean;
|
18
|
+
/** 是否可见 */
|
19
|
+
visible?: boolean;
|
20
|
+
/** 是否静音播放 */
|
21
|
+
muted?: boolean;
|
22
|
+
/** 初始化显示首帧 */
|
23
|
+
videoInit?: boolean;
|
24
|
+
/** 是否允许记忆播放 */
|
25
|
+
enableMemory?: boolean;
|
26
|
+
/** 记忆提示文字展示时长(s) */
|
27
|
+
lastPlayTimeHideDelay?: number;
|
28
|
+
/** 手动控制当前播放集数 */
|
29
|
+
currentIndex?: number;
|
30
|
+
setCurrentIndex?: (currentIndex: number) => void;
|
31
|
+
style?: CSSProperties;
|
32
|
+
className?: string;
|
33
|
+
}
|
34
|
+
declare const _default: ({ id, videoUrls, definitionList, isLoop, muted, currentIndex: parentIndex, setCurrentIndex: setParentIndex, className, style, visible, autoplay, videoInit, enableMemory, lastPlayTimeHideDelay, ...props }: VideoProps) => JSX.Element;
|
35
|
+
export default _default;
|
package/dist/index.css
CHANGED
@@ -411,18 +411,47 @@
|
|
411
411
|
}
|
412
412
|
[data-prefers-color='dark'] .ant-radio-group-solid .ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled) {
|
413
413
|
background: rgba(156, 208, 239, 0.2) !important;
|
414
|
-
border: 1px solid #9cd0ef !important;
|
415
414
|
font-size: 14px;
|
416
415
|
font-family: Microsoft YaHei Regular, Microsoft YaHei Regular-Regular;
|
417
416
|
font-weight: 400;
|
418
|
-
|
417
|
+
}
|
418
|
+
[data-prefers-color='dark'] .ant-radio-wrapper {
|
419
|
+
color: #bbdff0;
|
420
|
+
}
|
421
|
+
[data-prefers-color='dark'] .ant-radio-disabled + span {
|
422
|
+
color: rgba(255, 255, 255, 0.25);
|
423
|
+
}
|
424
|
+
[data-prefers-color='dark'] .ant-radio-button-wrapper:focus-within {
|
425
|
+
box-shadow: none;
|
426
|
+
}
|
427
|
+
[data-prefers-color='dark'] .ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):focus-within {
|
428
|
+
box-shadow: none;
|
429
|
+
}
|
430
|
+
[data-prefers-color='dark'] .ant-radio-group-solid .ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):focus-within {
|
431
|
+
box-shadow: none;
|
419
432
|
}
|
420
433
|
[data-prefers-color='dark'] .ant-radio-button-wrapper {
|
421
|
-
background:
|
434
|
+
background: rgba(81, 190, 246, 0.28) !important;
|
435
|
+
border: 1px solid #4383a4;
|
422
436
|
font-size: 14px;
|
423
437
|
font-family: Microsoft YaHei Regular, Microsoft YaHei Regular-Regular;
|
424
438
|
font-weight: 400;
|
425
|
-
color: #
|
439
|
+
color: #bbdff0;
|
440
|
+
}
|
441
|
+
[data-prefers-color='dark'] .ant-radio-button-wrapper:first-child {
|
442
|
+
border-left: 1px solid #4383a4;
|
443
|
+
}
|
444
|
+
[data-prefers-color='dark'] .ant-radio-button-wrapper-disabled {
|
445
|
+
color: rgba(255, 255, 255, 0.25);
|
446
|
+
}
|
447
|
+
[data-prefers-color='dark'] .ant-radio-button-wrapper:not(:first-child)::before {
|
448
|
+
background-color: #4383a4;
|
449
|
+
}
|
450
|
+
[data-prefers-color='dark'] .ant-radio-button-wrapper-checked {
|
451
|
+
color: rgba(21, 27, 37, 0.9) !important;
|
452
|
+
}
|
453
|
+
[data-prefers-color='dark'] .ant-radio-button-wrapper-checked .ant-radio-button-checked {
|
454
|
+
background: #51bef6 !important;
|
426
455
|
}
|
427
456
|
[data-prefers-color='dark'] .ant-picker-input input::-webkit-input-placeholder {
|
428
457
|
color: #4383a4;
|
package/dist/index.d.ts
CHANGED
@@ -27,3 +27,4 @@ export { default as TabelCard } from './components/TabelCard';
|
|
27
27
|
export { default as Cascader } from './components/Cascader';
|
28
28
|
export { default as WebsocketHeart } from './components/WebsocketHeart';
|
29
29
|
export { default as VideoPlayer } from './components/VideoPlayer';
|
30
|
+
export { default as Video } from './components/Video';
|
package/dist/index.esm.css
CHANGED
@@ -411,18 +411,47 @@
|
|
411
411
|
}
|
412
412
|
[data-prefers-color='dark'] .ant-radio-group-solid .ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled) {
|
413
413
|
background: rgba(156, 208, 239, 0.2) !important;
|
414
|
-
border: 1px solid #9cd0ef !important;
|
415
414
|
font-size: 14px;
|
416
415
|
font-family: Microsoft YaHei Regular, Microsoft YaHei Regular-Regular;
|
417
416
|
font-weight: 400;
|
418
|
-
|
417
|
+
}
|
418
|
+
[data-prefers-color='dark'] .ant-radio-wrapper {
|
419
|
+
color: #bbdff0;
|
420
|
+
}
|
421
|
+
[data-prefers-color='dark'] .ant-radio-disabled + span {
|
422
|
+
color: rgba(255, 255, 255, 0.25);
|
423
|
+
}
|
424
|
+
[data-prefers-color='dark'] .ant-radio-button-wrapper:focus-within {
|
425
|
+
box-shadow: none;
|
426
|
+
}
|
427
|
+
[data-prefers-color='dark'] .ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):focus-within {
|
428
|
+
box-shadow: none;
|
429
|
+
}
|
430
|
+
[data-prefers-color='dark'] .ant-radio-group-solid .ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):focus-within {
|
431
|
+
box-shadow: none;
|
419
432
|
}
|
420
433
|
[data-prefers-color='dark'] .ant-radio-button-wrapper {
|
421
|
-
background:
|
434
|
+
background: rgba(81, 190, 246, 0.28) !important;
|
435
|
+
border: 1px solid #4383a4;
|
422
436
|
font-size: 14px;
|
423
437
|
font-family: Microsoft YaHei Regular, Microsoft YaHei Regular-Regular;
|
424
438
|
font-weight: 400;
|
425
|
-
color: #
|
439
|
+
color: #bbdff0;
|
440
|
+
}
|
441
|
+
[data-prefers-color='dark'] .ant-radio-button-wrapper:first-child {
|
442
|
+
border-left: 1px solid #4383a4;
|
443
|
+
}
|
444
|
+
[data-prefers-color='dark'] .ant-radio-button-wrapper-disabled {
|
445
|
+
color: rgba(255, 255, 255, 0.25);
|
446
|
+
}
|
447
|
+
[data-prefers-color='dark'] .ant-radio-button-wrapper:not(:first-child)::before {
|
448
|
+
background-color: #4383a4;
|
449
|
+
}
|
450
|
+
[data-prefers-color='dark'] .ant-radio-button-wrapper-checked {
|
451
|
+
color: rgba(21, 27, 37, 0.9) !important;
|
452
|
+
}
|
453
|
+
[data-prefers-color='dark'] .ant-radio-button-wrapper-checked .ant-radio-button-checked {
|
454
|
+
background: #51bef6 !important;
|
426
455
|
}
|
427
456
|
[data-prefers-color='dark'] .ant-picker-input input::-webkit-input-placeholder {
|
428
457
|
color: #4383a4;
|
package/dist/index.esm.js
CHANGED
@@ -4,7 +4,7 @@ import 'antd/es/dropdown/style';
|
|
4
4
|
import _Dropdown from 'antd/es/dropdown';
|
5
5
|
import 'antd/es/menu/style';
|
6
6
|
import _Menu from 'antd/es/menu';
|
7
|
-
import React, { memo, useState, useEffect, useMemo, useImperativeHandle, useRef, forwardRef, createRef } from 'react';
|
7
|
+
import React, { memo, useState, useEffect, useMemo, useImperativeHandle, useRef, forwardRef, createRef, useCallback } from 'react';
|
8
8
|
import { createFromIconfontCN, SearchOutlined, ReloadOutlined, CloseCircleOutlined, PlusOutlined, EllipsisOutlined, ExclamationCircleOutlined, EyeOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons';
|
9
9
|
import 'antd/es/input/style';
|
10
10
|
import _Input from 'antd/es/input';
|
@@ -51,6 +51,7 @@ import ProTable from '@ant-design/pro-table';
|
|
51
51
|
import Player from 'xgplayer';
|
52
52
|
import FlvPlayer from 'xgplayer-flv.js';
|
53
53
|
import HlsJsPlayer from 'xgplayer-hls.js';
|
54
|
+
import { isEmpty } from 'lodash';
|
54
55
|
|
55
56
|
function ownKeys(object, enumerableOnly) {
|
56
57
|
var keys = Object.keys(object);
|
@@ -9608,13 +9609,13 @@ var Index$c = function Index(_ref, ref) {
|
|
9608
9609
|
className: "container-in"
|
9609
9610
|
}, /*#__PURE__*/React.createElement("div", {
|
9610
9611
|
className: "container-in-border"
|
9611
|
-
}, /*#__PURE__*/React.createElement("div", {
|
9612
|
+
}, title ? /*#__PURE__*/React.createElement("div", {
|
9612
9613
|
className: "header"
|
9613
9614
|
}, /*#__PURE__*/React.createElement("div", {
|
9614
9615
|
className: "title"
|
9615
9616
|
}, /*#__PURE__*/React.createElement("span", {
|
9616
9617
|
className: "dot"
|
9617
|
-
}), title), headerCenter, headerTail), /*#__PURE__*/React.createElement("div", {
|
9618
|
+
}), title), headerCenter, headerTail) : null, /*#__PURE__*/React.createElement("div", {
|
9618
9619
|
className: "body"
|
9619
9620
|
}, sliderTabs ? sliderTabs.components[activeTab] : props.children)), sliderTabs && /*#__PURE__*/React.createElement("div", {
|
9620
9621
|
className: "sliderTabs ".concat(sliderTabs.direction == 'left' ? "left ".concat(sliderTabs.className || '') : "right ".concat(sliderTabs.className || ''))
|
@@ -11172,12 +11173,13 @@ function Xgplay(_ref, fRef) {
|
|
11172
11173
|
}
|
11173
11174
|
|
11174
11175
|
return function () {
|
11175
|
-
var _playerRef$current, _playerRef$
|
11176
|
+
var _playerRef$current, _playerRef$current2;
|
11176
11177
|
|
11177
|
-
(_playerRef$current = playerRef.current) === null || _playerRef$current === void 0 ? void 0 :
|
11178
|
+
(_playerRef$current = playerRef.current) === null || _playerRef$current === void 0 ? void 0 : _playerRef$current.pause();
|
11179
|
+
(_playerRef$current2 = playerRef.current) === null || _playerRef$current2 === void 0 ? void 0 : _playerRef$current2.destroy(true);
|
11178
11180
|
setRef(null);
|
11179
11181
|
};
|
11180
|
-
});
|
11182
|
+
}, []);
|
11181
11183
|
useImperativeHandle(fRef, function () {
|
11182
11184
|
return {
|
11183
11185
|
player: playerRef.current
|
@@ -11382,4 +11384,234 @@ function VideoPlayer(_ref, ref) {
|
|
11382
11384
|
|
11383
11385
|
var index$3 = /*#__PURE__*/forwardRef(VideoPlayer);
|
11384
11386
|
|
11385
|
-
|
11387
|
+
var _excluded$i = ["id", "videoUrls", "definitionList", "isLoop", "muted", "currentIndex", "setCurrentIndex", "className", "style", "visible", "autoplay", "videoInit", "enableMemory", "lastPlayTimeHideDelay"];
|
11388
|
+
|
11389
|
+
var DEFAULT_PLAY_BACK_RATE = [0.5, 0.75, 1, 1.5, 2]; // 默认记忆提示文字展示时长(s)
|
11390
|
+
|
11391
|
+
var DEFAULT_LAST_PLAY_TIME_DELAY = 5; // 默认音量大小
|
11392
|
+
|
11393
|
+
var DEFAULT_VOLUME = 0.6;
|
11394
|
+
var index$4 = (function (_ref) {
|
11395
|
+
var id = _ref.id,
|
11396
|
+
_ref$videoUrls = _ref.videoUrls,
|
11397
|
+
videoUrls = _ref$videoUrls === void 0 ? [] : _ref$videoUrls,
|
11398
|
+
_ref$definitionList = _ref.definitionList,
|
11399
|
+
definitionList = _ref$definitionList === void 0 ? [] : _ref$definitionList,
|
11400
|
+
_ref$isLoop = _ref.isLoop,
|
11401
|
+
isLoop = _ref$isLoop === void 0 ? true : _ref$isLoop,
|
11402
|
+
_ref$muted = _ref.muted,
|
11403
|
+
muted = _ref$muted === void 0 ? false : _ref$muted,
|
11404
|
+
parentIndex = _ref.currentIndex,
|
11405
|
+
setParentIndex = _ref.setCurrentIndex,
|
11406
|
+
className = _ref.className,
|
11407
|
+
style = _ref.style,
|
11408
|
+
_ref$visible = _ref.visible,
|
11409
|
+
visible = _ref$visible === void 0 ? true : _ref$visible,
|
11410
|
+
_ref$autoplay = _ref.autoplay,
|
11411
|
+
autoplay = _ref$autoplay === void 0 ? false : _ref$autoplay,
|
11412
|
+
_ref$videoInit = _ref.videoInit,
|
11413
|
+
videoInit = _ref$videoInit === void 0 ? true : _ref$videoInit,
|
11414
|
+
_ref$enableMemory = _ref.enableMemory,
|
11415
|
+
enableMemory = _ref$enableMemory === void 0 ? false : _ref$enableMemory,
|
11416
|
+
_ref$lastPlayTimeHide = _ref.lastPlayTimeHideDelay,
|
11417
|
+
lastPlayTimeHideDelay = _ref$lastPlayTimeHide === void 0 ? DEFAULT_LAST_PLAY_TIME_DELAY : _ref$lastPlayTimeHide,
|
11418
|
+
props = _objectWithoutProperties(_ref, _excluded$i);
|
11419
|
+
|
11420
|
+
var player = useRef();
|
11421
|
+
var currentPlayerIndex = useRef(0); // 内置的 index 状态管理
|
11422
|
+
|
11423
|
+
var _useState = useState(0),
|
11424
|
+
_useState2 = _slicedToArray(_useState, 2),
|
11425
|
+
videoIndex = _useState2[0],
|
11426
|
+
setVideoIndex = _useState2[1];
|
11427
|
+
|
11428
|
+
var currentIndex = useMemo(function () {
|
11429
|
+
return parentIndex !== null && parentIndex !== void 0 ? parentIndex : videoIndex;
|
11430
|
+
}, [parentIndex, videoIndex]);
|
11431
|
+
var setCurrentIndex = useMemo(function () {
|
11432
|
+
return setParentIndex !== null && setParentIndex !== void 0 ? setParentIndex : setVideoIndex;
|
11433
|
+
}, [setParentIndex, setVideoIndex]);
|
11434
|
+
var config = useRef(_objectSpread2({
|
11435
|
+
url: videoUrls[0],
|
11436
|
+
playbackRate: DEFAULT_PLAY_BACK_RATE,
|
11437
|
+
playNext: {
|
11438
|
+
urlList: videoUrls.slice(1)
|
11439
|
+
},
|
11440
|
+
volume: muted ? 0 : DEFAULT_VOLUME,
|
11441
|
+
autoplay: autoplay,
|
11442
|
+
videoInit: videoInit,
|
11443
|
+
lastPlayTimeHideDelay: lastPlayTimeHideDelay
|
11444
|
+
}, props));
|
11445
|
+
/** 设置当前播放 index */
|
11446
|
+
|
11447
|
+
var handleSetCurrentIndex = useCallback(function (currentIdx) {
|
11448
|
+
var newIdx = currentIdx !== null && currentIdx !== void 0 ? currentIdx : currentPlayerIndex.current + 1;
|
11449
|
+
|
11450
|
+
if (newIdx >= videoUrls.length) {
|
11451
|
+
if (isLoop) {
|
11452
|
+
// 允许循环则播放起始视频
|
11453
|
+
newIdx = 0;
|
11454
|
+
} else if (player.current && player.current.video) {
|
11455
|
+
// 不允许循环则进度条快进到最后
|
11456
|
+
player.current.currentTime = player.current.video.duration;
|
11457
|
+
return;
|
11458
|
+
}
|
11459
|
+
}
|
11460
|
+
|
11461
|
+
setCurrentIndex(newIdx);
|
11462
|
+
}, [isLoop, setCurrentIndex, videoUrls.length]);
|
11463
|
+
/** 播放下一个 */
|
11464
|
+
|
11465
|
+
var handlePlayNext = useCallback(function (currentIdx) {
|
11466
|
+
if (!player.current) {
|
11467
|
+
return;
|
11468
|
+
}
|
11469
|
+
|
11470
|
+
player.current.src = videoUrls[currentIdx];
|
11471
|
+
player.current.emit('playerNext', currentIdx);
|
11472
|
+
player.current.play();
|
11473
|
+
currentPlayerIndex.current = currentIdx;
|
11474
|
+
|
11475
|
+
if (isLoop) {
|
11476
|
+
// 防止 next 按钮消失
|
11477
|
+
player.current.currentVideoIndex = -videoUrls.length;
|
11478
|
+
}
|
11479
|
+
}, [videoUrls, isLoop]);
|
11480
|
+
/** 重置视频 */
|
11481
|
+
|
11482
|
+
var handleReset = useCallback(function () {
|
11483
|
+
if (!player.current) {
|
11484
|
+
return;
|
11485
|
+
}
|
11486
|
+
|
11487
|
+
setCurrentIndex(0);
|
11488
|
+
currentPlayerIndex.current = -1;
|
11489
|
+
player.current.destroy();
|
11490
|
+
player.current = undefined;
|
11491
|
+
}, [setCurrentIndex]);
|
11492
|
+
/** 弹窗中的视频关闭以后重置 */
|
11493
|
+
|
11494
|
+
useEffect(function () {
|
11495
|
+
if (!visible) {
|
11496
|
+
handleReset();
|
11497
|
+
}
|
11498
|
+
}, [handleReset, visible]);
|
11499
|
+
/** 当 currentIndex 改变以后自动播放下一个 */
|
11500
|
+
|
11501
|
+
useEffect(function () {
|
11502
|
+
if (!player.current || !visible) {
|
11503
|
+
return;
|
11504
|
+
}
|
11505
|
+
|
11506
|
+
handlePlayNext(currentIndex !== null && currentIndex !== void 0 ? currentIndex : currentPlayerIndex.current);
|
11507
|
+
}, [currentIndex, handlePlayNext, visible]);
|
11508
|
+
/** 播放器初始化并绑定事件 */
|
11509
|
+
|
11510
|
+
useEffect(function () {
|
11511
|
+
if (!visible || isEmpty(videoUrls) || player.current) {
|
11512
|
+
return;
|
11513
|
+
}
|
11514
|
+
|
11515
|
+
player.current = new Player(config.current);
|
11516
|
+
player.current.currentVideoIndex = -videoUrls.length;
|
11517
|
+
player.current.on('ended', function () {
|
11518
|
+
// 如果是循环或有其他视频未播放完,继续播放下一个
|
11519
|
+
if (isLoop || !isLoop && currentPlayerIndex.current < videoUrls.length - 1) {
|
11520
|
+
handleSetCurrentIndex();
|
11521
|
+
setTimeout(function () {
|
11522
|
+
var _player$current;
|
11523
|
+
|
11524
|
+
return (_player$current = player.current) === null || _player$current === void 0 ? void 0 : _player$current.play();
|
11525
|
+
});
|
11526
|
+
} else {
|
11527
|
+
var _player$current2;
|
11528
|
+
|
11529
|
+
(_player$current2 = player.current) === null || _player$current2 === void 0 ? void 0 : _player$current2.pause();
|
11530
|
+
}
|
11531
|
+
}); // 播放记忆缓存
|
11532
|
+
|
11533
|
+
if (enableMemory) {
|
11534
|
+
var videoPlayedTimeObj = JSON.parse(localStorage.getItem('videoPlayedTime') || '{}');
|
11535
|
+
player.current.on('timeupdate', function () {
|
11536
|
+
var _player$current3;
|
11537
|
+
|
11538
|
+
if (currentPlayerIndex.current === -1) {
|
11539
|
+
return;
|
11540
|
+
}
|
11541
|
+
|
11542
|
+
localStorage.setItem('videoPlayedTime', JSON.stringify(_objectSpread2(_objectSpread2({}, videoPlayedTimeObj), {}, _defineProperty({}, id, {
|
11543
|
+
lastPlayTime: (_player$current3 = player.current) === null || _player$current3 === void 0 ? void 0 : _player$current3.currentTime,
|
11544
|
+
videoIndex: currentPlayerIndex.current
|
11545
|
+
}))));
|
11546
|
+
});
|
11547
|
+
}
|
11548
|
+
|
11549
|
+
player.current.on('playNextBtnClick', function () {
|
11550
|
+
if (!isLoop && player.current) {
|
11551
|
+
// 防止 next 按钮消失
|
11552
|
+
player.current.currentVideoIndex = videoUrls.length - 2;
|
11553
|
+
}
|
11554
|
+
|
11555
|
+
handleSetCurrentIndex();
|
11556
|
+
});
|
11557
|
+
}, [autoplay, enableMemory, handleSetCurrentIndex, id, isLoop, videoUrls, videoUrls.length, visible]);
|
11558
|
+
/** 读取缓存的播放记忆并跳转 */
|
11559
|
+
|
11560
|
+
useEffect(function () {
|
11561
|
+
if (enableMemory && visible) {
|
11562
|
+
var _JSON$parse;
|
11563
|
+
|
11564
|
+
var _ref2 = ((_JSON$parse = JSON.parse(localStorage.getItem('videoPlayedTime') || '{}')) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse[id]) || {},
|
11565
|
+
lastPlayTime = _ref2.lastPlayTime,
|
11566
|
+
_videoIndex = _ref2.videoIndex;
|
11567
|
+
|
11568
|
+
setTimeout(function () {
|
11569
|
+
handleSetCurrentIndex(_videoIndex);
|
11570
|
+
setTimeout(function () {
|
11571
|
+
if (player.current) {
|
11572
|
+
player.current.currentTime = lastPlayTime;
|
11573
|
+
}
|
11574
|
+
});
|
11575
|
+
});
|
11576
|
+
}
|
11577
|
+
}, [visible, enableMemory, handleSetCurrentIndex, id]);
|
11578
|
+
/** 加载清晰度配置 */
|
11579
|
+
|
11580
|
+
useEffect(function () {
|
11581
|
+
if (!isEmpty(definitionList[currentIndex]) && player.current) {
|
11582
|
+
player.current.emit('resourceReady', definitionList[currentIndex]);
|
11583
|
+
}
|
11584
|
+
}, [currentIndex, definitionList]);
|
11585
|
+
var getRef = useCallback(function (ref) {
|
11586
|
+
if (ref && visible) {
|
11587
|
+
var newConfig = _objectSpread2(_objectSpread2({}, config.current), {}, {
|
11588
|
+
el: ref,
|
11589
|
+
url: videoUrls[0],
|
11590
|
+
playNext: {
|
11591
|
+
urlList: videoUrls.slice(1)
|
11592
|
+
}
|
11593
|
+
});
|
11594
|
+
|
11595
|
+
if (enableMemory) {
|
11596
|
+
var _JSON$parse2;
|
11597
|
+
|
11598
|
+
var _ref3 = ((_JSON$parse2 = JSON.parse(localStorage.getItem('videoPlayedTime') || '{}')) === null || _JSON$parse2 === void 0 ? void 0 : _JSON$parse2[id]) || {},
|
11599
|
+
lastPlayTime = _ref3.lastPlayTime;
|
11600
|
+
|
11601
|
+
Object.assign(newConfig, {
|
11602
|
+
lastPlayTime: lastPlayTime,
|
11603
|
+
lastPlayTimeHideDelay: lastPlayTimeHideDelay
|
11604
|
+
});
|
11605
|
+
}
|
11606
|
+
|
11607
|
+
config.current = newConfig;
|
11608
|
+
}
|
11609
|
+
}, [visible, id, videoUrls, lastPlayTimeHideDelay, enableMemory]);
|
11610
|
+
return /*#__PURE__*/React.createElement("div", {
|
11611
|
+
className: className,
|
11612
|
+
ref: getRef,
|
11613
|
+
style: style
|
11614
|
+
});
|
11615
|
+
});
|
11616
|
+
|
11617
|
+
export { Index$9 as AutoScroll, Index$b as Breadcrumb, WButton as Button, index$1 as Card, WCascader as Cascader, Index$3 as Checkbox, Index$8 as CountUp, Index$1 as DatePicker, index as IconFont, Index as Input, WInputNumber as InputNumber, Modal, ModalForm$1 as ModalForm, Modal$1 as ModalTips, Index$7 as Number, NumericInput, Index$2 as Radio, Select, Index$a as Swiper, WSwitch as Switch, index$2 as TabelCard, Table, Index$6 as TreeSelect, index$4 as Video, index$3 as VideoPlayer, Index$5 as WDatePicker, WForm$1 as WForm, WebsocketHeart };
|
package/dist/index.js
CHANGED
@@ -55,6 +55,7 @@ var ProTable = require('@ant-design/pro-table');
|
|
55
55
|
var Player = require('xgplayer');
|
56
56
|
var FlvPlayer = require('xgplayer-flv.js');
|
57
57
|
var HlsJsPlayer = require('xgplayer-hls.js');
|
58
|
+
var lodash = require('lodash');
|
58
59
|
|
59
60
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
60
61
|
|
@@ -9646,13 +9647,13 @@ var Index$c = function Index(_ref, ref) {
|
|
9646
9647
|
className: "container-in"
|
9647
9648
|
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
9648
9649
|
className: "container-in-border"
|
9649
|
-
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
9650
|
+
}, title ? /*#__PURE__*/React__default['default'].createElement("div", {
|
9650
9651
|
className: "header"
|
9651
9652
|
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
9652
9653
|
className: "title"
|
9653
9654
|
}, /*#__PURE__*/React__default['default'].createElement("span", {
|
9654
9655
|
className: "dot"
|
9655
|
-
}), title), headerCenter, headerTail), /*#__PURE__*/React__default['default'].createElement("div", {
|
9656
|
+
}), title), headerCenter, headerTail) : null, /*#__PURE__*/React__default['default'].createElement("div", {
|
9656
9657
|
className: "body"
|
9657
9658
|
}, sliderTabs ? sliderTabs.components[activeTab] : props.children)), sliderTabs && /*#__PURE__*/React__default['default'].createElement("div", {
|
9658
9659
|
className: "sliderTabs ".concat(sliderTabs.direction == 'left' ? "left ".concat(sliderTabs.className || '') : "right ".concat(sliderTabs.className || ''))
|
@@ -11210,12 +11211,13 @@ function Xgplay(_ref, fRef) {
|
|
11210
11211
|
}
|
11211
11212
|
|
11212
11213
|
return function () {
|
11213
|
-
var _playerRef$current, _playerRef$
|
11214
|
+
var _playerRef$current, _playerRef$current2;
|
11214
11215
|
|
11215
|
-
(_playerRef$current = playerRef.current) === null || _playerRef$current === void 0 ? void 0 :
|
11216
|
+
(_playerRef$current = playerRef.current) === null || _playerRef$current === void 0 ? void 0 : _playerRef$current.pause();
|
11217
|
+
(_playerRef$current2 = playerRef.current) === null || _playerRef$current2 === void 0 ? void 0 : _playerRef$current2.destroy(true);
|
11216
11218
|
setRef(null);
|
11217
11219
|
};
|
11218
|
-
});
|
11220
|
+
}, []);
|
11219
11221
|
React.useImperativeHandle(fRef, function () {
|
11220
11222
|
return {
|
11221
11223
|
player: playerRef.current
|
@@ -11420,6 +11422,236 @@ function VideoPlayer(_ref, ref) {
|
|
11420
11422
|
|
11421
11423
|
var index$3 = /*#__PURE__*/React.forwardRef(VideoPlayer);
|
11422
11424
|
|
11425
|
+
var _excluded$i = ["id", "videoUrls", "definitionList", "isLoop", "muted", "currentIndex", "setCurrentIndex", "className", "style", "visible", "autoplay", "videoInit", "enableMemory", "lastPlayTimeHideDelay"];
|
11426
|
+
|
11427
|
+
var DEFAULT_PLAY_BACK_RATE = [0.5, 0.75, 1, 1.5, 2]; // 默认记忆提示文字展示时长(s)
|
11428
|
+
|
11429
|
+
var DEFAULT_LAST_PLAY_TIME_DELAY = 5; // 默认音量大小
|
11430
|
+
|
11431
|
+
var DEFAULT_VOLUME = 0.6;
|
11432
|
+
var index$4 = (function (_ref) {
|
11433
|
+
var id = _ref.id,
|
11434
|
+
_ref$videoUrls = _ref.videoUrls,
|
11435
|
+
videoUrls = _ref$videoUrls === void 0 ? [] : _ref$videoUrls,
|
11436
|
+
_ref$definitionList = _ref.definitionList,
|
11437
|
+
definitionList = _ref$definitionList === void 0 ? [] : _ref$definitionList,
|
11438
|
+
_ref$isLoop = _ref.isLoop,
|
11439
|
+
isLoop = _ref$isLoop === void 0 ? true : _ref$isLoop,
|
11440
|
+
_ref$muted = _ref.muted,
|
11441
|
+
muted = _ref$muted === void 0 ? false : _ref$muted,
|
11442
|
+
parentIndex = _ref.currentIndex,
|
11443
|
+
setParentIndex = _ref.setCurrentIndex,
|
11444
|
+
className = _ref.className,
|
11445
|
+
style = _ref.style,
|
11446
|
+
_ref$visible = _ref.visible,
|
11447
|
+
visible = _ref$visible === void 0 ? true : _ref$visible,
|
11448
|
+
_ref$autoplay = _ref.autoplay,
|
11449
|
+
autoplay = _ref$autoplay === void 0 ? false : _ref$autoplay,
|
11450
|
+
_ref$videoInit = _ref.videoInit,
|
11451
|
+
videoInit = _ref$videoInit === void 0 ? true : _ref$videoInit,
|
11452
|
+
_ref$enableMemory = _ref.enableMemory,
|
11453
|
+
enableMemory = _ref$enableMemory === void 0 ? false : _ref$enableMemory,
|
11454
|
+
_ref$lastPlayTimeHide = _ref.lastPlayTimeHideDelay,
|
11455
|
+
lastPlayTimeHideDelay = _ref$lastPlayTimeHide === void 0 ? DEFAULT_LAST_PLAY_TIME_DELAY : _ref$lastPlayTimeHide,
|
11456
|
+
props = _objectWithoutProperties(_ref, _excluded$i);
|
11457
|
+
|
11458
|
+
var player = React.useRef();
|
11459
|
+
var currentPlayerIndex = React.useRef(0); // 内置的 index 状态管理
|
11460
|
+
|
11461
|
+
var _useState = React.useState(0),
|
11462
|
+
_useState2 = _slicedToArray(_useState, 2),
|
11463
|
+
videoIndex = _useState2[0],
|
11464
|
+
setVideoIndex = _useState2[1];
|
11465
|
+
|
11466
|
+
var currentIndex = React.useMemo(function () {
|
11467
|
+
return parentIndex !== null && parentIndex !== void 0 ? parentIndex : videoIndex;
|
11468
|
+
}, [parentIndex, videoIndex]);
|
11469
|
+
var setCurrentIndex = React.useMemo(function () {
|
11470
|
+
return setParentIndex !== null && setParentIndex !== void 0 ? setParentIndex : setVideoIndex;
|
11471
|
+
}, [setParentIndex, setVideoIndex]);
|
11472
|
+
var config = React.useRef(_objectSpread2({
|
11473
|
+
url: videoUrls[0],
|
11474
|
+
playbackRate: DEFAULT_PLAY_BACK_RATE,
|
11475
|
+
playNext: {
|
11476
|
+
urlList: videoUrls.slice(1)
|
11477
|
+
},
|
11478
|
+
volume: muted ? 0 : DEFAULT_VOLUME,
|
11479
|
+
autoplay: autoplay,
|
11480
|
+
videoInit: videoInit,
|
11481
|
+
lastPlayTimeHideDelay: lastPlayTimeHideDelay
|
11482
|
+
}, props));
|
11483
|
+
/** 设置当前播放 index */
|
11484
|
+
|
11485
|
+
var handleSetCurrentIndex = React.useCallback(function (currentIdx) {
|
11486
|
+
var newIdx = currentIdx !== null && currentIdx !== void 0 ? currentIdx : currentPlayerIndex.current + 1;
|
11487
|
+
|
11488
|
+
if (newIdx >= videoUrls.length) {
|
11489
|
+
if (isLoop) {
|
11490
|
+
// 允许循环则播放起始视频
|
11491
|
+
newIdx = 0;
|
11492
|
+
} else if (player.current && player.current.video) {
|
11493
|
+
// 不允许循环则进度条快进到最后
|
11494
|
+
player.current.currentTime = player.current.video.duration;
|
11495
|
+
return;
|
11496
|
+
}
|
11497
|
+
}
|
11498
|
+
|
11499
|
+
setCurrentIndex(newIdx);
|
11500
|
+
}, [isLoop, setCurrentIndex, videoUrls.length]);
|
11501
|
+
/** 播放下一个 */
|
11502
|
+
|
11503
|
+
var handlePlayNext = React.useCallback(function (currentIdx) {
|
11504
|
+
if (!player.current) {
|
11505
|
+
return;
|
11506
|
+
}
|
11507
|
+
|
11508
|
+
player.current.src = videoUrls[currentIdx];
|
11509
|
+
player.current.emit('playerNext', currentIdx);
|
11510
|
+
player.current.play();
|
11511
|
+
currentPlayerIndex.current = currentIdx;
|
11512
|
+
|
11513
|
+
if (isLoop) {
|
11514
|
+
// 防止 next 按钮消失
|
11515
|
+
player.current.currentVideoIndex = -videoUrls.length;
|
11516
|
+
}
|
11517
|
+
}, [videoUrls, isLoop]);
|
11518
|
+
/** 重置视频 */
|
11519
|
+
|
11520
|
+
var handleReset = React.useCallback(function () {
|
11521
|
+
if (!player.current) {
|
11522
|
+
return;
|
11523
|
+
}
|
11524
|
+
|
11525
|
+
setCurrentIndex(0);
|
11526
|
+
currentPlayerIndex.current = -1;
|
11527
|
+
player.current.destroy();
|
11528
|
+
player.current = undefined;
|
11529
|
+
}, [setCurrentIndex]);
|
11530
|
+
/** 弹窗中的视频关闭以后重置 */
|
11531
|
+
|
11532
|
+
React.useEffect(function () {
|
11533
|
+
if (!visible) {
|
11534
|
+
handleReset();
|
11535
|
+
}
|
11536
|
+
}, [handleReset, visible]);
|
11537
|
+
/** 当 currentIndex 改变以后自动播放下一个 */
|
11538
|
+
|
11539
|
+
React.useEffect(function () {
|
11540
|
+
if (!player.current || !visible) {
|
11541
|
+
return;
|
11542
|
+
}
|
11543
|
+
|
11544
|
+
handlePlayNext(currentIndex !== null && currentIndex !== void 0 ? currentIndex : currentPlayerIndex.current);
|
11545
|
+
}, [currentIndex, handlePlayNext, visible]);
|
11546
|
+
/** 播放器初始化并绑定事件 */
|
11547
|
+
|
11548
|
+
React.useEffect(function () {
|
11549
|
+
if (!visible || lodash.isEmpty(videoUrls) || player.current) {
|
11550
|
+
return;
|
11551
|
+
}
|
11552
|
+
|
11553
|
+
player.current = new Player__default['default'](config.current);
|
11554
|
+
player.current.currentVideoIndex = -videoUrls.length;
|
11555
|
+
player.current.on('ended', function () {
|
11556
|
+
// 如果是循环或有其他视频未播放完,继续播放下一个
|
11557
|
+
if (isLoop || !isLoop && currentPlayerIndex.current < videoUrls.length - 1) {
|
11558
|
+
handleSetCurrentIndex();
|
11559
|
+
setTimeout(function () {
|
11560
|
+
var _player$current;
|
11561
|
+
|
11562
|
+
return (_player$current = player.current) === null || _player$current === void 0 ? void 0 : _player$current.play();
|
11563
|
+
});
|
11564
|
+
} else {
|
11565
|
+
var _player$current2;
|
11566
|
+
|
11567
|
+
(_player$current2 = player.current) === null || _player$current2 === void 0 ? void 0 : _player$current2.pause();
|
11568
|
+
}
|
11569
|
+
}); // 播放记忆缓存
|
11570
|
+
|
11571
|
+
if (enableMemory) {
|
11572
|
+
var videoPlayedTimeObj = JSON.parse(localStorage.getItem('videoPlayedTime') || '{}');
|
11573
|
+
player.current.on('timeupdate', function () {
|
11574
|
+
var _player$current3;
|
11575
|
+
|
11576
|
+
if (currentPlayerIndex.current === -1) {
|
11577
|
+
return;
|
11578
|
+
}
|
11579
|
+
|
11580
|
+
localStorage.setItem('videoPlayedTime', JSON.stringify(_objectSpread2(_objectSpread2({}, videoPlayedTimeObj), {}, _defineProperty({}, id, {
|
11581
|
+
lastPlayTime: (_player$current3 = player.current) === null || _player$current3 === void 0 ? void 0 : _player$current3.currentTime,
|
11582
|
+
videoIndex: currentPlayerIndex.current
|
11583
|
+
}))));
|
11584
|
+
});
|
11585
|
+
}
|
11586
|
+
|
11587
|
+
player.current.on('playNextBtnClick', function () {
|
11588
|
+
if (!isLoop && player.current) {
|
11589
|
+
// 防止 next 按钮消失
|
11590
|
+
player.current.currentVideoIndex = videoUrls.length - 2;
|
11591
|
+
}
|
11592
|
+
|
11593
|
+
handleSetCurrentIndex();
|
11594
|
+
});
|
11595
|
+
}, [autoplay, enableMemory, handleSetCurrentIndex, id, isLoop, videoUrls, videoUrls.length, visible]);
|
11596
|
+
/** 读取缓存的播放记忆并跳转 */
|
11597
|
+
|
11598
|
+
React.useEffect(function () {
|
11599
|
+
if (enableMemory && visible) {
|
11600
|
+
var _JSON$parse;
|
11601
|
+
|
11602
|
+
var _ref2 = ((_JSON$parse = JSON.parse(localStorage.getItem('videoPlayedTime') || '{}')) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse[id]) || {},
|
11603
|
+
lastPlayTime = _ref2.lastPlayTime,
|
11604
|
+
_videoIndex = _ref2.videoIndex;
|
11605
|
+
|
11606
|
+
setTimeout(function () {
|
11607
|
+
handleSetCurrentIndex(_videoIndex);
|
11608
|
+
setTimeout(function () {
|
11609
|
+
if (player.current) {
|
11610
|
+
player.current.currentTime = lastPlayTime;
|
11611
|
+
}
|
11612
|
+
});
|
11613
|
+
});
|
11614
|
+
}
|
11615
|
+
}, [visible, enableMemory, handleSetCurrentIndex, id]);
|
11616
|
+
/** 加载清晰度配置 */
|
11617
|
+
|
11618
|
+
React.useEffect(function () {
|
11619
|
+
if (!lodash.isEmpty(definitionList[currentIndex]) && player.current) {
|
11620
|
+
player.current.emit('resourceReady', definitionList[currentIndex]);
|
11621
|
+
}
|
11622
|
+
}, [currentIndex, definitionList]);
|
11623
|
+
var getRef = React.useCallback(function (ref) {
|
11624
|
+
if (ref && visible) {
|
11625
|
+
var newConfig = _objectSpread2(_objectSpread2({}, config.current), {}, {
|
11626
|
+
el: ref,
|
11627
|
+
url: videoUrls[0],
|
11628
|
+
playNext: {
|
11629
|
+
urlList: videoUrls.slice(1)
|
11630
|
+
}
|
11631
|
+
});
|
11632
|
+
|
11633
|
+
if (enableMemory) {
|
11634
|
+
var _JSON$parse2;
|
11635
|
+
|
11636
|
+
var _ref3 = ((_JSON$parse2 = JSON.parse(localStorage.getItem('videoPlayedTime') || '{}')) === null || _JSON$parse2 === void 0 ? void 0 : _JSON$parse2[id]) || {},
|
11637
|
+
lastPlayTime = _ref3.lastPlayTime;
|
11638
|
+
|
11639
|
+
Object.assign(newConfig, {
|
11640
|
+
lastPlayTime: lastPlayTime,
|
11641
|
+
lastPlayTimeHideDelay: lastPlayTimeHideDelay
|
11642
|
+
});
|
11643
|
+
}
|
11644
|
+
|
11645
|
+
config.current = newConfig;
|
11646
|
+
}
|
11647
|
+
}, [visible, id, videoUrls, lastPlayTimeHideDelay, enableMemory]);
|
11648
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
11649
|
+
className: className,
|
11650
|
+
ref: getRef,
|
11651
|
+
style: style
|
11652
|
+
});
|
11653
|
+
});
|
11654
|
+
|
11423
11655
|
exports.AutoScroll = Index$9;
|
11424
11656
|
exports.Breadcrumb = Index$b;
|
11425
11657
|
exports.Button = WButton;
|
@@ -11443,6 +11675,7 @@ exports.Switch = WSwitch;
|
|
11443
11675
|
exports.TabelCard = index$2;
|
11444
11676
|
exports.Table = Table;
|
11445
11677
|
exports.TreeSelect = Index$6;
|
11678
|
+
exports.Video = index$4;
|
11446
11679
|
exports.VideoPlayer = index$3;
|
11447
11680
|
exports.WDatePicker = Index$5;
|
11448
11681
|
exports.WForm = WForm$1;
|
package/package.json
CHANGED