@cloud-app-dev/vidc 4.0.8 → 4.0.9
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/.dumirc.ts +0 -10
- package/.fatherrc.ts +1 -4
- package/es/AppContext/Sync.js +10 -24
- package/es/AppContext/index.js +19 -19
- package/es/AppContext/static.js +0 -6
- package/es/Auth/index.js +2 -5
- package/es/AutoExit/index.js +2 -2
- package/es/CheckGroupFixed/demo.js +0 -2
- package/es/CheckGroupFixed/index.js +25 -42
- package/es/CustomRenderSelect/index.js +2 -2
- package/es/DisableMark/index.js +2 -2
- package/es/DomMove/index.js +31 -42
- package/es/DomMove/utils.js +3 -8
- package/es/Drag/DragAndDropItem.js +28 -45
- package/es/Drag/DropItem.js +11 -21
- package/es/DynamicGridList/Demo.js +1 -13
- package/es/DynamicList/demo.js +1 -10
- package/es/DynamicList/index.js +27 -41
- package/es/ErrorFallback/index.js +1 -3
- package/es/EventTools/index.d.ts +3 -0
- package/es/EventTools/index.js +12 -0
- package/es/GridList/Demo.js +5 -18
- package/es/GridList/utils.js +0 -1
- package/es/HightLevel/index.js +1 -5
- package/es/IconFont/index.js +9 -18
- package/es/InstanceHistory/index.js +0 -2
- package/es/ListWithSizeAnimate/index.js +15 -31
- package/es/LoaderScript/index.js +10 -21
- package/es/LoaderScript/utils.js +2 -2
- package/es/Map/BasicMap/AMapInstance.js +6 -16
- package/es/Map/BasicMap/LeafletInstance.js +16 -26
- package/es/Map/ClusterLayer/hook.js +16 -38
- package/es/Map/ClusterLayer/index.js +2 -6
- package/es/Map/Context/index.js +6 -30
- package/es/Map/FindPio/index.js +0 -2
- package/es/Map/LevelCenter/DragMarker/index.js +6 -9
- package/es/Map/LevelCenter/demo.js +12 -21
- package/es/Map/LevelCenter/index.js +8 -14
- package/es/Map/LoaderMap/index.js +14 -17
- package/es/Map/MapDrawSelect/demo.js +14 -25
- package/es/Map/MapDrawSelect/index.js +14 -20
- package/es/Map/MouseTool/index.js +17 -27
- package/es/Map/MouseTool/useMouseTools.js +12 -35
- package/es/Map/ResetTools/index.js +4 -8
- package/es/Map/SinglePoint/index.js +6 -13
- package/es/Map/hook/useMapEvent.js +3 -7
- package/es/Map/hook/useMapType.js +1 -2
- package/es/Map/useMarker/index.js +17 -30
- package/es/Map/withMap/index.js +4 -6
- package/es/Picture/component/DefaultRects/RectInfo.js +13 -27
- package/es/Picture/component/DefaultRects/index.js +7 -10
- package/es/Picture/component/DrawRect/index.js +10 -13
- package/es/Picture/component/RectMenu/index.js +10 -15
- package/es/Picture/component/RectMenu/utils.js +3 -6
- package/es/Picture/component/WheelScale/index.js +3 -5
- package/es/Picture/loadCaptureRectImage.js +42 -61
- package/es/Picture/useDraw.js +23 -39
- package/es/Player/api/index.js +2 -2
- package/es/Player/context.js +5 -9
- package/es/Player/contraller_bar/bar.js +9 -16
- package/es/Player/contraller_bar/contraller_event.js +7 -25
- package/es/Player/contraller_bar/index.js +7 -9
- package/es/Player/contraller_bar/left_bar.js +17 -29
- package/es/Player/contraller_bar/time.js +5 -14
- package/es/Player/contraller_bar/useBarStatus.js +12 -24
- package/es/Player/contraller_bar/volume.js +9 -29
- package/es/Player/event/eventName.js +1 -1
- package/es/Player/event/index.js +28 -63
- package/es/Player/frontend_player.js +16 -27
- package/es/Player/iconfont.js +6 -12
- package/es/Player/live_heart.js +2 -18
- package/es/Player/message.js +15 -35
- package/es/Player/segment_player.js +48 -86
- package/es/Player/timeline.js +19 -41
- package/es/PlayerExt/demo.js +15 -25
- package/es/PlayerExt/index.js +29 -51
- package/es/ROI/demo.js +0 -2
- package/es/ScreenPlayer/Record.js +1 -1
- package/es/ScreenPlayer/TimeMode.js +1 -3
- package/es/ScreenPlayer/useTimeSlider.js +3 -3
- package/es/SocketEmitter/eventEmitter.d.ts +27 -0
- package/es/SocketEmitter/eventEmitter.js +87 -0
- package/es/SocketEmitter/index.d.ts +24 -0
- package/es/SocketEmitter/index.js +125 -0
- package/es/SocketEmitter/interface.d.ts +4 -0
- package/es/ThemeAntd/demo.js +0 -2
- package/es/VList/utils.js +2 -3
- package/es/bigNumberTransformCN/index.d.ts +5 -0
- package/es/bigNumberTransformCN/index.js +60 -0
- package/es/cache/index.d.ts +34 -0
- package/es/cache/index.js +94 -0
- package/es/copy/index.d.ts +1 -0
- package/es/copy/index.js +9 -0
- package/es/getThemeStyle/index.d.ts +2 -0
- package/es/getThemeStyle/index.js +5 -0
- package/es/index.d.ts +11 -0
- package/es/index.js +12 -1
- package/es/logger/index.d.ts +7 -0
- package/es/logger/index.js +30 -0
- package/es/nextTick/index.d.ts +1 -0
- package/es/nextTick/index.js +7 -0
- package/es/submidstr/index.d.ts +5 -0
- package/es/submidstr/index.js +14 -0
- package/es/treeHelper/index.d.ts +11 -0
- package/es/treeHelper/index.js +173 -0
- package/es/useEventEmitterHandle/index.js +5 -9
- package/es/useFullscreen/demo.js +8 -18
- package/es/useFullscreen/index.js +7 -28
- package/es/useHistory/index.js +0 -2
- package/es/useRafInterval/index.js +3 -27
- package/es/useSimpleState/index.js +11 -22
- package/es/useVirtualList/index.js +21 -57
- package/es/utils.js +2 -2
- package/es/uuid/index.d.ts +4 -0
- package/es/uuid/index.js +15 -0
- package/package.json +1 -2
|
@@ -1,82 +1,65 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
1
2
|
import _useUpdate from "ahooks/es/useUpdate";
|
|
2
3
|
import _useLatest from "ahooks/es/useLatest";
|
|
3
4
|
var _excluded = ["segments", "begin", "forwordRef", "defaultIndex", "onCanPlayerInit", "customTimeLine"];
|
|
4
|
-
|
|
5
5
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
6
|
-
|
|
7
6
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
8
|
-
|
|
9
7
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
-
|
|
11
8
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
12
|
-
|
|
13
|
-
function
|
|
14
|
-
|
|
9
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
11
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
12
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
16
|
-
|
|
17
13
|
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."); }
|
|
18
|
-
|
|
19
14
|
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); }
|
|
20
|
-
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
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; }
|
|
24
|
-
|
|
15
|
+
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; }
|
|
16
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
25
17
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
26
|
-
|
|
27
18
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
28
19
|
import { useRegisterPlayerEvent, useVideoEvent } from "./event";
|
|
29
20
|
import Events from "./event/eventName";
|
|
30
21
|
import SegmentTimeLine from "./segment_timeline";
|
|
31
22
|
import SinglePlayer from "./single_player";
|
|
23
|
+
|
|
32
24
|
/**
|
|
33
25
|
* @desc 计算第一个url
|
|
34
26
|
* @param segments
|
|
35
27
|
* @param defaultIndex
|
|
36
28
|
* @returns
|
|
37
29
|
*/
|
|
38
|
-
|
|
39
30
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
40
31
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
41
|
-
|
|
42
32
|
function getFirstUrlIndex(segments) {
|
|
43
33
|
var defaultIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
44
|
-
|
|
45
34
|
if (!(Array.isArray(segments) && segments.length > 0)) {
|
|
46
35
|
return defaultIndex;
|
|
47
36
|
}
|
|
48
|
-
|
|
49
37
|
if (segments[defaultIndex].url) {
|
|
50
38
|
return defaultIndex;
|
|
51
39
|
} else {
|
|
52
40
|
var i = defaultIndex + 1;
|
|
53
|
-
|
|
54
41
|
if (i > segments.length) {
|
|
55
42
|
return i;
|
|
56
43
|
}
|
|
57
|
-
|
|
58
44
|
return getFirstUrlIndex(segments, i);
|
|
59
45
|
}
|
|
60
46
|
}
|
|
47
|
+
|
|
61
48
|
/**
|
|
62
49
|
* @desc 片段索引控制
|
|
63
50
|
* @param event
|
|
64
51
|
* @param segments
|
|
65
52
|
* @returns
|
|
66
53
|
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
54
|
function usePlayIndex(event, segments) {
|
|
70
55
|
var defaultIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
71
|
-
|
|
72
56
|
var _useState = useState({
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
57
|
+
index: getFirstUrlIndex(segments !== null && segments !== void 0 ? segments : [], defaultIndex)
|
|
58
|
+
}),
|
|
59
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
60
|
+
state = _useState2[0],
|
|
61
|
+
setState = _useState2[1];
|
|
62
|
+
// 片段发生变化重新开始计算索引
|
|
80
63
|
useEffect(function () {
|
|
81
64
|
var index = getFirstUrlIndex(segments !== null && segments !== void 0 ? segments : [], 0);
|
|
82
65
|
setState(function (old) {
|
|
@@ -84,11 +67,11 @@ function usePlayIndex(event, segments) {
|
|
|
84
67
|
index: index
|
|
85
68
|
});
|
|
86
69
|
});
|
|
87
|
-
}, [segments]);
|
|
70
|
+
}, [segments]);
|
|
88
71
|
|
|
72
|
+
// 索引不存在播放地址,自动跳转下一段
|
|
89
73
|
useEffect(function () {
|
|
90
74
|
var _segments$state$index, _segments$length;
|
|
91
|
-
|
|
92
75
|
if (!(segments !== null && segments !== void 0 && (_segments$state$index = segments[state.index]) !== null && _segments$state$index !== void 0 && _segments$state$index.url) && state.index < ((_segments$length = segments === null || segments === void 0 ? void 0 : segments.length) !== null && _segments$length !== void 0 ? _segments$length : 0) - 1) {
|
|
93
76
|
setState(function (old) {
|
|
94
77
|
return _objectSpread(_objectSpread({}, old), {}, {
|
|
@@ -96,18 +79,17 @@ function usePlayIndex(event, segments) {
|
|
|
96
79
|
});
|
|
97
80
|
});
|
|
98
81
|
}
|
|
99
|
-
}, [segments, state.index]);
|
|
82
|
+
}, [segments, state.index]);
|
|
100
83
|
|
|
84
|
+
// 监听片段播放状态,自动跳转下一个片段
|
|
101
85
|
var endHandle = function endHandle() {
|
|
102
86
|
return setState(function (old) {
|
|
103
87
|
var _segments$length2;
|
|
104
|
-
|
|
105
88
|
return _objectSpread(_objectSpread({}, old), {}, {
|
|
106
89
|
index: old.index + 1 < ((_segments$length2 = segments === null || segments === void 0 ? void 0 : segments.length) !== null && _segments$length2 !== void 0 ? _segments$length2 : 0) ? old.index + 1 : old.index
|
|
107
90
|
});
|
|
108
91
|
});
|
|
109
92
|
};
|
|
110
|
-
|
|
111
93
|
useVideoEvent('ended', endHandle, event);
|
|
112
94
|
useRegisterPlayerEvent(Events.PLAY_ENDED, endHandle, event);
|
|
113
95
|
return {
|
|
@@ -121,40 +103,33 @@ function usePlayIndex(event, segments) {
|
|
|
121
103
|
}
|
|
122
104
|
};
|
|
123
105
|
}
|
|
106
|
+
|
|
124
107
|
/**
|
|
125
108
|
* @desc 主组件,负责片段整体逻辑控制
|
|
126
109
|
* @param param0
|
|
127
110
|
* @returns
|
|
128
111
|
*/
|
|
129
|
-
|
|
130
|
-
|
|
131
112
|
function SegmentPlayer(_ref) {
|
|
132
113
|
var segments = _ref.segments,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
114
|
+
begin = _ref.begin,
|
|
115
|
+
forwordRef = _ref.forwordRef,
|
|
116
|
+
defaultIndex = _ref.defaultIndex,
|
|
117
|
+
onCanPlayerInit = _ref.onCanPlayerInit,
|
|
118
|
+
customTimeLine = _ref.customTimeLine,
|
|
119
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
140
120
|
var _useState3 = useState({
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
121
|
+
seekTime: 0
|
|
122
|
+
}),
|
|
123
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
124
|
+
state = _useState4[0],
|
|
125
|
+
setState = _useState4[1];
|
|
147
126
|
var latestSegmentsRef = _useLatest(segments);
|
|
148
|
-
|
|
149
127
|
var update = _useUpdate();
|
|
150
|
-
|
|
151
128
|
var ref = useRef(null);
|
|
152
129
|
var playRef = forwordRef ? forwordRef : ref;
|
|
153
|
-
|
|
154
130
|
var _ref2 = playRef.current || {},
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
131
|
+
api = _ref2.api,
|
|
132
|
+
event = _ref2.event;
|
|
158
133
|
var duration = useMemo(function () {
|
|
159
134
|
return segments === null || segments === void 0 ? void 0 : segments.map(function (v) {
|
|
160
135
|
return (v.endTime - v.beginTime) / 1000;
|
|
@@ -162,55 +137,45 @@ function SegmentPlayer(_ref) {
|
|
|
162
137
|
return a + b;
|
|
163
138
|
}, 0);
|
|
164
139
|
}, [segments]);
|
|
165
|
-
|
|
166
140
|
var _usePlayIndex = usePlayIndex(event, segments, defaultIndex),
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
141
|
+
index = _usePlayIndex.index,
|
|
142
|
+
setIndex = _usePlayIndex.setIndex;
|
|
170
143
|
var url = useMemo(function () {
|
|
171
144
|
return segments !== null && segments !== void 0 && segments[index] ? segments[index].url : undefined;
|
|
172
|
-
}, [segments, index]);
|
|
173
|
-
|
|
145
|
+
}, [segments, index]);
|
|
146
|
+
// 重置reload
|
|
174
147
|
var reload = function reload() {
|
|
175
148
|
var _playRef$current$plug, _playRef$current, _playRef$current2, _playRef$current3, _playRef$current4;
|
|
176
|
-
|
|
177
149
|
var _ref3 = (_playRef$current$plug = (_playRef$current = playRef.current) === null || _playRef$current === void 0 ? void 0 : _playRef$current.plugins) !== null && _playRef$current$plug !== void 0 ? _playRef$current$plug : [],
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
150
|
+
_ref4 = _slicedToArray(_ref3, 2),
|
|
151
|
+
hls = _ref4[1];
|
|
181
152
|
if (hls) {
|
|
182
153
|
hls.swapAudioCodec();
|
|
183
154
|
hls.recoverMediaError();
|
|
184
155
|
}
|
|
185
|
-
|
|
186
156
|
(_playRef$current2 = playRef.current) === null || _playRef$current2 === void 0 ? void 0 : _playRef$current2.event.emit(Events.RELOAD);
|
|
187
157
|
(_playRef$current3 = playRef.current) === null || _playRef$current3 === void 0 ? void 0 : _playRef$current3.event.emit(Events.CLEAR_ERROR_TIMER);
|
|
188
158
|
setIndex(0);
|
|
189
159
|
(_playRef$current4 = playRef.current) === null || _playRef$current4 === void 0 ? void 0 : _playRef$current4.api.reload();
|
|
190
|
-
};
|
|
191
|
-
|
|
160
|
+
};
|
|
192
161
|
|
|
162
|
+
// time 毫秒的时间戳
|
|
193
163
|
var seekTo = function seekTo(time) {
|
|
194
164
|
var _latestSegmentsRef$cu, _playRef$current$plug2, _playRef$current5, _cSegments$index;
|
|
195
|
-
|
|
196
165
|
var cSegments = (_latestSegmentsRef$cu = latestSegmentsRef.current) !== null && _latestSegmentsRef$cu !== void 0 ? _latestSegmentsRef$cu : [];
|
|
197
166
|
var index = cSegments.findIndex(function (v) {
|
|
198
167
|
return time >= v.beginTime && time < v.endTime;
|
|
199
168
|
});
|
|
200
|
-
|
|
201
169
|
if (index === -1) {
|
|
202
170
|
return;
|
|
203
171
|
}
|
|
204
|
-
|
|
205
172
|
var _ref5 = (_playRef$current$plug2 = (_playRef$current5 = playRef.current) === null || _playRef$current5 === void 0 ? void 0 : _playRef$current5.plugins) !== null && _playRef$current$plug2 !== void 0 ? _playRef$current$plug2 : [],
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
173
|
+
_ref6 = _slicedToArray(_ref5, 2),
|
|
174
|
+
hls = _ref6[1];
|
|
209
175
|
if (hls) {
|
|
210
176
|
hls.swapAudioCodec();
|
|
211
177
|
hls.recoverMediaError();
|
|
212
178
|
}
|
|
213
|
-
|
|
214
179
|
var currentTime = time - ((_cSegments$index = cSegments[index]) === null || _cSegments$index === void 0 ? void 0 : _cSegments$index.beginTime);
|
|
215
180
|
setIndex(index);
|
|
216
181
|
setState(function (old) {
|
|
@@ -218,26 +183,23 @@ function SegmentPlayer(_ref) {
|
|
|
218
183
|
seekTime: currentTime / 1000
|
|
219
184
|
});
|
|
220
185
|
});
|
|
221
|
-
};
|
|
222
|
-
|
|
186
|
+
};
|
|
223
187
|
|
|
188
|
+
// 处理seek 后index变化后 cuurenttime变化的过程
|
|
224
189
|
useEffect(function () {
|
|
225
190
|
var _playRef$current6;
|
|
226
|
-
|
|
227
191
|
if (state.seekTime === 0) {
|
|
228
192
|
return;
|
|
229
193
|
}
|
|
230
|
-
|
|
231
194
|
setState(function (old) {
|
|
232
195
|
return _objectSpread(_objectSpread({}, old), {}, {
|
|
233
196
|
seekTime: 0
|
|
234
197
|
});
|
|
235
198
|
});
|
|
236
|
-
|
|
237
199
|
if ((_playRef$current6 = playRef.current) !== null && _playRef$current6 !== void 0 && _playRef$current6.video) {
|
|
238
200
|
playRef.current.video.currentTime = state.seekTime;
|
|
239
|
-
}
|
|
240
|
-
|
|
201
|
+
}
|
|
202
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
241
203
|
}, [state.seekTime]);
|
|
242
204
|
var hasReady = api && event;
|
|
243
205
|
var timeline = customTimeLine !== null && customTimeLine !== void 0 ? customTimeLine : /*#__PURE__*/_jsx(SegmentTimeLine, {
|
|
@@ -249,7 +211,8 @@ function SegmentPlayer(_ref) {
|
|
|
249
211
|
});
|
|
250
212
|
var onInit = useCallback(function () {
|
|
251
213
|
update();
|
|
252
|
-
onCanPlayerInit === null || onCanPlayerInit === void 0 ? void 0 : onCanPlayerInit();
|
|
214
|
+
onCanPlayerInit === null || onCanPlayerInit === void 0 ? void 0 : onCanPlayerInit();
|
|
215
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
253
216
|
}, []);
|
|
254
217
|
return /*#__PURE__*/_jsx(SinglePlayer, _objectSpread({
|
|
255
218
|
ref: playRef,
|
|
@@ -264,5 +227,4 @@ function SegmentPlayer(_ref) {
|
|
|
264
227
|
customTimeLine: hasReady ? timeline : /*#__PURE__*/_jsx(_Fragment, {})
|
|
265
228
|
}, props));
|
|
266
229
|
}
|
|
267
|
-
|
|
268
230
|
export default SegmentPlayer;
|
package/es/Player/timeline.js
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
1
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
-
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
7
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
-
|
|
9
8
|
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."); }
|
|
10
|
-
|
|
11
9
|
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); }
|
|
12
|
-
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
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; }
|
|
16
|
-
|
|
10
|
+
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; }
|
|
11
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
17
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
-
|
|
19
13
|
import React, { useContext, useMemo, useState } from 'react';
|
|
20
14
|
import { Context } from "./context";
|
|
21
15
|
import useBarStatus from "./contraller_bar/useBarStatus";
|
|
@@ -25,81 +19,66 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
25
19
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
26
20
|
export function useTimes() {
|
|
27
21
|
var _useContext = useContext(Context),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
api = _useContext.api,
|
|
23
|
+
isFpsPlay = _useContext.isFpsPlay;
|
|
31
24
|
var _useState = useState({
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
currentTime: 0,
|
|
26
|
+
buffered: 0
|
|
27
|
+
}),
|
|
28
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29
|
+
state = _useState2[0],
|
|
30
|
+
setState = _useState2[1];
|
|
39
31
|
var getCurrentTime = function getCurrentTime() {
|
|
40
32
|
return setState(function (old) {
|
|
41
33
|
var _api$getCurrentTime, _api$getSecondsLoaded;
|
|
42
|
-
|
|
43
34
|
return _objectSpread(_objectSpread({}, old), {}, {
|
|
44
35
|
currentTime: (_api$getCurrentTime = api === null || api === void 0 ? void 0 : api.getCurrentTime()) !== null && _api$getCurrentTime !== void 0 ? _api$getCurrentTime : 0,
|
|
45
36
|
buffered: (_api$getSecondsLoaded = api === null || api === void 0 ? void 0 : api.getSecondsLoaded()) !== null && _api$getSecondsLoaded !== void 0 ? _api$getSecondsLoaded : 0
|
|
46
37
|
});
|
|
47
38
|
});
|
|
48
39
|
};
|
|
49
|
-
|
|
50
40
|
var getBuffered = function getBuffered() {
|
|
51
41
|
return setState(function (old) {
|
|
52
42
|
var _api$getSecondsLoaded2;
|
|
53
|
-
|
|
54
43
|
return _objectSpread(_objectSpread({}, old), {}, {
|
|
55
44
|
buffered: (_api$getSecondsLoaded2 = api === null || api === void 0 ? void 0 : api.getSecondsLoaded()) !== null && _api$getSecondsLoaded2 !== void 0 ? _api$getSecondsLoaded2 : 0
|
|
56
45
|
});
|
|
57
46
|
});
|
|
58
47
|
};
|
|
59
|
-
|
|
60
48
|
var seekendPlay = function seekendPlay() {
|
|
61
49
|
return !isFpsPlay && (api === null || api === void 0 ? void 0 : api.play());
|
|
62
50
|
};
|
|
63
|
-
|
|
64
51
|
useVideoEvent('timeupdate', getCurrentTime);
|
|
65
52
|
useVideoEvent('progress', getBuffered);
|
|
66
53
|
useVideoEvent('suspend', getBuffered);
|
|
67
54
|
useVideoEvent('seeked', seekendPlay);
|
|
68
55
|
return useMemo(function () {
|
|
69
56
|
var _api$getDuration;
|
|
70
|
-
|
|
71
57
|
return [state.currentTime, state.buffered, (_api$getDuration = api === null || api === void 0 ? void 0 : api.getDuration()) !== null && _api$getDuration !== void 0 ? _api$getDuration : 0];
|
|
72
58
|
}, [state.currentTime, state.buffered, api]);
|
|
73
59
|
}
|
|
74
|
-
|
|
75
60
|
function TimeLine() {
|
|
76
61
|
var _useContext2 = useContext(Context),
|
|
77
|
-
|
|
78
|
-
|
|
62
|
+
api = _useContext2.api;
|
|
79
63
|
var status = useBarStatus();
|
|
80
|
-
|
|
81
64
|
var _useTimes = useTimes(),
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
65
|
+
_useTimes2 = _slicedToArray(_useTimes, 3),
|
|
66
|
+
currentTime = _useTimes2[0],
|
|
67
|
+
buffered = _useTimes2[1],
|
|
68
|
+
duration = _useTimes2[2];
|
|
87
69
|
var playPercent = useMemo(function () {
|
|
88
70
|
return currentTime / duration * 100;
|
|
89
71
|
}, [currentTime, duration]);
|
|
90
72
|
var bufferedPercent = useMemo(function () {
|
|
91
73
|
return buffered / duration * 100;
|
|
92
74
|
}, [buffered, duration]);
|
|
93
|
-
|
|
94
75
|
var seekWithLine = function seekWithLine(e) {
|
|
95
76
|
var _api$getDuration2;
|
|
96
|
-
|
|
97
77
|
var rect = e.currentTarget.getBoundingClientRect();
|
|
98
78
|
var current = e.pageX - rect.left;
|
|
99
79
|
var cTime = current / rect.width * ((_api$getDuration2 = api === null || api === void 0 ? void 0 : api.getDuration()) !== null && _api$getDuration2 !== void 0 ? _api$getDuration2 : 0);
|
|
100
80
|
api === null || api === void 0 ? void 0 : api.seekTo(cTime);
|
|
101
81
|
};
|
|
102
|
-
|
|
103
82
|
return /*#__PURE__*/_jsxs("div", {
|
|
104
83
|
className: "player-timeline-layout ".concat(status === 0 ? 'hide-time-line' : ''),
|
|
105
84
|
onClick: seekWithLine,
|
|
@@ -116,5 +95,4 @@ function TimeLine() {
|
|
|
116
95
|
})]
|
|
117
96
|
});
|
|
118
97
|
}
|
|
119
|
-
|
|
120
98
|
export default TimeLine;
|
package/es/PlayerExt/demo.js
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
1
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
-
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
7
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
-
|
|
9
8
|
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."); }
|
|
10
|
-
|
|
11
9
|
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); }
|
|
12
|
-
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
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; }
|
|
16
|
-
|
|
10
|
+
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; }
|
|
11
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
17
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
-
|
|
19
13
|
import React, { useState } from 'react';
|
|
20
14
|
import { Button, ConfigProvider, Select, Input } from 'antd';
|
|
21
15
|
import Player from "../Player/single_player";
|
|
@@ -39,20 +33,18 @@ var options2 = [{
|
|
|
39
33
|
value: 0,
|
|
40
34
|
label: '录像'
|
|
41
35
|
}];
|
|
42
|
-
|
|
43
36
|
//http://192.168.101.162:14088/flv/live/1853e2a5c3308bd62/2.flv?device_id=&channel_id=1853e2a5c3308bd62&stream_index=2&ip=0
|
|
44
37
|
function Demo() {
|
|
45
38
|
var _useState = useState({
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
39
|
+
type: undefined,
|
|
40
|
+
isLive: 1,
|
|
41
|
+
url: '',
|
|
42
|
+
tempUrl: '',
|
|
43
|
+
mode: 1
|
|
44
|
+
}),
|
|
45
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
46
|
+
state = _useState2[0],
|
|
47
|
+
setState = _useState2[1];
|
|
56
48
|
return /*#__PURE__*/_jsxs("div", {
|
|
57
49
|
style: {
|
|
58
50
|
width: '100%',
|
|
@@ -169,12 +161,10 @@ function Demo() {
|
|
|
169
161
|
})]
|
|
170
162
|
});
|
|
171
163
|
}
|
|
172
|
-
|
|
173
164
|
var App = function App() {
|
|
174
165
|
return /*#__PURE__*/_jsx(ConfigProvider, {
|
|
175
166
|
prefixCls: "cloudapp",
|
|
176
167
|
children: /*#__PURE__*/_jsx(Demo, {})
|
|
177
168
|
});
|
|
178
169
|
};
|
|
179
|
-
|
|
180
170
|
export default App;
|