@cloud-app-dev/vidc 4.0.7 → 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/single_player.js +1 -1
- 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/RatePick.js +8 -10
- package/es/ScreenPlayer/Record.js +11 -32
- package/es/ScreenPlayer/TimeMode.js +1 -3
- package/es/ScreenPlayer/useTimeSlider.js +3 -3
- package/es/ScreenPlayer/useVideoFit.js +8 -21
- 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 +4 -5
package/es/Player/event/index.js
CHANGED
|
@@ -1,44 +1,30 @@
|
|
|
1
1
|
import _useLatest from "ahooks/es/useLatest";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
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); }
|
|
4
3
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
5
|
-
|
|
6
4
|
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."); }
|
|
7
|
-
|
|
8
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); }
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
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; }
|
|
13
|
-
|
|
6
|
+
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; }
|
|
7
|
+
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; } }
|
|
14
8
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
|
-
|
|
16
9
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
|
-
|
|
18
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
19
|
-
|
|
10
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
20
11
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
12
|
+
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; }
|
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
|
+
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); }
|
|
24
15
|
import { useContext, useEffect, useMemo, useState } from 'react';
|
|
16
|
+
import nextTick from "../../nextTick";
|
|
25
17
|
import { Context } from "../context";
|
|
26
|
-
|
|
27
18
|
var VideoEventInstance = /*#__PURE__*/function () {
|
|
28
19
|
function VideoEventInstance(video) {
|
|
29
20
|
_classCallCheck(this, VideoEventInstance);
|
|
30
|
-
|
|
31
21
|
_defineProperty(this, "video", void 0);
|
|
32
|
-
|
|
33
22
|
_defineProperty(this, "events", void 0);
|
|
34
|
-
|
|
35
23
|
_defineProperty(this, "playerEvents", void 0);
|
|
36
|
-
|
|
37
24
|
this.video = video;
|
|
38
25
|
this.events = {};
|
|
39
26
|
this.playerEvents = {};
|
|
40
27
|
}
|
|
41
|
-
|
|
42
28
|
_createClass(VideoEventInstance, [{
|
|
43
29
|
key: "on",
|
|
44
30
|
value: function on(eventName, handle) {
|
|
@@ -62,7 +48,6 @@ var VideoEventInstance = /*#__PURE__*/function () {
|
|
|
62
48
|
if (!this.playerEvents || !this.playerEvents[eventName]) {
|
|
63
49
|
return;
|
|
64
50
|
}
|
|
65
|
-
|
|
66
51
|
var index = this.playerEvents[eventName].findIndex(function (v) {
|
|
67
52
|
return v === handle;
|
|
68
53
|
});
|
|
@@ -76,11 +61,9 @@ var VideoEventInstance = /*#__PURE__*/function () {
|
|
|
76
61
|
for (var _len = arguments.length, data = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
77
62
|
data[_key - 1] = arguments[_key];
|
|
78
63
|
}
|
|
79
|
-
|
|
80
64
|
if (!this.events || !this.events[eventName]) {
|
|
81
65
|
return;
|
|
82
66
|
}
|
|
83
|
-
|
|
84
67
|
this.events[eventName].listener.forEach(function (v) {
|
|
85
68
|
v.apply(void 0, data);
|
|
86
69
|
});
|
|
@@ -91,7 +74,6 @@ var VideoEventInstance = /*#__PURE__*/function () {
|
|
|
91
74
|
if (!this.events || !this.events.eventName) {
|
|
92
75
|
return;
|
|
93
76
|
}
|
|
94
|
-
|
|
95
77
|
var index = this.events[eventName].listener.findIndex(function (v) {
|
|
96
78
|
return v === handle;
|
|
97
79
|
});
|
|
@@ -101,7 +83,6 @@ var VideoEventInstance = /*#__PURE__*/function () {
|
|
|
101
83
|
key: "destroy",
|
|
102
84
|
value: function destroy() {
|
|
103
85
|
var _this = this;
|
|
104
|
-
|
|
105
86
|
Object.keys(this.playerEvents).forEach(function (key) {
|
|
106
87
|
_this.playerEvents[key].forEach(function (fn) {
|
|
107
88
|
_this.removeEventListener(key, fn);
|
|
@@ -112,26 +93,22 @@ var VideoEventInstance = /*#__PURE__*/function () {
|
|
|
112
93
|
this.video = null;
|
|
113
94
|
}
|
|
114
95
|
}]);
|
|
115
|
-
|
|
116
96
|
return VideoEventInstance;
|
|
117
97
|
}();
|
|
118
|
-
|
|
119
98
|
export function usePlayerEvent(video) {
|
|
120
99
|
var _useState = useState(undefined),
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
100
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
101
|
+
event = _useState2[0],
|
|
102
|
+
setEvent = _useState2[1];
|
|
125
103
|
useEffect(function () {
|
|
126
104
|
if (!video) {
|
|
127
105
|
console.debug('wait create event...');
|
|
128
106
|
return undefined;
|
|
129
107
|
}
|
|
130
|
-
|
|
131
108
|
var event = new VideoEventInstance(video);
|
|
132
109
|
setEvent(event);
|
|
133
110
|
return function () {
|
|
134
|
-
return
|
|
111
|
+
return nextTick(function () {
|
|
135
112
|
return event.destroy();
|
|
136
113
|
});
|
|
137
114
|
};
|
|
@@ -142,50 +119,42 @@ export function useVideoEvent(eventName, handle, context) {
|
|
|
142
119
|
var ctx = useContext(Context);
|
|
143
120
|
var event = useMemo(function () {
|
|
144
121
|
var _ctx$event;
|
|
145
|
-
|
|
146
122
|
return (_ctx$event = ctx === null || ctx === void 0 ? void 0 : ctx.event) !== null && _ctx$event !== void 0 ? _ctx$event : context;
|
|
147
123
|
}, [context, ctx === null || ctx === void 0 ? void 0 : ctx.event]);
|
|
148
|
-
|
|
149
124
|
var handlerRef = _useLatest(handle);
|
|
150
|
-
|
|
151
125
|
useEffect(function () {
|
|
152
126
|
if (!event) {
|
|
153
127
|
return undefined;
|
|
154
128
|
}
|
|
155
|
-
|
|
156
129
|
var eventListener = function eventListener(event) {
|
|
157
130
|
return handlerRef.current(event);
|
|
158
131
|
};
|
|
159
|
-
|
|
160
132
|
event.addEventListener(eventName, eventListener);
|
|
161
133
|
return function () {
|
|
162
134
|
event.removeEventListener(eventName, eventListener);
|
|
163
|
-
};
|
|
135
|
+
};
|
|
136
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
164
137
|
}, [event, eventName]);
|
|
165
138
|
}
|
|
166
139
|
export function useRegisterPlayerEvent(eventName, handle, context) {
|
|
167
140
|
var ctx = useContext(Context);
|
|
168
141
|
var event = useMemo(function () {
|
|
169
142
|
var _ctx$event2;
|
|
170
|
-
|
|
171
143
|
return (_ctx$event2 = ctx === null || ctx === void 0 ? void 0 : ctx.event) !== null && _ctx$event2 !== void 0 ? _ctx$event2 : context;
|
|
172
144
|
}, [context, ctx === null || ctx === void 0 ? void 0 : ctx.event]);
|
|
173
|
-
|
|
174
145
|
var handlerRef = _useLatest(handle);
|
|
175
|
-
|
|
176
146
|
useEffect(function () {
|
|
177
147
|
if (!event) {
|
|
178
148
|
return undefined;
|
|
179
149
|
}
|
|
180
|
-
|
|
181
150
|
var eventListener = function eventListener(event) {
|
|
182
151
|
return handlerRef.current(event);
|
|
183
152
|
};
|
|
184
|
-
|
|
185
153
|
event.on(eventName, eventListener);
|
|
186
154
|
return function () {
|
|
187
155
|
event.off(eventName, eventListener);
|
|
188
|
-
};
|
|
156
|
+
};
|
|
157
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
189
158
|
}, [event, eventName]);
|
|
190
159
|
}
|
|
191
160
|
export function useVideoEvents(event, events) {
|
|
@@ -193,23 +162,21 @@ export function useVideoEvents(event, events) {
|
|
|
193
162
|
if (!event || !events) {
|
|
194
163
|
return undefined;
|
|
195
164
|
}
|
|
196
|
-
|
|
197
165
|
events.forEach(function (_ref) {
|
|
198
166
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
167
|
+
eventName = _ref2[0],
|
|
168
|
+
handle = _ref2[1];
|
|
202
169
|
event.addEventListener(eventName, handle);
|
|
203
170
|
});
|
|
204
171
|
return function () {
|
|
205
172
|
events.forEach(function (_ref3) {
|
|
206
173
|
var _ref4 = _slicedToArray(_ref3, 2),
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
174
|
+
eventName = _ref4[0],
|
|
175
|
+
handle = _ref4[1];
|
|
210
176
|
event.removeEventListener(eventName, handle);
|
|
211
177
|
});
|
|
212
|
-
};
|
|
178
|
+
};
|
|
179
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
213
180
|
}, [event]);
|
|
214
181
|
}
|
|
215
182
|
export function useRegisterPlayerEvents(event, events) {
|
|
@@ -217,23 +184,21 @@ export function useRegisterPlayerEvents(event, events) {
|
|
|
217
184
|
if (!event || !events) {
|
|
218
185
|
return undefined;
|
|
219
186
|
}
|
|
220
|
-
|
|
221
187
|
events.forEach(function (_ref5) {
|
|
222
188
|
var _ref6 = _slicedToArray(_ref5, 2),
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
189
|
+
eventName = _ref6[0],
|
|
190
|
+
handle = _ref6[1];
|
|
226
191
|
event.on(eventName, handle);
|
|
227
192
|
});
|
|
228
193
|
return function () {
|
|
229
194
|
events.forEach(function (_ref7) {
|
|
230
195
|
var _ref8 = _slicedToArray(_ref7, 2),
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
196
|
+
eventName = _ref8[0],
|
|
197
|
+
handle = _ref8[1];
|
|
234
198
|
event.off(eventName, handle);
|
|
235
199
|
});
|
|
236
|
-
};
|
|
200
|
+
};
|
|
201
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
237
202
|
}, [event]);
|
|
238
203
|
}
|
|
239
204
|
export default VideoEventInstance;
|
|
@@ -1,67 +1,57 @@
|
|
|
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 _useMemoizedFn from "ahooks/es/useMemoizedFn";
|
|
2
3
|
import _useUpdate from "ahooks/es/useUpdate";
|
|
3
4
|
var _excluded = ["url", "begin", "end", "onSeek", "forwordRef", "customTimeLine", "onCanPlayerInit"];
|
|
4
|
-
|
|
5
5
|
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; }
|
|
6
|
-
|
|
7
6
|
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; }
|
|
8
|
-
|
|
9
|
-
function
|
|
10
|
-
|
|
7
|
+
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; }
|
|
8
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
9
|
+
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); }
|
|
11
10
|
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; }
|
|
12
|
-
|
|
13
11
|
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; }
|
|
14
|
-
|
|
15
12
|
import React, { useMemo, useRef } from 'react';
|
|
16
13
|
import Events from "./event/eventName";
|
|
17
14
|
import FrontendTimeLine from "./frontend_timeline";
|
|
18
15
|
import SinglePlayer from "./single_player";
|
|
16
|
+
|
|
19
17
|
/**
|
|
20
18
|
* @desc 主组件,负责片段整体逻辑控制
|
|
21
19
|
* @return JSX.Element
|
|
22
20
|
*/
|
|
23
|
-
|
|
24
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
22
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
26
|
-
|
|
27
23
|
function FrontendPlayer(_ref) {
|
|
28
24
|
var url = _ref.url,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
begin = _ref.begin,
|
|
26
|
+
end = _ref.end,
|
|
27
|
+
onSeek = _ref.onSeek,
|
|
28
|
+
forwordRef = _ref.forwordRef,
|
|
29
|
+
customTimeLine = _ref.customTimeLine,
|
|
30
|
+
onCanPlayerInit = _ref.onCanPlayerInit,
|
|
31
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
37
32
|
var update = _useUpdate();
|
|
38
|
-
|
|
39
33
|
var ref = useRef(null);
|
|
40
34
|
var playRef = forwordRef ? forwordRef : ref;
|
|
41
|
-
|
|
42
35
|
var _ref2 = playRef.current || {},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
api = _ref2.api,
|
|
37
|
+
event = _ref2.event;
|
|
46
38
|
|
|
39
|
+
// 转换毫秒
|
|
47
40
|
var duration = useMemo(function () {
|
|
48
41
|
return (end !== null && end !== void 0 ? end : 0 - (begin !== null && begin !== void 0 ? begin : 0)) / 1000;
|
|
49
42
|
}, [begin, end]); //单位s 秒
|
|
50
|
-
// 重置reload
|
|
51
43
|
|
|
44
|
+
// 重置reload
|
|
52
45
|
var reload = _useMemoizedFn(function () {
|
|
53
46
|
var _playRef$current, _playRef$current2;
|
|
54
|
-
|
|
55
47
|
(_playRef$current = playRef.current) === null || _playRef$current === void 0 ? void 0 : _playRef$current.event.emit(Events.RELOAD);
|
|
56
48
|
onSeek === null || onSeek === void 0 ? void 0 : onSeek(begin);
|
|
57
49
|
(_playRef$current2 = playRef.current) === null || _playRef$current2 === void 0 ? void 0 : _playRef$current2.api.reload();
|
|
58
50
|
});
|
|
59
|
-
|
|
60
51
|
var onInit = _useMemoizedFn(function () {
|
|
61
52
|
update();
|
|
62
53
|
onCanPlayerInit === null || onCanPlayerInit === void 0 ? void 0 : onCanPlayerInit();
|
|
63
54
|
});
|
|
64
|
-
|
|
65
55
|
var hasReady = api && event;
|
|
66
56
|
var timeline = customTimeLine !== null && customTimeLine !== void 0 ? customTimeLine : /*#__PURE__*/_jsx(FrontendTimeLine, {
|
|
67
57
|
end: end !== null && end !== void 0 ? end : 0,
|
|
@@ -79,5 +69,4 @@ function FrontendPlayer(_ref) {
|
|
|
79
69
|
customTimeLine: hasReady ? timeline : /*#__PURE__*/_jsx(_Fragment, {})
|
|
80
70
|
}, props));
|
|
81
71
|
}
|
|
82
|
-
|
|
83
72
|
export default FrontendPlayer;
|
package/es/Player/iconfont.js
CHANGED
|
@@ -1,28 +1,22 @@
|
|
|
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
|
var _excluded = ["className"];
|
|
2
|
-
|
|
3
3
|
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; }
|
|
4
|
-
|
|
5
4
|
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; }
|
|
6
|
-
|
|
7
|
-
function
|
|
8
|
-
|
|
5
|
+
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; }
|
|
6
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
|
+
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); }
|
|
9
8
|
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; }
|
|
10
|
-
|
|
11
9
|
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; }
|
|
12
|
-
|
|
13
10
|
import React from 'react';
|
|
14
11
|
import Icon from "../IconFont";
|
|
15
12
|
import "./style/iconfont.js";
|
|
16
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
-
|
|
18
14
|
function IconFont(_ref) {
|
|
19
15
|
var _ref$className = _ref.className,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
17
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
23
18
|
return /*#__PURE__*/_jsx(Icon, _objectSpread({
|
|
24
19
|
className: "lm-player-iconfont ".concat(className)
|
|
25
20
|
}, props));
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
export default IconFont;
|
package/es/Player/live_heart.js
CHANGED
|
@@ -3,60 +3,44 @@ import _useUpdateEffect from "ahooks/es/useUpdateEffect";
|
|
|
3
3
|
import _useDocumentVisibility from "ahooks/es/useDocumentVisibility";
|
|
4
4
|
import { useRef } from 'react';
|
|
5
5
|
import Events from "./event/eventName";
|
|
6
|
-
|
|
7
6
|
function useLiveHeart(_ref) {
|
|
8
7
|
var api = _ref.api,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
event = _ref.event,
|
|
9
|
+
isLive = _ref.isLive;
|
|
12
10
|
var documentVisibility = _useDocumentVisibility();
|
|
13
|
-
|
|
14
11
|
var cTimeRef = useRef(0);
|
|
15
|
-
|
|
16
12
|
var run = function run() {
|
|
17
13
|
var _api$getCurrentTime;
|
|
18
|
-
|
|
19
14
|
if (!isLive || documentVisibility !== 'visible' || !api) {
|
|
20
15
|
return;
|
|
21
16
|
}
|
|
22
|
-
|
|
23
17
|
var current = (_api$getCurrentTime = api.getCurrentTime()) !== null && _api$getCurrentTime !== void 0 ? _api$getCurrentTime : 0;
|
|
24
18
|
var buffered = api.getSecondsLoaded();
|
|
25
|
-
|
|
26
19
|
if (buffered - current > 5) {
|
|
27
20
|
console.debug("\u5F53\u524D\u5EF6\u65F6\u8FC7\u5927current->".concat(current, " buffered->").concat(buffered, ", \u57FA\u4E8E\u89C6\u9891\u5F53\u524D\u7F13\u5B58\u65F6\u95F4\u66F4\u65B0\u5F53\u524D\u64AD\u653E\u65F6\u95F4 updateTime -> ").concat(buffered - 2));
|
|
28
21
|
api.seekTo(buffered - 2 > 0 ? buffered - 2 : 0);
|
|
29
22
|
api.play();
|
|
30
23
|
}
|
|
31
24
|
};
|
|
32
|
-
|
|
33
25
|
_useUpdateEffect(function () {
|
|
34
26
|
return run();
|
|
35
27
|
}, [documentVisibility]);
|
|
36
|
-
|
|
37
28
|
_useRafInterval(function () {
|
|
38
29
|
var _api$getCurrentTime2;
|
|
39
|
-
|
|
40
30
|
return cTimeRef.current = (_api$getCurrentTime2 = api === null || api === void 0 ? void 0 : api.getCurrentTime()) !== null && _api$getCurrentTime2 !== void 0 ? _api$getCurrentTime2 : 0;
|
|
41
31
|
}, 1 * 1000);
|
|
42
|
-
|
|
43
32
|
_useRafInterval(function () {
|
|
44
33
|
return run();
|
|
45
34
|
}, 30 * 1000);
|
|
46
|
-
|
|
47
35
|
_useRafInterval(function () {
|
|
48
36
|
var _api$video;
|
|
49
|
-
|
|
50
37
|
if (!api || !event) {
|
|
51
38
|
return;
|
|
52
39
|
}
|
|
53
|
-
|
|
54
40
|
var cuurentTime = api.getCurrentTime();
|
|
55
|
-
|
|
56
41
|
if (!!isLive && !((_api$video = api.video) !== null && _api$video !== void 0 && _api$video.paused) && cuurentTime === cTimeRef.current) {
|
|
57
42
|
event.emit(Events.ERROR);
|
|
58
43
|
}
|
|
59
44
|
}, 20 * 1000);
|
|
60
45
|
}
|
|
61
|
-
|
|
62
46
|
export default useLiveHeart;
|
package/es/Player/message.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, useRef, useState } from 'react';
|
|
20
14
|
import { Context } from "./context";
|
|
21
15
|
import { useRegisterPlayerEvent, useVideoEvent } from "./event";
|
|
@@ -24,35 +18,29 @@ import IconFont from "./iconfont";
|
|
|
24
18
|
import "./style/message.less";
|
|
25
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
20
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
|
-
|
|
28
21
|
function VideoMessage() {
|
|
29
22
|
var _useContext = useContext(Context),
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
api = _useContext.api;
|
|
32
24
|
var _useState = useState({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
25
|
+
status: null,
|
|
26
|
+
errorTimer: 1,
|
|
27
|
+
loading: false
|
|
28
|
+
}),
|
|
29
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
30
|
+
state = _useState2[0],
|
|
31
|
+
setState = _useState2[1];
|
|
41
32
|
var timeRef = useRef();
|
|
42
33
|
var message = useMemo(function () {
|
|
43
34
|
if (state.status === 'fail') {
|
|
44
35
|
console.warn("\u89C6\u9891\u9519\u8BEF\uFF0C\u8BF7\u624B\u52A8\u5237\u65B0\u91CD\u8BD5\uFF01");
|
|
45
36
|
return '请稍后重试!';
|
|
46
37
|
}
|
|
47
|
-
|
|
48
38
|
if (state.status === 'reload') {
|
|
49
39
|
console.warn("\u7B2C".concat(state.errorTimer, "\u6B21\u91CD\u8FDE"));
|
|
50
40
|
return "\u6B63\u5728\u5237\u65B0...";
|
|
51
41
|
}
|
|
52
|
-
|
|
53
42
|
return '';
|
|
54
43
|
}, [state.errorTimer, state.status]);
|
|
55
|
-
|
|
56
44
|
var openLoading = function openLoading() {
|
|
57
45
|
clearTimeout(timeRef.current);
|
|
58
46
|
timeRef.current = setTimeout(function () {
|
|
@@ -63,7 +51,6 @@ function VideoMessage() {
|
|
|
63
51
|
});
|
|
64
52
|
}, 200);
|
|
65
53
|
};
|
|
66
|
-
|
|
67
54
|
var closeLoading = function closeLoading() {
|
|
68
55
|
clearTimeout(timeRef.current);
|
|
69
56
|
setState(function (old) {
|
|
@@ -72,7 +59,6 @@ function VideoMessage() {
|
|
|
72
59
|
});
|
|
73
60
|
});
|
|
74
61
|
};
|
|
75
|
-
|
|
76
62
|
var errorReload = function errorReload(timer) {
|
|
77
63
|
clearTimeout(timeRef.current);
|
|
78
64
|
setState(function () {
|
|
@@ -83,7 +69,6 @@ function VideoMessage() {
|
|
|
83
69
|
};
|
|
84
70
|
});
|
|
85
71
|
};
|
|
86
|
-
|
|
87
72
|
var reloadFail = function reloadFail() {
|
|
88
73
|
return setState(function (old) {
|
|
89
74
|
return _objectSpread(_objectSpread({}, old), {}, {
|
|
@@ -91,7 +76,6 @@ function VideoMessage() {
|
|
|
91
76
|
});
|
|
92
77
|
});
|
|
93
78
|
};
|
|
94
|
-
|
|
95
79
|
var reloadSuccess = function reloadSuccess() {
|
|
96
80
|
return setState(function (old) {
|
|
97
81
|
return _objectSpread(_objectSpread({}, old), {}, {
|
|
@@ -99,7 +83,6 @@ function VideoMessage() {
|
|
|
99
83
|
});
|
|
100
84
|
});
|
|
101
85
|
};
|
|
102
|
-
|
|
103
86
|
var reload = function reload() {
|
|
104
87
|
return setState(function (old) {
|
|
105
88
|
return _objectSpread(_objectSpread({}, old), {}, {
|
|
@@ -108,7 +91,6 @@ function VideoMessage() {
|
|
|
108
91
|
});
|
|
109
92
|
});
|
|
110
93
|
};
|
|
111
|
-
|
|
112
94
|
var playEnd = function playEnd() {
|
|
113
95
|
clearTimeout(timeRef.current);
|
|
114
96
|
setState(function (old) {
|
|
@@ -119,7 +101,6 @@ function VideoMessage() {
|
|
|
119
101
|
});
|
|
120
102
|
api === null || api === void 0 ? void 0 : api.pause();
|
|
121
103
|
};
|
|
122
|
-
|
|
123
104
|
useVideoEvent('loadstart', openLoading);
|
|
124
105
|
useVideoEvent('loadeddata', closeLoading);
|
|
125
106
|
useVideoEvent('canplay', closeLoading);
|
|
@@ -130,7 +111,7 @@ function VideoMessage() {
|
|
|
130
111
|
useRegisterPlayerEvent(EventName.HISTORY_PLAY_END, playEnd);
|
|
131
112
|
useRegisterPlayerEvent(EventName.CLEAR_ERROR_TIMER, reloadSuccess);
|
|
132
113
|
var loading = state.loading,
|
|
133
|
-
|
|
114
|
+
status = state.status;
|
|
134
115
|
return /*#__PURE__*/_jsxs("div", {
|
|
135
116
|
className: "lm-player-message-mask ".concat(loading || status === 'fail' ? 'lm-player-mask-loading-animation' : ''),
|
|
136
117
|
children: [/*#__PURE__*/_jsx(IconFont, {
|
|
@@ -142,7 +123,6 @@ function VideoMessage() {
|
|
|
142
123
|
})]
|
|
143
124
|
});
|
|
144
125
|
}
|
|
145
|
-
|
|
146
126
|
export var NoSource = function NoSource() {
|
|
147
127
|
return /*#__PURE__*/_jsx("div", {
|
|
148
128
|
className: "lm-player-message-mask lm-player-mask-loading-animation",
|