@cloud-app-dev/vidc 3.0.17 → 3.0.19
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/.umirc.ts +1 -1
- package/es/CustomRenderSelect/index.d.ts +1 -1
- package/es/CustomRenderSelect/index.js +3 -3
- package/es/LoaderScript/utils.js +1 -0
- package/es/Map/LevelCenter/DragMarker/index.d.ts +1 -4
- package/es/Map/LevelCenter/DragMarker/index.js +2 -5
- package/es/Map/LevelCenter/index.js +13 -2
- package/es/Map/SinglePoint/index.d.ts +10 -3
- package/es/Map/SinglePoint/index.js +37 -15
- package/es/Map/hook/useMapEvent.js +9 -8
- package/es/Map/index.d.ts +1 -1
- package/es/Player/api/index.d.ts +5 -1
- package/es/Player/api/index.js +36 -24
- package/es/Player/context.d.ts +21 -0
- package/es/Player/context.js +16 -0
- package/es/Player/contraller_bar/contraller_event.d.ts +1 -4
- package/es/Player/contraller_bar/contraller_event.js +37 -28
- package/es/Player/contraller_bar/index.d.ts +2 -7
- package/es/Player/contraller_bar/index.js +4 -12
- package/es/Player/contraller_bar/left_bar.d.ts +2 -7
- package/es/Player/contraller_bar/left_bar.js +29 -33
- package/es/Player/contraller_bar/right_bar.d.ts +1 -6
- package/es/Player/contraller_bar/right_bar.js +6 -3
- package/es/Player/contraller_bar/time.d.ts +3 -0
- package/es/Player/contraller_bar/time.js +34 -0
- package/es/Player/contraller_bar/useBarStatus.js +17 -24
- package/es/Player/contraller_bar/volume.d.ts +9 -0
- package/es/Player/contraller_bar/volume.js +86 -0
- package/es/Player/demo.js +5 -1
- package/es/Player/event/errorEvent.js +34 -43
- package/es/Player/event/eventName.d.ts +17 -2
- package/es/Player/event/eventName.js +5 -1
- package/es/Player/event/index.d.ts +2 -0
- package/es/Player/event/index.js +55 -3
- package/es/Player/fps_play.d.ts +11 -0
- package/es/Player/fps_play.js +99 -0
- package/es/Player/frontend_player.js +0 -2
- package/es/Player/frontend_timeline.d.ts +1 -5
- package/es/Player/frontend_timeline.js +14 -11
- package/es/Player/live_heart.js +1 -1
- package/es/Player/message.js +69 -84
- package/es/Player/player.d.ts +15 -15
- package/es/Player/segment_player.js +12 -29
- package/es/Player/segment_timeline.d.ts +1 -6
- package/es/Player/segment_timeline.js +56 -11
- package/es/Player/single_player.js +80 -35
- package/es/Player/style/bar.css +2 -1
- package/es/Player/style/iconfont.js +15 -16
- package/es/Player/style/index.css +8 -0
- package/es/Player/style/timeline.css +7 -0
- package/es/Player/style/volume.css +19 -0
- package/es/Player/timeline.d.ts +1 -1
- package/es/Player/timeline.js +26 -37
- package/es/Player/util.d.ts +2 -1
- package/es/Player/util.js +10 -6
- package/es/ScreenPlayer/Live.js +0 -1
- package/es/ScreenPlayer/LiveTools.js +7 -27
- package/es/ScreenPlayer/PlayerWithExt.d.ts +1 -1
- package/es/ScreenPlayer/PlayerWithExt.js +2 -4
- package/es/ScreenPlayer/Record.js +0 -1
- package/es/ScreenPlayer/RecordTools.js +31 -16
- package/es/ScreenPlayer/ScreenSelect.js +2 -2
- package/es/ScreenPlayer/TimeMode.js +1 -1
- package/es/ScreenPlayer/demo2.js +1 -1
- package/es/ScreenPlayer/index.css +17 -8
- package/es/ScreenPlayer/utils.js +4 -4
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/useRafInterval/index.d.ts +5 -0
- package/es/useRafInterval/index.js +94 -0
- package/icon-fix.js +31 -0
- package/package.json +1 -1
- package/es/Map/SinglePoint/Marker/index.d.ts +0 -7
- package/es/Map/SinglePoint/Marker/index.js +0 -29
- package/es/Player/event/browserTabEvent.d.ts +0 -9
- package/es/Player/event/browserTabEvent.js +0 -57
- package/es/ScreenPlayer/TimeSlider.d.ts +0 -129
- package/es/ScreenPlayer/TimeSlider.js +0 -556
|
@@ -10,41 +10,39 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
10
10
|
|
|
11
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
12
|
|
|
13
|
-
import React, { useState,
|
|
13
|
+
import React, { useState, useCallback, useMemo, useContext } from 'react';
|
|
14
14
|
import IconFont from '../iconfont';
|
|
15
15
|
import Bar from './bar';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { Context } from '../context';
|
|
17
|
+
import { useVideoEvent } from '../event';
|
|
18
|
+
import Volume from './volume';
|
|
19
|
+
import Time from './time';
|
|
18
20
|
|
|
19
21
|
function LeftBar(_ref) {
|
|
20
|
-
var
|
|
21
|
-
event = _ref.event,
|
|
22
|
-
container = _ref.container,
|
|
23
|
-
isLive = _ref.isLive,
|
|
24
|
-
reload = _ref.reload,
|
|
22
|
+
var reload = _ref.reload,
|
|
25
23
|
leftExtContents = _ref.leftExtContents,
|
|
26
24
|
leftMidExtContents = _ref.leftMidExtContents,
|
|
27
|
-
hideTimeProgress = _ref.hideTimeProgress
|
|
25
|
+
hideTimeProgress = _ref.hideTimeProgress,
|
|
26
|
+
oneFpsPlay = _ref.oneFpsPlay;
|
|
27
|
+
|
|
28
|
+
var _useContext = useContext(Context),
|
|
29
|
+
api = _useContext.api,
|
|
30
|
+
container = _useContext.container,
|
|
31
|
+
isLive = _useContext.isLive,
|
|
32
|
+
isFpsPlay = _useContext.isFpsPlay;
|
|
28
33
|
|
|
29
34
|
var _useState = useState(Date.now()),
|
|
30
35
|
_useState2 = _slicedToArray(_useState, 2),
|
|
31
36
|
dep = _useState2[0],
|
|
32
37
|
setDep = _useState2[1];
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
39
|
+
var updateRender = function updateRender() {
|
|
40
|
+
return setDep(Date.now());
|
|
41
|
+
};
|
|
38
42
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return function () {
|
|
43
|
-
event.removeEventListener('play', updateRender);
|
|
44
|
-
event.removeEventListener('pause', updateRender);
|
|
45
|
-
event.removeEventListener('volumechange', updateRender);
|
|
46
|
-
};
|
|
47
|
-
}, [event]);
|
|
43
|
+
useVideoEvent('play', updateRender);
|
|
44
|
+
useVideoEvent('pause', updateRender);
|
|
45
|
+
useVideoEvent('volumechange', updateRender);
|
|
48
46
|
var video = container.querySelector('video'); //缓存值
|
|
49
47
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
50
48
|
|
|
@@ -56,13 +54,7 @@ function LeftBar(_ref) {
|
|
|
56
54
|
}, [paused]);
|
|
57
55
|
var statusText = useMemo(function () {
|
|
58
56
|
return paused ? '播放' : '暂停';
|
|
59
|
-
}, [paused]);
|
|
60
|
-
|
|
61
|
-
var _useTimes = useTimes(api, event, hideTimeProgress),
|
|
62
|
-
_useTimes2 = _slicedToArray(_useTimes, 3),
|
|
63
|
-
current = _useTimes2[0],
|
|
64
|
-
duration = _useTimes2[2]; //TODO 方法
|
|
65
|
-
|
|
57
|
+
}, [paused]); //TODO 方法
|
|
66
58
|
|
|
67
59
|
var changePlayStatus = useCallback(function () {
|
|
68
60
|
if (video === null || video === void 0 ? void 0 : video.paused) {
|
|
@@ -75,16 +67,20 @@ function LeftBar(_ref) {
|
|
|
75
67
|
}, [video, api]);
|
|
76
68
|
return /*#__PURE__*/React.createElement("div", {
|
|
77
69
|
className: "contraller-left-bar"
|
|
78
|
-
}, leftExtContents, /*#__PURE__*/React.createElement(Bar, null, /*#__PURE__*/React.createElement(IconFont, {
|
|
70
|
+
}, leftExtContents, !isFpsPlay && /*#__PURE__*/React.createElement(Bar, null, /*#__PURE__*/React.createElement(IconFont, {
|
|
79
71
|
onClick: changePlayStatus,
|
|
80
72
|
type: statusIconClassName,
|
|
81
73
|
title: statusText
|
|
82
|
-
})),
|
|
83
|
-
|
|
84
|
-
}
|
|
74
|
+
})), /*#__PURE__*/React.createElement(Bar, null, /*#__PURE__*/React.createElement(Volume, {
|
|
75
|
+
api: api
|
|
76
|
+
})), !isLive && !hideTimeProgress && /*#__PURE__*/React.createElement(Time, null), /*#__PURE__*/React.createElement(Bar, null, /*#__PURE__*/React.createElement(IconFont, {
|
|
85
77
|
onClick: reload,
|
|
86
78
|
type: "lm-player-Refresh_Main",
|
|
87
79
|
title: "\u91CD\u8F7D"
|
|
80
|
+
})), !isLive && oneFpsPlay && /*#__PURE__*/React.createElement(Bar, null, /*#__PURE__*/React.createElement(IconFont, {
|
|
81
|
+
onClick: isFpsPlay ? api.closeFpsPlay : api.openFpsPlay,
|
|
82
|
+
type: "lm-player-zhuzhenplay",
|
|
83
|
+
title: "\u9010\u5E27\u64AD\u653E"
|
|
88
84
|
})), leftMidExtContents);
|
|
89
85
|
}
|
|
90
86
|
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import Api from '../api';
|
|
3
2
|
interface IRightBarProps {
|
|
4
|
-
container?: HTMLElement;
|
|
5
3
|
visibel?: boolean;
|
|
6
|
-
api: Api;
|
|
7
|
-
video?: HTMLVideoElement;
|
|
8
|
-
isLive?: boolean;
|
|
9
4
|
rightExtContents: React.ReactNode;
|
|
10
5
|
rightMidExtContents: React.ReactNode;
|
|
11
6
|
}
|
|
12
|
-
declare function RightBar({
|
|
7
|
+
declare function RightBar({ rightExtContents, rightMidExtContents }: IRightBarProps): JSX.Element;
|
|
13
8
|
export default RightBar;
|
|
@@ -10,16 +10,19 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
10
10
|
|
|
11
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
12
|
|
|
13
|
-
import React from 'react';
|
|
13
|
+
import React, { useContext } from 'react';
|
|
14
14
|
import IconFont from '../iconfont';
|
|
15
15
|
import Bar from './bar';
|
|
16
16
|
import useFullscreen from '../../useFullscreen';
|
|
17
|
+
import { Context } from '../context';
|
|
17
18
|
|
|
18
19
|
function RightBar(_ref) {
|
|
19
|
-
var
|
|
20
|
-
rightExtContents = _ref.rightExtContents,
|
|
20
|
+
var rightExtContents = _ref.rightExtContents,
|
|
21
21
|
rightMidExtContents = _ref.rightMidExtContents;
|
|
22
22
|
|
|
23
|
+
var _useContext = useContext(Context),
|
|
24
|
+
container = _useContext.container;
|
|
25
|
+
|
|
23
26
|
var _useFullscreen = useFullscreen(container),
|
|
24
27
|
_useFullscreen2 = _slicedToArray(_useFullscreen, 2),
|
|
25
28
|
isFullScreen = _useFullscreen2[0],
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
|
|
3
|
+
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."); }
|
|
4
|
+
|
|
5
|
+
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); }
|
|
6
|
+
|
|
7
|
+
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; }
|
|
8
|
+
|
|
9
|
+
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; }
|
|
10
|
+
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
|
|
13
|
+
import React, { useContext } from 'react';
|
|
14
|
+
import { Context } from '../context';
|
|
15
|
+
import { useTimes } from '../timeline';
|
|
16
|
+
import { timeStamp } from '../util';
|
|
17
|
+
|
|
18
|
+
function Time() {
|
|
19
|
+
var _useContext = useContext(Context),
|
|
20
|
+
api = _useContext.api,
|
|
21
|
+
event = _useContext.event,
|
|
22
|
+
isFpsPlay = _useContext.isFpsPlay;
|
|
23
|
+
|
|
24
|
+
var _useTimes = useTimes(api, event, isFpsPlay),
|
|
25
|
+
_useTimes2 = _slicedToArray(_useTimes, 3),
|
|
26
|
+
current = _useTimes2[0],
|
|
27
|
+
duration = _useTimes2[2];
|
|
28
|
+
|
|
29
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
30
|
+
className: "video-time-progress"
|
|
31
|
+
}, timeStamp(current), "/", timeStamp(duration || 0));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default Time;
|
|
@@ -10,7 +10,8 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
10
10
|
|
|
11
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { useState } from 'react';
|
|
14
|
+
import { useRegisterPlayerEvents } from '../event';
|
|
14
15
|
import EventName from '../event/eventName';
|
|
15
16
|
|
|
16
17
|
function useBarStatus(event) {
|
|
@@ -19,33 +20,25 @@ function useBarStatus(event) {
|
|
|
19
20
|
}),
|
|
20
21
|
_useState2 = _slicedToArray(_useState, 2),
|
|
21
22
|
state = _useState2[0],
|
|
22
|
-
setState = _useState2[1];
|
|
23
|
+
setState = _useState2[1];
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return Object.assign(Object.assign({}, old), {
|
|
29
|
-
status: 1
|
|
30
|
-
});
|
|
25
|
+
var show = function show() {
|
|
26
|
+
return setState(function (old) {
|
|
27
|
+
return Object.assign(Object.assign({}, old), {
|
|
28
|
+
status: 1
|
|
31
29
|
});
|
|
32
|
-
};
|
|
30
|
+
});
|
|
31
|
+
};
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
33
|
+
var hide = function hide() {
|
|
34
|
+
return setState(function (old) {
|
|
35
|
+
return Object.assign(Object.assign({}, old), {
|
|
36
|
+
status: 0
|
|
39
37
|
});
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return function () {
|
|
45
|
-
event.off(EventName.SHOW_CONTRALLER, show);
|
|
46
|
-
event.off(EventName.HIDE_CONTRALLER, hide);
|
|
47
|
-
};
|
|
48
|
-
}, []);
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
useRegisterPlayerEvents(event, [[EventName.SHOW_CONTRALLER, show], [EventName.HIDE_CONTRALLER, hide]]);
|
|
49
42
|
return state.status;
|
|
50
43
|
}
|
|
51
44
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type Api from '../api';
|
|
3
|
+
import '../style/volume.less';
|
|
4
|
+
declare function Volume({ api, style }: {
|
|
5
|
+
api: Api;
|
|
6
|
+
style?: React.CSSProperties;
|
|
7
|
+
}): JSX.Element;
|
|
8
|
+
declare const _default: React.MemoExoticComponent<typeof Volume>;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import "antd/lib/slider/style";
|
|
2
|
+
import _Slider from "antd/lib/slider";
|
|
3
|
+
import "antd/lib/tooltip/style";
|
|
4
|
+
import _Tooltip from "antd/lib/tooltip";
|
|
5
|
+
import _useUpdateEffect from "ahooks/es/useUpdateEffect";
|
|
6
|
+
import _useUpdate from "ahooks/es/useUpdate";
|
|
7
|
+
|
|
8
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
+
|
|
10
|
+
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."); }
|
|
11
|
+
|
|
12
|
+
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); }
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
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; }
|
|
17
|
+
|
|
18
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
19
|
+
|
|
20
|
+
import React, { useMemo, useState } from 'react';
|
|
21
|
+
import IconFont from '../iconfont';
|
|
22
|
+
import "../style/volume.css";
|
|
23
|
+
|
|
24
|
+
function Volume(_ref) {
|
|
25
|
+
var api = _ref.api,
|
|
26
|
+
style = _ref.style;
|
|
27
|
+
|
|
28
|
+
var _a;
|
|
29
|
+
|
|
30
|
+
var _useState = useState(Math.round((_a = api === null || api === void 0 ? void 0 : api.getVolume()) !== null && _a !== void 0 ? _a : 0 * 100)),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
val = _useState2[0],
|
|
33
|
+
setVal = _useState2[1];
|
|
34
|
+
|
|
35
|
+
var update = _useUpdate(); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
var volume = useMemo(function () {
|
|
39
|
+
return (api === null || api === void 0 ? void 0 : api.muted) ? 0 : val;
|
|
40
|
+
}, undefined);
|
|
41
|
+
|
|
42
|
+
var onChange = function onChange(num) {
|
|
43
|
+
if (api === null || api === void 0 ? void 0 : api.muted) {
|
|
44
|
+
api === null || api === void 0 ? void 0 : api.unmute();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
setVal(num);
|
|
48
|
+
update();
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
var toggleMuted = function toggleMuted() {
|
|
52
|
+
if (!api) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (api.muted) {
|
|
57
|
+
api.unmute();
|
|
58
|
+
setVal(100);
|
|
59
|
+
} else {
|
|
60
|
+
api.mute();
|
|
61
|
+
setVal(0);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
update();
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
_useUpdateEffect(function () {
|
|
68
|
+
return api === null || api === void 0 ? void 0 : api.setVolume(val / 100);
|
|
69
|
+
}, [val]);
|
|
70
|
+
|
|
71
|
+
return /*#__PURE__*/React.createElement(_Tooltip, {
|
|
72
|
+
showArrow: false,
|
|
73
|
+
overlayClassName: "lm-player-volume-popup",
|
|
74
|
+
title: /*#__PURE__*/React.createElement(_Slider, {
|
|
75
|
+
onChange: onChange,
|
|
76
|
+
vertical: true,
|
|
77
|
+
value: val
|
|
78
|
+
})
|
|
79
|
+
}, /*#__PURE__*/React.createElement(IconFont, {
|
|
80
|
+
style: style,
|
|
81
|
+
type: volume !== 0 ? 'lm-player-volume-open' : 'lm-player-volume-close',
|
|
82
|
+
onClick: toggleMuted
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export default /*#__PURE__*/React.memo(Volume);
|
package/es/Player/demo.js
CHANGED
|
@@ -117,6 +117,8 @@ function Demo1() {
|
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
}, "\u64AD\u653E")), /*#__PURE__*/React.createElement(Player, {
|
|
120
|
+
fpsDelay: 800,
|
|
121
|
+
oneFpsPlay: true,
|
|
120
122
|
type: state.type,
|
|
121
123
|
url: state.url,
|
|
122
124
|
isLive: !!state.isLive,
|
|
@@ -214,6 +216,7 @@ function Demo2() {
|
|
|
214
216
|
});
|
|
215
217
|
}
|
|
216
218
|
}, "\u64AD\u653E")), /*#__PURE__*/React.createElement(SegmentPlayer, {
|
|
219
|
+
oneFpsPlay: true,
|
|
217
220
|
begin: mm.valueOf(),
|
|
218
221
|
segments: state.segments,
|
|
219
222
|
isLive: false
|
|
@@ -278,7 +281,8 @@ function Demo3() {
|
|
|
278
281
|
url: "".concat(old.url, "?").concat(time)
|
|
279
282
|
});
|
|
280
283
|
});
|
|
281
|
-
}
|
|
284
|
+
},
|
|
285
|
+
type: "native"
|
|
282
286
|
}));
|
|
283
287
|
}
|
|
284
288
|
|
|
@@ -22,6 +22,7 @@ import { useState, useEffect, useRef } from 'react';
|
|
|
22
22
|
import EventName from './eventName';
|
|
23
23
|
import Flvjs from '@cloud-app-dev/flv.js';
|
|
24
24
|
import Hls from 'hls.js';
|
|
25
|
+
import { useRegisterPlayerEvent, useVideoEvent } from '.';
|
|
25
26
|
|
|
26
27
|
function useErrorEvent(_ref) {
|
|
27
28
|
var event = _ref.event,
|
|
@@ -40,64 +41,54 @@ function useErrorEvent(_ref) {
|
|
|
40
41
|
|
|
41
42
|
var errorInfo = useRef(null);
|
|
42
43
|
var reloadTimer = useRef(null);
|
|
43
|
-
useEffect(function () {
|
|
44
|
-
var errorHandle = function errorHandle() {
|
|
45
|
-
var _console;
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
45
|
+
var errorHandle = function errorHandle() {
|
|
46
|
+
var _console;
|
|
50
47
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
49
|
+
args[_key] = arguments[_key];
|
|
50
|
+
}
|
|
54
51
|
|
|
55
|
-
|
|
52
|
+
if (args[2] && args[2].msg && args[2].msg.includes('Unsupported audio')) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
56
55
|
|
|
57
|
-
|
|
56
|
+
(_console = console).error.apply(_console, args);
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
setErrorTime(errorTimer + 1);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
58
|
+
errorInfo.current = args;
|
|
63
59
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
clearErrorTimer();
|
|
69
|
-
}
|
|
70
|
-
};
|
|
60
|
+
if (!(errorHandleAdapter === null || errorHandleAdapter === void 0 ? void 0 : errorHandleAdapter(args))) {
|
|
61
|
+
setErrorTime(errorTimer + 1);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
71
64
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
var clearErrorTimer = function clearErrorTimer() {
|
|
66
|
+
return setErrorTime(0);
|
|
67
|
+
};
|
|
75
68
|
|
|
69
|
+
var reloadSuccess = function reloadSuccess() {
|
|
70
|
+
if (errorTimer > 0) {
|
|
71
|
+
console.warn('视频重连成功!');
|
|
72
|
+
event.emit(EventName.RELOAD_SUCCESS);
|
|
73
|
+
clearErrorTimer();
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
useVideoEvent('error', errorHandle);
|
|
78
|
+
useVideoEvent('canplay', reloadSuccess);
|
|
79
|
+
useRegisterPlayerEvent(EventName.ERROR, errorHandle);
|
|
80
|
+
useRegisterPlayerEvent(EventName.CLEAR_ERROR_TIMER, clearErrorTimer);
|
|
81
|
+
useEffect(function () {
|
|
76
82
|
if (flv) {
|
|
77
83
|
flv.on(Flvjs.Events.ERROR, errorHandle);
|
|
78
84
|
}
|
|
79
85
|
|
|
80
86
|
if (hls) {
|
|
81
87
|
hls.on(Hls.Events.ERROR, errorHandle);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (event) {
|
|
85
|
-
event.on(EventName.ERROR, errorHandle);
|
|
86
|
-
event.on(EventName.CLEAR_ERROR_TIMER, clearErrorTimer);
|
|
87
|
-
event.addEventListener('error', errorHandle); //获取video状态清除错误状态
|
|
88
|
-
|
|
89
|
-
event.addEventListener('canplay', reloadSuccess);
|
|
90
|
-
}
|
|
88
|
+
} //事件销毁由flv、hls销毁时控制
|
|
89
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
90
|
|
|
92
|
-
|
|
93
|
-
// flv, hls事件不用主动销毁,库内部自己处理
|
|
94
|
-
if (event) {
|
|
95
|
-
event.off(EventName.ERROR, errorHandle);
|
|
96
|
-
event.removeEventListener('error', errorHandle);
|
|
97
|
-
event.removeEventListener('canplay', reloadSuccess);
|
|
98
|
-
}
|
|
99
|
-
}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
100
|
-
}, [event, flv, hls, errorTimer]);
|
|
91
|
+
}, [flv, hls]);
|
|
101
92
|
useEffect(function () {
|
|
102
93
|
if (errorTimer === 0) {
|
|
103
94
|
return undefined;
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare const Events: {
|
|
2
|
+
RELOAD: string;
|
|
3
|
+
RELOAD_FAIL: string;
|
|
4
|
+
RELOAD_SUCCESS: string;
|
|
5
|
+
ERROR: string;
|
|
6
|
+
ERROR_RELOAD: string;
|
|
7
|
+
HISTORY_PLAY_END: string;
|
|
8
|
+
PLAY_ENDED: string;
|
|
9
|
+
SEEK: string;
|
|
10
|
+
TRANSFORM: string;
|
|
11
|
+
CHANGE_PLAY_INDEX: string;
|
|
12
|
+
HIDE_CONTRALLER: string;
|
|
13
|
+
SHOW_CONTRALLER: string;
|
|
14
|
+
CLEAR_ERROR_TIMER: string;
|
|
15
|
+
CANVAS_PAUSE: string;
|
|
16
|
+
CANVAS_PLAY: string;
|
|
17
|
+
};
|
|
3
18
|
export default Events;
|
|
@@ -5,11 +5,15 @@ var Events = {
|
|
|
5
5
|
ERROR: 'error',
|
|
6
6
|
ERROR_RELOAD: 'errorRload',
|
|
7
7
|
HISTORY_PLAY_END: 'historyPlayEnd',
|
|
8
|
+
PLAY_ENDED: 'play_ended',
|
|
8
9
|
SEEK: 'seek',
|
|
9
10
|
TRANSFORM: 'transform',
|
|
10
11
|
CHANGE_PLAY_INDEX: 'changePlayIndex',
|
|
11
12
|
HIDE_CONTRALLER: 'hideContraller',
|
|
12
13
|
SHOW_CONTRALLER: 'showContraller',
|
|
13
|
-
CLEAR_ERROR_TIMER: 'clearErrorTimer'
|
|
14
|
+
CLEAR_ERROR_TIMER: 'clearErrorTimer',
|
|
15
|
+
CANVAS_PAUSE: 'canvasPause',
|
|
16
|
+
CANVAS_PLAY: 'canvasPlay' //逐帧播放
|
|
17
|
+
|
|
14
18
|
};
|
|
15
19
|
export default Events;
|
|
@@ -17,6 +17,8 @@ declare class VideoEventInstance {
|
|
|
17
17
|
}
|
|
18
18
|
declare type PlayEvent = VideoEventInstance;
|
|
19
19
|
export declare function usePlayerEvent(video: HTMLVideoElement): PlayEvent;
|
|
20
|
+
export declare function useVideoEvent(eventName: string, handle: (event: any) => void, context?: VideoEventInstance): void;
|
|
21
|
+
export declare function useRegisterPlayerEvent(eventName: string, handle: (event: any) => void, context?: VideoEventInstance): void;
|
|
20
22
|
export declare function useVideoEvents(event: VideoEventInstance, events: CustomEvent[]): void;
|
|
21
23
|
export declare function useRegisterPlayerEvents(event: VideoEventInstance, events: CustomEvent[]): void;
|
|
22
24
|
export default VideoEventInstance;
|
package/es/Player/event/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _useLatest from "ahooks/es/useLatest";
|
|
1
2
|
import _nextTick from "@cloud-app-dev/utils/es/nextTick";
|
|
2
3
|
|
|
3
4
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
@@ -18,7 +19,8 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
18
19
|
|
|
19
20
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
20
21
|
|
|
21
|
-
import { useEffect, useState } from 'react';
|
|
22
|
+
import { useContext, useEffect, useMemo, useState } from 'react';
|
|
23
|
+
import { Context } from '../context';
|
|
22
24
|
|
|
23
25
|
var VideoEventInstance = /*#__PURE__*/function () {
|
|
24
26
|
function VideoEventInstance(video) {
|
|
@@ -128,6 +130,56 @@ export function usePlayerEvent(video) {
|
|
|
128
130
|
}, [video]);
|
|
129
131
|
return event;
|
|
130
132
|
}
|
|
133
|
+
export function useVideoEvent(eventName, handle, context) {
|
|
134
|
+
var ctx = useContext(Context);
|
|
135
|
+
var event = useMemo(function () {
|
|
136
|
+
var _a;
|
|
137
|
+
|
|
138
|
+
return (_a = ctx === null || ctx === void 0 ? void 0 : ctx.event) !== null && _a !== void 0 ? _a : context;
|
|
139
|
+
}, [context, ctx === null || ctx === void 0 ? void 0 : ctx.event]);
|
|
140
|
+
|
|
141
|
+
var handlerRef = _useLatest(handle);
|
|
142
|
+
|
|
143
|
+
useEffect(function () {
|
|
144
|
+
if (!event) {
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
var eventListener = function eventListener(event) {
|
|
149
|
+
return handlerRef.current(event);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
event.addEventListener(eventName, eventListener);
|
|
153
|
+
return function () {
|
|
154
|
+
event.removeEventListener(eventName, eventListener);
|
|
155
|
+
}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
156
|
+
}, [event, eventName]);
|
|
157
|
+
}
|
|
158
|
+
export function useRegisterPlayerEvent(eventName, handle, context) {
|
|
159
|
+
var ctx = useContext(Context);
|
|
160
|
+
var event = useMemo(function () {
|
|
161
|
+
var _a;
|
|
162
|
+
|
|
163
|
+
return (_a = ctx === null || ctx === void 0 ? void 0 : ctx.event) !== null && _a !== void 0 ? _a : context;
|
|
164
|
+
}, [context, ctx === null || ctx === void 0 ? void 0 : ctx.event]);
|
|
165
|
+
|
|
166
|
+
var handlerRef = _useLatest(handle);
|
|
167
|
+
|
|
168
|
+
useEffect(function () {
|
|
169
|
+
if (!event) {
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
var eventListener = function eventListener(event) {
|
|
174
|
+
return handlerRef.current(event);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
event.on(eventName, eventListener);
|
|
178
|
+
return function () {
|
|
179
|
+
event.off(eventName, eventListener);
|
|
180
|
+
}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
181
|
+
}, [event, eventName]);
|
|
182
|
+
}
|
|
131
183
|
export function useVideoEvents(event, events) {
|
|
132
184
|
useEffect(function () {
|
|
133
185
|
if (!event || !events) {
|
|
@@ -149,7 +201,7 @@ export function useVideoEvents(event, events) {
|
|
|
149
201
|
|
|
150
202
|
event.removeEventListener(eventName, handle);
|
|
151
203
|
});
|
|
152
|
-
};
|
|
204
|
+
}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
153
205
|
}, [event]);
|
|
154
206
|
}
|
|
155
207
|
export function useRegisterPlayerEvents(event, events) {
|
|
@@ -173,7 +225,7 @@ export function useRegisterPlayerEvents(event, events) {
|
|
|
173
225
|
|
|
174
226
|
event.off(eventName, handle);
|
|
175
227
|
});
|
|
176
|
-
};
|
|
228
|
+
}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
177
229
|
}, [event]);
|
|
178
230
|
}
|
|
179
231
|
export default VideoEventInstance;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type Api from './api';
|
|
3
|
+
import type VideoEventInstance from './event';
|
|
4
|
+
interface IFPSPlay {
|
|
5
|
+
api: Api;
|
|
6
|
+
event: VideoEventInstance;
|
|
7
|
+
fpsDelay?: number;
|
|
8
|
+
fps?: number;
|
|
9
|
+
}
|
|
10
|
+
declare function FPSPlay({ api, event, fpsDelay, fps }: IFPSPlay): JSX.Element;
|
|
11
|
+
export default FPSPlay;
|