wargerm 0.4.20 → 0.4.23
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/Modal/index.d.ts +0 -1
- 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 +37 -8
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.css +37 -8
- package/dist/index.esm.js +238 -12
- package/dist/index.js +237 -10
- 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;
|
@@ -1441,8 +1470,8 @@ button[data-prefers-color='dark'] .swiper-pagination-bullet {
|
|
1441
1470
|
background: #0f6ab7;
|
1442
1471
|
}
|
1443
1472
|
[data-prefers-color='dark'] .videoContainer {
|
1444
|
-
min-width:
|
1445
|
-
min-height:
|
1473
|
+
min-width: 10px;
|
1474
|
+
min-height: 10px;
|
1446
1475
|
width: 100%;
|
1447
1476
|
height: 100%;
|
1448
1477
|
display: flex;
|
@@ -2865,8 +2894,8 @@ button[data-prefers-color='light'] .swiper-pagination-bullet {
|
|
2865
2894
|
background: #0f6ab7;
|
2866
2895
|
}
|
2867
2896
|
[data-prefers-color='light'] .videoContainer {
|
2868
|
-
min-width:
|
2869
|
-
min-height:
|
2897
|
+
min-width: 10px;
|
2898
|
+
min-height: 10px;
|
2870
2899
|
width: 100%;
|
2871
2900
|
height: 100%;
|
2872
2901
|
display: flex;
|
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;
|
@@ -1441,8 +1470,8 @@ button[data-prefers-color='dark'] .swiper-pagination-bullet {
|
|
1441
1470
|
background: #0f6ab7;
|
1442
1471
|
}
|
1443
1472
|
[data-prefers-color='dark'] .videoContainer {
|
1444
|
-
min-width:
|
1445
|
-
min-height:
|
1473
|
+
min-width: 10px;
|
1474
|
+
min-height: 10px;
|
1446
1475
|
width: 100%;
|
1447
1476
|
height: 100%;
|
1448
1477
|
display: flex;
|
@@ -2865,8 +2894,8 @@ button[data-prefers-color='light'] .swiper-pagination-bullet {
|
|
2865
2894
|
background: #0f6ab7;
|
2866
2895
|
}
|
2867
2896
|
[data-prefers-color='light'] .videoContainer {
|
2868
|
-
min-width:
|
2869
|
-
min-height:
|
2897
|
+
min-width: 10px;
|
2898
|
+
min-height: 10px;
|
2870
2899
|
width: 100%;
|
2871
2900
|
height: 100%;
|
2872
2901
|
display: flex;
|
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 || ''))
|
@@ -9938,11 +9939,6 @@ var Modal = /*#__PURE__*/function (_React$PureComponent) {
|
|
9938
9939
|
document.onmousemove = null;
|
9939
9940
|
};
|
9940
9941
|
}
|
9941
|
-
}, {
|
9942
|
-
key: "componentWillUnmount",
|
9943
|
-
value: function componentWillUnmount() {
|
9944
|
-
Modal.destory();
|
9945
|
-
}
|
9946
9942
|
}, {
|
9947
9943
|
key: "render",
|
9948
9944
|
value: function render() {
|
@@ -11177,12 +11173,12 @@ function Xgplay(_ref, fRef) {
|
|
11177
11173
|
}
|
11178
11174
|
|
11179
11175
|
return function () {
|
11180
|
-
var _playerRef$current
|
11176
|
+
var _playerRef$current;
|
11181
11177
|
|
11182
|
-
(_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.destroy(true);
|
11183
11179
|
setRef(null);
|
11184
11180
|
};
|
11185
|
-
});
|
11181
|
+
}, []);
|
11186
11182
|
useImperativeHandle(fRef, function () {
|
11187
11183
|
return {
|
11188
11184
|
player: playerRef.current
|
@@ -11387,4 +11383,234 @@ function VideoPlayer(_ref, ref) {
|
|
11387
11383
|
|
11388
11384
|
var index$3 = /*#__PURE__*/forwardRef(VideoPlayer);
|
11389
11385
|
|
11390
|
-
|
11386
|
+
var _excluded$i = ["id", "videoUrls", "definitionList", "isLoop", "muted", "currentIndex", "setCurrentIndex", "className", "style", "visible", "autoplay", "videoInit", "enableMemory", "lastPlayTimeHideDelay"];
|
11387
|
+
|
11388
|
+
var DEFAULT_PLAY_BACK_RATE = [0.5, 0.75, 1, 1.5, 2]; // 默认记忆提示文字展示时长(s)
|
11389
|
+
|
11390
|
+
var DEFAULT_LAST_PLAY_TIME_DELAY = 5; // 默认音量大小
|
11391
|
+
|
11392
|
+
var DEFAULT_VOLUME = 0.6;
|
11393
|
+
var index$4 = (function (_ref) {
|
11394
|
+
var id = _ref.id,
|
11395
|
+
_ref$videoUrls = _ref.videoUrls,
|
11396
|
+
videoUrls = _ref$videoUrls === void 0 ? [] : _ref$videoUrls,
|
11397
|
+
_ref$definitionList = _ref.definitionList,
|
11398
|
+
definitionList = _ref$definitionList === void 0 ? [] : _ref$definitionList,
|
11399
|
+
_ref$isLoop = _ref.isLoop,
|
11400
|
+
isLoop = _ref$isLoop === void 0 ? true : _ref$isLoop,
|
11401
|
+
_ref$muted = _ref.muted,
|
11402
|
+
muted = _ref$muted === void 0 ? false : _ref$muted,
|
11403
|
+
parentIndex = _ref.currentIndex,
|
11404
|
+
setParentIndex = _ref.setCurrentIndex,
|
11405
|
+
className = _ref.className,
|
11406
|
+
style = _ref.style,
|
11407
|
+
_ref$visible = _ref.visible,
|
11408
|
+
visible = _ref$visible === void 0 ? true : _ref$visible,
|
11409
|
+
_ref$autoplay = _ref.autoplay,
|
11410
|
+
autoplay = _ref$autoplay === void 0 ? false : _ref$autoplay,
|
11411
|
+
_ref$videoInit = _ref.videoInit,
|
11412
|
+
videoInit = _ref$videoInit === void 0 ? true : _ref$videoInit,
|
11413
|
+
_ref$enableMemory = _ref.enableMemory,
|
11414
|
+
enableMemory = _ref$enableMemory === void 0 ? false : _ref$enableMemory,
|
11415
|
+
_ref$lastPlayTimeHide = _ref.lastPlayTimeHideDelay,
|
11416
|
+
lastPlayTimeHideDelay = _ref$lastPlayTimeHide === void 0 ? DEFAULT_LAST_PLAY_TIME_DELAY : _ref$lastPlayTimeHide,
|
11417
|
+
props = _objectWithoutProperties(_ref, _excluded$i);
|
11418
|
+
|
11419
|
+
var player = useRef();
|
11420
|
+
var currentPlayerIndex = useRef(0); // 内置的 index 状态管理
|
11421
|
+
|
11422
|
+
var _useState = useState(0),
|
11423
|
+
_useState2 = _slicedToArray(_useState, 2),
|
11424
|
+
videoIndex = _useState2[0],
|
11425
|
+
setVideoIndex = _useState2[1];
|
11426
|
+
|
11427
|
+
var currentIndex = useMemo(function () {
|
11428
|
+
return parentIndex !== null && parentIndex !== void 0 ? parentIndex : videoIndex;
|
11429
|
+
}, [parentIndex, videoIndex]);
|
11430
|
+
var setCurrentIndex = useMemo(function () {
|
11431
|
+
return setParentIndex !== null && setParentIndex !== void 0 ? setParentIndex : setVideoIndex;
|
11432
|
+
}, [setParentIndex, setVideoIndex]);
|
11433
|
+
var config = useRef(_objectSpread2({
|
11434
|
+
url: videoUrls[0],
|
11435
|
+
playbackRate: DEFAULT_PLAY_BACK_RATE,
|
11436
|
+
playNext: {
|
11437
|
+
urlList: videoUrls.slice(1)
|
11438
|
+
},
|
11439
|
+
volume: muted ? 0 : DEFAULT_VOLUME,
|
11440
|
+
autoplay: autoplay,
|
11441
|
+
videoInit: videoInit,
|
11442
|
+
lastPlayTimeHideDelay: lastPlayTimeHideDelay
|
11443
|
+
}, props));
|
11444
|
+
/** 设置当前播放 index */
|
11445
|
+
|
11446
|
+
var handleSetCurrentIndex = useCallback(function (currentIdx) {
|
11447
|
+
var newIdx = currentIdx !== null && currentIdx !== void 0 ? currentIdx : currentPlayerIndex.current + 1;
|
11448
|
+
|
11449
|
+
if (newIdx >= videoUrls.length) {
|
11450
|
+
if (isLoop) {
|
11451
|
+
// 允许循环则播放起始视频
|
11452
|
+
newIdx = 0;
|
11453
|
+
} else if (player.current && player.current.video) {
|
11454
|
+
// 不允许循环则进度条快进到最后
|
11455
|
+
player.current.currentTime = player.current.video.duration;
|
11456
|
+
return;
|
11457
|
+
}
|
11458
|
+
}
|
11459
|
+
|
11460
|
+
setCurrentIndex(newIdx);
|
11461
|
+
}, [isLoop, setCurrentIndex, videoUrls.length]);
|
11462
|
+
/** 播放下一个 */
|
11463
|
+
|
11464
|
+
var handlePlayNext = useCallback(function (currentIdx) {
|
11465
|
+
if (!player.current) {
|
11466
|
+
return;
|
11467
|
+
}
|
11468
|
+
|
11469
|
+
player.current.src = videoUrls[currentIdx];
|
11470
|
+
player.current.emit('playerNext', currentIdx);
|
11471
|
+
player.current.play();
|
11472
|
+
currentPlayerIndex.current = currentIdx;
|
11473
|
+
|
11474
|
+
if (isLoop) {
|
11475
|
+
// 防止 next 按钮消失
|
11476
|
+
player.current.currentVideoIndex = -videoUrls.length;
|
11477
|
+
}
|
11478
|
+
}, [videoUrls, isLoop]);
|
11479
|
+
/** 重置视频 */
|
11480
|
+
|
11481
|
+
var handleReset = useCallback(function () {
|
11482
|
+
if (!player.current) {
|
11483
|
+
return;
|
11484
|
+
}
|
11485
|
+
|
11486
|
+
setCurrentIndex(0);
|
11487
|
+
currentPlayerIndex.current = -1;
|
11488
|
+
player.current.destroy();
|
11489
|
+
player.current = undefined;
|
11490
|
+
}, [setCurrentIndex]);
|
11491
|
+
/** 弹窗中的视频关闭以后重置 */
|
11492
|
+
|
11493
|
+
useEffect(function () {
|
11494
|
+
if (!visible) {
|
11495
|
+
handleReset();
|
11496
|
+
}
|
11497
|
+
}, [handleReset, visible]);
|
11498
|
+
/** 当 currentIndex 改变以后自动播放下一个 */
|
11499
|
+
|
11500
|
+
useEffect(function () {
|
11501
|
+
if (!player.current || !visible) {
|
11502
|
+
return;
|
11503
|
+
}
|
11504
|
+
|
11505
|
+
handlePlayNext(currentIndex !== null && currentIndex !== void 0 ? currentIndex : currentPlayerIndex.current);
|
11506
|
+
}, [currentIndex, handlePlayNext, visible]);
|
11507
|
+
/** 播放器初始化并绑定事件 */
|
11508
|
+
|
11509
|
+
useEffect(function () {
|
11510
|
+
if (!visible || isEmpty(videoUrls) || player.current) {
|
11511
|
+
return;
|
11512
|
+
}
|
11513
|
+
|
11514
|
+
player.current = new Player(config.current);
|
11515
|
+
player.current.currentVideoIndex = -videoUrls.length;
|
11516
|
+
player.current.on('ended', function () {
|
11517
|
+
// 如果是循环或有其他视频未播放完,继续播放下一个
|
11518
|
+
if (isLoop || !isLoop && currentPlayerIndex.current < videoUrls.length - 1) {
|
11519
|
+
handleSetCurrentIndex();
|
11520
|
+
setTimeout(function () {
|
11521
|
+
var _player$current;
|
11522
|
+
|
11523
|
+
return (_player$current = player.current) === null || _player$current === void 0 ? void 0 : _player$current.play();
|
11524
|
+
});
|
11525
|
+
} else {
|
11526
|
+
var _player$current2;
|
11527
|
+
|
11528
|
+
(_player$current2 = player.current) === null || _player$current2 === void 0 ? void 0 : _player$current2.pause();
|
11529
|
+
}
|
11530
|
+
}); // 播放记忆缓存
|
11531
|
+
|
11532
|
+
if (enableMemory) {
|
11533
|
+
var videoPlayedTimeObj = JSON.parse(localStorage.getItem('videoPlayedTime') || '{}');
|
11534
|
+
player.current.on('timeupdate', function () {
|
11535
|
+
var _player$current3;
|
11536
|
+
|
11537
|
+
if (currentPlayerIndex.current === -1) {
|
11538
|
+
return;
|
11539
|
+
}
|
11540
|
+
|
11541
|
+
localStorage.setItem('videoPlayedTime', JSON.stringify(_objectSpread2(_objectSpread2({}, videoPlayedTimeObj), {}, _defineProperty({}, id, {
|
11542
|
+
lastPlayTime: (_player$current3 = player.current) === null || _player$current3 === void 0 ? void 0 : _player$current3.currentTime,
|
11543
|
+
videoIndex: currentPlayerIndex.current
|
11544
|
+
}))));
|
11545
|
+
});
|
11546
|
+
}
|
11547
|
+
|
11548
|
+
player.current.on('playNextBtnClick', function () {
|
11549
|
+
if (!isLoop && player.current) {
|
11550
|
+
// 防止 next 按钮消失
|
11551
|
+
player.current.currentVideoIndex = videoUrls.length - 2;
|
11552
|
+
}
|
11553
|
+
|
11554
|
+
handleSetCurrentIndex();
|
11555
|
+
});
|
11556
|
+
}, [autoplay, enableMemory, handleSetCurrentIndex, id, isLoop, videoUrls, videoUrls.length, visible]);
|
11557
|
+
/** 读取缓存的播放记忆并跳转 */
|
11558
|
+
|
11559
|
+
useEffect(function () {
|
11560
|
+
if (enableMemory && visible) {
|
11561
|
+
var _JSON$parse;
|
11562
|
+
|
11563
|
+
var _ref2 = ((_JSON$parse = JSON.parse(localStorage.getItem('videoPlayedTime') || '{}')) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse[id]) || {},
|
11564
|
+
lastPlayTime = _ref2.lastPlayTime,
|
11565
|
+
_videoIndex = _ref2.videoIndex;
|
11566
|
+
|
11567
|
+
setTimeout(function () {
|
11568
|
+
handleSetCurrentIndex(_videoIndex);
|
11569
|
+
setTimeout(function () {
|
11570
|
+
if (player.current) {
|
11571
|
+
player.current.currentTime = lastPlayTime;
|
11572
|
+
}
|
11573
|
+
});
|
11574
|
+
});
|
11575
|
+
}
|
11576
|
+
}, [visible, enableMemory, handleSetCurrentIndex, id]);
|
11577
|
+
/** 加载清晰度配置 */
|
11578
|
+
|
11579
|
+
useEffect(function () {
|
11580
|
+
if (!isEmpty(definitionList[currentIndex]) && player.current) {
|
11581
|
+
player.current.emit('resourceReady', definitionList[currentIndex]);
|
11582
|
+
}
|
11583
|
+
}, [currentIndex, definitionList]);
|
11584
|
+
var getRef = useCallback(function (ref) {
|
11585
|
+
if (ref && visible) {
|
11586
|
+
var newConfig = _objectSpread2(_objectSpread2({}, config.current), {}, {
|
11587
|
+
el: ref,
|
11588
|
+
url: videoUrls[0],
|
11589
|
+
playNext: {
|
11590
|
+
urlList: videoUrls.slice(1)
|
11591
|
+
}
|
11592
|
+
});
|
11593
|
+
|
11594
|
+
if (enableMemory) {
|
11595
|
+
var _JSON$parse2;
|
11596
|
+
|
11597
|
+
var _ref3 = ((_JSON$parse2 = JSON.parse(localStorage.getItem('videoPlayedTime') || '{}')) === null || _JSON$parse2 === void 0 ? void 0 : _JSON$parse2[id]) || {},
|
11598
|
+
lastPlayTime = _ref3.lastPlayTime;
|
11599
|
+
|
11600
|
+
Object.assign(newConfig, {
|
11601
|
+
lastPlayTime: lastPlayTime,
|
11602
|
+
lastPlayTimeHideDelay: lastPlayTimeHideDelay
|
11603
|
+
});
|
11604
|
+
}
|
11605
|
+
|
11606
|
+
config.current = newConfig;
|
11607
|
+
}
|
11608
|
+
}, [visible, id, videoUrls, lastPlayTimeHideDelay, enableMemory]);
|
11609
|
+
return /*#__PURE__*/React.createElement("div", {
|
11610
|
+
className: className,
|
11611
|
+
ref: getRef,
|
11612
|
+
style: style
|
11613
|
+
});
|
11614
|
+
});
|
11615
|
+
|
11616
|
+
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 || ''))
|
@@ -9976,11 +9977,6 @@ var Modal = /*#__PURE__*/function (_React$PureComponent) {
|
|
9976
9977
|
document.onmousemove = null;
|
9977
9978
|
};
|
9978
9979
|
}
|
9979
|
-
}, {
|
9980
|
-
key: "componentWillUnmount",
|
9981
|
-
value: function componentWillUnmount() {
|
9982
|
-
Modal.destory();
|
9983
|
-
}
|
9984
9980
|
}, {
|
9985
9981
|
key: "render",
|
9986
9982
|
value: function render() {
|
@@ -11215,12 +11211,12 @@ function Xgplay(_ref, fRef) {
|
|
11215
11211
|
}
|
11216
11212
|
|
11217
11213
|
return function () {
|
11218
|
-
var _playerRef$current
|
11214
|
+
var _playerRef$current;
|
11219
11215
|
|
11220
|
-
(_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.destroy(true);
|
11221
11217
|
setRef(null);
|
11222
11218
|
};
|
11223
|
-
});
|
11219
|
+
}, []);
|
11224
11220
|
React.useImperativeHandle(fRef, function () {
|
11225
11221
|
return {
|
11226
11222
|
player: playerRef.current
|
@@ -11425,6 +11421,236 @@ function VideoPlayer(_ref, ref) {
|
|
11425
11421
|
|
11426
11422
|
var index$3 = /*#__PURE__*/React.forwardRef(VideoPlayer);
|
11427
11423
|
|
11424
|
+
var _excluded$i = ["id", "videoUrls", "definitionList", "isLoop", "muted", "currentIndex", "setCurrentIndex", "className", "style", "visible", "autoplay", "videoInit", "enableMemory", "lastPlayTimeHideDelay"];
|
11425
|
+
|
11426
|
+
var DEFAULT_PLAY_BACK_RATE = [0.5, 0.75, 1, 1.5, 2]; // 默认记忆提示文字展示时长(s)
|
11427
|
+
|
11428
|
+
var DEFAULT_LAST_PLAY_TIME_DELAY = 5; // 默认音量大小
|
11429
|
+
|
11430
|
+
var DEFAULT_VOLUME = 0.6;
|
11431
|
+
var index$4 = (function (_ref) {
|
11432
|
+
var id = _ref.id,
|
11433
|
+
_ref$videoUrls = _ref.videoUrls,
|
11434
|
+
videoUrls = _ref$videoUrls === void 0 ? [] : _ref$videoUrls,
|
11435
|
+
_ref$definitionList = _ref.definitionList,
|
11436
|
+
definitionList = _ref$definitionList === void 0 ? [] : _ref$definitionList,
|
11437
|
+
_ref$isLoop = _ref.isLoop,
|
11438
|
+
isLoop = _ref$isLoop === void 0 ? true : _ref$isLoop,
|
11439
|
+
_ref$muted = _ref.muted,
|
11440
|
+
muted = _ref$muted === void 0 ? false : _ref$muted,
|
11441
|
+
parentIndex = _ref.currentIndex,
|
11442
|
+
setParentIndex = _ref.setCurrentIndex,
|
11443
|
+
className = _ref.className,
|
11444
|
+
style = _ref.style,
|
11445
|
+
_ref$visible = _ref.visible,
|
11446
|
+
visible = _ref$visible === void 0 ? true : _ref$visible,
|
11447
|
+
_ref$autoplay = _ref.autoplay,
|
11448
|
+
autoplay = _ref$autoplay === void 0 ? false : _ref$autoplay,
|
11449
|
+
_ref$videoInit = _ref.videoInit,
|
11450
|
+
videoInit = _ref$videoInit === void 0 ? true : _ref$videoInit,
|
11451
|
+
_ref$enableMemory = _ref.enableMemory,
|
11452
|
+
enableMemory = _ref$enableMemory === void 0 ? false : _ref$enableMemory,
|
11453
|
+
_ref$lastPlayTimeHide = _ref.lastPlayTimeHideDelay,
|
11454
|
+
lastPlayTimeHideDelay = _ref$lastPlayTimeHide === void 0 ? DEFAULT_LAST_PLAY_TIME_DELAY : _ref$lastPlayTimeHide,
|
11455
|
+
props = _objectWithoutProperties(_ref, _excluded$i);
|
11456
|
+
|
11457
|
+
var player = React.useRef();
|
11458
|
+
var currentPlayerIndex = React.useRef(0); // 内置的 index 状态管理
|
11459
|
+
|
11460
|
+
var _useState = React.useState(0),
|
11461
|
+
_useState2 = _slicedToArray(_useState, 2),
|
11462
|
+
videoIndex = _useState2[0],
|
11463
|
+
setVideoIndex = _useState2[1];
|
11464
|
+
|
11465
|
+
var currentIndex = React.useMemo(function () {
|
11466
|
+
return parentIndex !== null && parentIndex !== void 0 ? parentIndex : videoIndex;
|
11467
|
+
}, [parentIndex, videoIndex]);
|
11468
|
+
var setCurrentIndex = React.useMemo(function () {
|
11469
|
+
return setParentIndex !== null && setParentIndex !== void 0 ? setParentIndex : setVideoIndex;
|
11470
|
+
}, [setParentIndex, setVideoIndex]);
|
11471
|
+
var config = React.useRef(_objectSpread2({
|
11472
|
+
url: videoUrls[0],
|
11473
|
+
playbackRate: DEFAULT_PLAY_BACK_RATE,
|
11474
|
+
playNext: {
|
11475
|
+
urlList: videoUrls.slice(1)
|
11476
|
+
},
|
11477
|
+
volume: muted ? 0 : DEFAULT_VOLUME,
|
11478
|
+
autoplay: autoplay,
|
11479
|
+
videoInit: videoInit,
|
11480
|
+
lastPlayTimeHideDelay: lastPlayTimeHideDelay
|
11481
|
+
}, props));
|
11482
|
+
/** 设置当前播放 index */
|
11483
|
+
|
11484
|
+
var handleSetCurrentIndex = React.useCallback(function (currentIdx) {
|
11485
|
+
var newIdx = currentIdx !== null && currentIdx !== void 0 ? currentIdx : currentPlayerIndex.current + 1;
|
11486
|
+
|
11487
|
+
if (newIdx >= videoUrls.length) {
|
11488
|
+
if (isLoop) {
|
11489
|
+
// 允许循环则播放起始视频
|
11490
|
+
newIdx = 0;
|
11491
|
+
} else if (player.current && player.current.video) {
|
11492
|
+
// 不允许循环则进度条快进到最后
|
11493
|
+
player.current.currentTime = player.current.video.duration;
|
11494
|
+
return;
|
11495
|
+
}
|
11496
|
+
}
|
11497
|
+
|
11498
|
+
setCurrentIndex(newIdx);
|
11499
|
+
}, [isLoop, setCurrentIndex, videoUrls.length]);
|
11500
|
+
/** 播放下一个 */
|
11501
|
+
|
11502
|
+
var handlePlayNext = React.useCallback(function (currentIdx) {
|
11503
|
+
if (!player.current) {
|
11504
|
+
return;
|
11505
|
+
}
|
11506
|
+
|
11507
|
+
player.current.src = videoUrls[currentIdx];
|
11508
|
+
player.current.emit('playerNext', currentIdx);
|
11509
|
+
player.current.play();
|
11510
|
+
currentPlayerIndex.current = currentIdx;
|
11511
|
+
|
11512
|
+
if (isLoop) {
|
11513
|
+
// 防止 next 按钮消失
|
11514
|
+
player.current.currentVideoIndex = -videoUrls.length;
|
11515
|
+
}
|
11516
|
+
}, [videoUrls, isLoop]);
|
11517
|
+
/** 重置视频 */
|
11518
|
+
|
11519
|
+
var handleReset = React.useCallback(function () {
|
11520
|
+
if (!player.current) {
|
11521
|
+
return;
|
11522
|
+
}
|
11523
|
+
|
11524
|
+
setCurrentIndex(0);
|
11525
|
+
currentPlayerIndex.current = -1;
|
11526
|
+
player.current.destroy();
|
11527
|
+
player.current = undefined;
|
11528
|
+
}, [setCurrentIndex]);
|
11529
|
+
/** 弹窗中的视频关闭以后重置 */
|
11530
|
+
|
11531
|
+
React.useEffect(function () {
|
11532
|
+
if (!visible) {
|
11533
|
+
handleReset();
|
11534
|
+
}
|
11535
|
+
}, [handleReset, visible]);
|
11536
|
+
/** 当 currentIndex 改变以后自动播放下一个 */
|
11537
|
+
|
11538
|
+
React.useEffect(function () {
|
11539
|
+
if (!player.current || !visible) {
|
11540
|
+
return;
|
11541
|
+
}
|
11542
|
+
|
11543
|
+
handlePlayNext(currentIndex !== null && currentIndex !== void 0 ? currentIndex : currentPlayerIndex.current);
|
11544
|
+
}, [currentIndex, handlePlayNext, visible]);
|
11545
|
+
/** 播放器初始化并绑定事件 */
|
11546
|
+
|
11547
|
+
React.useEffect(function () {
|
11548
|
+
if (!visible || lodash.isEmpty(videoUrls) || player.current) {
|
11549
|
+
return;
|
11550
|
+
}
|
11551
|
+
|
11552
|
+
player.current = new Player__default['default'](config.current);
|
11553
|
+
player.current.currentVideoIndex = -videoUrls.length;
|
11554
|
+
player.current.on('ended', function () {
|
11555
|
+
// 如果是循环或有其他视频未播放完,继续播放下一个
|
11556
|
+
if (isLoop || !isLoop && currentPlayerIndex.current < videoUrls.length - 1) {
|
11557
|
+
handleSetCurrentIndex();
|
11558
|
+
setTimeout(function () {
|
11559
|
+
var _player$current;
|
11560
|
+
|
11561
|
+
return (_player$current = player.current) === null || _player$current === void 0 ? void 0 : _player$current.play();
|
11562
|
+
});
|
11563
|
+
} else {
|
11564
|
+
var _player$current2;
|
11565
|
+
|
11566
|
+
(_player$current2 = player.current) === null || _player$current2 === void 0 ? void 0 : _player$current2.pause();
|
11567
|
+
}
|
11568
|
+
}); // 播放记忆缓存
|
11569
|
+
|
11570
|
+
if (enableMemory) {
|
11571
|
+
var videoPlayedTimeObj = JSON.parse(localStorage.getItem('videoPlayedTime') || '{}');
|
11572
|
+
player.current.on('timeupdate', function () {
|
11573
|
+
var _player$current3;
|
11574
|
+
|
11575
|
+
if (currentPlayerIndex.current === -1) {
|
11576
|
+
return;
|
11577
|
+
}
|
11578
|
+
|
11579
|
+
localStorage.setItem('videoPlayedTime', JSON.stringify(_objectSpread2(_objectSpread2({}, videoPlayedTimeObj), {}, _defineProperty({}, id, {
|
11580
|
+
lastPlayTime: (_player$current3 = player.current) === null || _player$current3 === void 0 ? void 0 : _player$current3.currentTime,
|
11581
|
+
videoIndex: currentPlayerIndex.current
|
11582
|
+
}))));
|
11583
|
+
});
|
11584
|
+
}
|
11585
|
+
|
11586
|
+
player.current.on('playNextBtnClick', function () {
|
11587
|
+
if (!isLoop && player.current) {
|
11588
|
+
// 防止 next 按钮消失
|
11589
|
+
player.current.currentVideoIndex = videoUrls.length - 2;
|
11590
|
+
}
|
11591
|
+
|
11592
|
+
handleSetCurrentIndex();
|
11593
|
+
});
|
11594
|
+
}, [autoplay, enableMemory, handleSetCurrentIndex, id, isLoop, videoUrls, videoUrls.length, visible]);
|
11595
|
+
/** 读取缓存的播放记忆并跳转 */
|
11596
|
+
|
11597
|
+
React.useEffect(function () {
|
11598
|
+
if (enableMemory && visible) {
|
11599
|
+
var _JSON$parse;
|
11600
|
+
|
11601
|
+
var _ref2 = ((_JSON$parse = JSON.parse(localStorage.getItem('videoPlayedTime') || '{}')) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse[id]) || {},
|
11602
|
+
lastPlayTime = _ref2.lastPlayTime,
|
11603
|
+
_videoIndex = _ref2.videoIndex;
|
11604
|
+
|
11605
|
+
setTimeout(function () {
|
11606
|
+
handleSetCurrentIndex(_videoIndex);
|
11607
|
+
setTimeout(function () {
|
11608
|
+
if (player.current) {
|
11609
|
+
player.current.currentTime = lastPlayTime;
|
11610
|
+
}
|
11611
|
+
});
|
11612
|
+
});
|
11613
|
+
}
|
11614
|
+
}, [visible, enableMemory, handleSetCurrentIndex, id]);
|
11615
|
+
/** 加载清晰度配置 */
|
11616
|
+
|
11617
|
+
React.useEffect(function () {
|
11618
|
+
if (!lodash.isEmpty(definitionList[currentIndex]) && player.current) {
|
11619
|
+
player.current.emit('resourceReady', definitionList[currentIndex]);
|
11620
|
+
}
|
11621
|
+
}, [currentIndex, definitionList]);
|
11622
|
+
var getRef = React.useCallback(function (ref) {
|
11623
|
+
if (ref && visible) {
|
11624
|
+
var newConfig = _objectSpread2(_objectSpread2({}, config.current), {}, {
|
11625
|
+
el: ref,
|
11626
|
+
url: videoUrls[0],
|
11627
|
+
playNext: {
|
11628
|
+
urlList: videoUrls.slice(1)
|
11629
|
+
}
|
11630
|
+
});
|
11631
|
+
|
11632
|
+
if (enableMemory) {
|
11633
|
+
var _JSON$parse2;
|
11634
|
+
|
11635
|
+
var _ref3 = ((_JSON$parse2 = JSON.parse(localStorage.getItem('videoPlayedTime') || '{}')) === null || _JSON$parse2 === void 0 ? void 0 : _JSON$parse2[id]) || {},
|
11636
|
+
lastPlayTime = _ref3.lastPlayTime;
|
11637
|
+
|
11638
|
+
Object.assign(newConfig, {
|
11639
|
+
lastPlayTime: lastPlayTime,
|
11640
|
+
lastPlayTimeHideDelay: lastPlayTimeHideDelay
|
11641
|
+
});
|
11642
|
+
}
|
11643
|
+
|
11644
|
+
config.current = newConfig;
|
11645
|
+
}
|
11646
|
+
}, [visible, id, videoUrls, lastPlayTimeHideDelay, enableMemory]);
|
11647
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
11648
|
+
className: className,
|
11649
|
+
ref: getRef,
|
11650
|
+
style: style
|
11651
|
+
});
|
11652
|
+
});
|
11653
|
+
|
11428
11654
|
exports.AutoScroll = Index$9;
|
11429
11655
|
exports.Breadcrumb = Index$b;
|
11430
11656
|
exports.Button = WButton;
|
@@ -11448,6 +11674,7 @@ exports.Switch = WSwitch;
|
|
11448
11674
|
exports.TabelCard = index$2;
|
11449
11675
|
exports.Table = Table;
|
11450
11676
|
exports.TreeSelect = Index$6;
|
11677
|
+
exports.Video = index$4;
|
11451
11678
|
exports.VideoPlayer = index$3;
|
11452
11679
|
exports.WDatePicker = Index$5;
|
11453
11680
|
exports.WForm = WForm$1;
|
package/package.json
CHANGED