@cloud-app-dev/vidc 3.0.1 → 3.0.2
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/es/Player/api/index.d.ts +1 -0
- package/es/Player/api/index.js +2 -0
- package/es/Player/demo.js +8 -3
- package/es/Player/frontend_player.d.ts +1 -2
- package/es/Player/frontend_player.js +25 -49
- package/es/Player/frontend_timeline.d.ts +2 -1
- package/es/Player/frontend_timeline.js +14 -4
- package/es/Player/player.d.ts +7 -9
- package/es/Player/segment_player.d.ts +1 -1
- package/es/Player/segment_player.js +31 -32
- package/es/Player/single_player.js +13 -9
- package/es/ScreenPlayer/PlayerWithExt.js +12 -25
- package/es/ScreenPlayer/Record.js +5 -9
- package/es/ScreenPlayer/TimeSlider.d.ts +1 -1
- package/es/ScreenPlayer/TimeSlider.js +28 -26
- package/es/ScreenPlayer/index.css +2 -3
- package/package.json +1 -1
- package/release-build.sh +29 -4
package/es/Player/api/index.d.ts
CHANGED
package/es/Player/api/index.js
CHANGED
package/es/Player/demo.js
CHANGED
|
@@ -197,7 +197,7 @@ function Demo2() {
|
|
|
197
197
|
|
|
198
198
|
function Demo3() {
|
|
199
199
|
var _useState5 = useState({
|
|
200
|
-
url: 'http://
|
|
200
|
+
url: 'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4',
|
|
201
201
|
tempUrl: '',
|
|
202
202
|
begin: 1652889636,
|
|
203
203
|
end: 1652890200
|
|
@@ -208,7 +208,8 @@ function Demo3() {
|
|
|
208
208
|
|
|
209
209
|
return /*#__PURE__*/React.createElement("div", {
|
|
210
210
|
style: {
|
|
211
|
-
width: '
|
|
211
|
+
width: '600px',
|
|
212
|
+
height: '400px',
|
|
212
213
|
marginTop: 20
|
|
213
214
|
}
|
|
214
215
|
}, /*#__PURE__*/React.createElement("h3", null, " \u524D\u7AEF\u5F55\u50CF\u89C6\u9891\u64AD\u653E"), /*#__PURE__*/React.createElement("div", {
|
|
@@ -247,7 +248,11 @@ function Demo3() {
|
|
|
247
248
|
end: state.end,
|
|
248
249
|
url: state.url,
|
|
249
250
|
onSeek: function onSeek(time) {
|
|
250
|
-
return
|
|
251
|
+
return setState(function (old) {
|
|
252
|
+
return Object.assign(Object.assign({}, old), {
|
|
253
|
+
url: "".concat(old.url, "?").concat(time)
|
|
254
|
+
});
|
|
255
|
+
});
|
|
251
256
|
}
|
|
252
257
|
}));
|
|
253
258
|
}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
import type { IFrontendPlayerProps } from './player';
|
|
3
3
|
/**
|
|
4
4
|
* @desc 主组件,负责片段整体逻辑控制
|
|
5
|
-
* @
|
|
6
|
-
* @returns
|
|
5
|
+
* @return JSX.Element
|
|
7
6
|
*/
|
|
8
7
|
declare function FrontendPlayer({ url, begin, end, onSeek, forwordRef, customTimeLine, onCanPlayerInit, ...props }: IFrontendPlayerProps): JSX.Element;
|
|
9
8
|
export default FrontendPlayer;
|
|
@@ -1,26 +1,14 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
1
|
+
import _useUpdate from "ahooks/es/useUpdate";
|
|
13
2
|
import { __rest } from "tslib";
|
|
14
|
-
import React, { useMemo, useRef
|
|
3
|
+
import React, { useCallback, useMemo, useRef } from 'react';
|
|
15
4
|
import SinglePlayer from './single_player';
|
|
16
5
|
import FrontendTimeLine from './frontend_timeline';
|
|
17
6
|
import Events from './event/eventName';
|
|
7
|
+
|
|
18
8
|
/**
|
|
19
9
|
* @desc 主组件,负责片段整体逻辑控制
|
|
20
|
-
* @
|
|
21
|
-
* @returns
|
|
10
|
+
* @return JSX.Element
|
|
22
11
|
*/
|
|
23
|
-
|
|
24
12
|
function FrontendPlayer(_a) {
|
|
25
13
|
var url = _a.url,
|
|
26
14
|
begin = _a.begin,
|
|
@@ -28,15 +16,10 @@ function FrontendPlayer(_a) {
|
|
|
28
16
|
onSeek = _a.onSeek,
|
|
29
17
|
forwordRef = _a.forwordRef,
|
|
30
18
|
customTimeLine = _a.customTimeLine,
|
|
31
|
-
|
|
19
|
+
onCanPlayerInit = _a.onCanPlayerInit,
|
|
32
20
|
props = __rest(_a, ["url", "begin", "end", "onSeek", "forwordRef", "customTimeLine", "onCanPlayerInit"]);
|
|
33
21
|
|
|
34
|
-
var
|
|
35
|
-
forceKey: Date.now()
|
|
36
|
-
}),
|
|
37
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
38
|
-
state = _useState2[0],
|
|
39
|
-
setState = _useState2[1];
|
|
22
|
+
var update = _useUpdate();
|
|
40
23
|
|
|
41
24
|
var ref = useRef(null);
|
|
42
25
|
var playRef = forwordRef ? forwordRef : ref;
|
|
@@ -48,10 +31,10 @@ function FrontendPlayer(_a) {
|
|
|
48
31
|
|
|
49
32
|
var beginTemp = useMemo(function () {
|
|
50
33
|
return begin ? String(begin).length === 10 ? Math.floor(begin * 1000) : begin : begin;
|
|
51
|
-
}, []);
|
|
34
|
+
}, [begin]);
|
|
52
35
|
var endTemp = useMemo(function () {
|
|
53
36
|
return end ? String(end).length === 10 ? Math.floor(end * 1000) : end : end;
|
|
54
|
-
}, []);
|
|
37
|
+
}, [end]);
|
|
55
38
|
var duration = useMemo(function () {
|
|
56
39
|
return (endTemp - beginTemp) / 1000;
|
|
57
40
|
}, [beginTemp, endTemp]); //单位s 秒
|
|
@@ -61,36 +44,29 @@ function FrontendPlayer(_a) {
|
|
|
61
44
|
playRef.current.event.emit(Events.RELOAD);
|
|
62
45
|
onSeek && onSeek(beginTemp);
|
|
63
46
|
playRef.current.api.reload();
|
|
64
|
-
setState(function (old) {
|
|
65
|
-
return Object.assign(Object.assign({}, old), {
|
|
66
|
-
forceKey: Date.now()
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
47
|
};
|
|
70
48
|
|
|
49
|
+
var onInit = useCallback(function () {
|
|
50
|
+
update();
|
|
51
|
+
onCanPlayerInit && onCanPlayerInit(); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
52
|
+
}, []);
|
|
53
|
+
var hasReady = api && event;
|
|
54
|
+
var timeline = customTimeLine !== null && customTimeLine !== void 0 ? customTimeLine : /*#__PURE__*/React.createElement(FrontendTimeLine, {
|
|
55
|
+
end: endTemp,
|
|
56
|
+
url: url,
|
|
57
|
+
onSeek: onSeek,
|
|
58
|
+
begin: beginTemp,
|
|
59
|
+
api: api,
|
|
60
|
+
event: event,
|
|
61
|
+
duration: duration
|
|
62
|
+
});
|
|
71
63
|
return /*#__PURE__*/React.createElement(SinglePlayer, Object.assign({
|
|
72
64
|
ref: playRef,
|
|
73
65
|
url: url,
|
|
74
|
-
type: "flv",
|
|
75
66
|
reload: reload,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
forceKey: Date.now()
|
|
80
|
-
});
|
|
81
|
-
_onCanPlayerInit && _onCanPlayerInit({
|
|
82
|
-
reload: reload
|
|
83
|
-
});
|
|
84
|
-
},
|
|
85
|
-
customTimeLine: api && event && (customTimeLine || /*#__PURE__*/React.createElement(FrontendTimeLine, {
|
|
86
|
-
end: endTemp,
|
|
87
|
-
onSeek: onSeek,
|
|
88
|
-
key: state.forceKey,
|
|
89
|
-
begin: beginTemp,
|
|
90
|
-
api: api,
|
|
91
|
-
event: event,
|
|
92
|
-
duration: duration
|
|
93
|
-
}))
|
|
67
|
+
onCanPlayerInit: onInit,
|
|
68
|
+
isLive: false,
|
|
69
|
+
customTimeLine: hasReady ? timeline : /*#__PURE__*/React.createElement(React.Fragment, null)
|
|
94
70
|
}, props));
|
|
95
71
|
}
|
|
96
72
|
|
|
@@ -9,6 +9,7 @@ interface ITimeLineProps {
|
|
|
9
9
|
begin: number;
|
|
10
10
|
end: number;
|
|
11
11
|
onSeek?: (time: number) => void;
|
|
12
|
+
url?: string;
|
|
12
13
|
}
|
|
13
|
-
declare function FrontendTimeLine({ api, event, duration, begin, end, onSeek }: ITimeLineProps): JSX.Element;
|
|
14
|
+
declare function FrontendTimeLine({ api, event, duration, begin, end, onSeek, url }: ITimeLineProps): JSX.Element;
|
|
14
15
|
export default FrontendTimeLine;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _useTrackedEffect from "ahooks/es/useTrackedEffect";
|
|
2
|
+
|
|
1
3
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
4
|
|
|
3
5
|
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,7 +12,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
10
12
|
|
|
11
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
14
|
|
|
13
|
-
import React, { useCallback, useEffect, useMemo, useState, startTransition } from 'react';
|
|
15
|
+
import React, { useCallback, useEffect, useMemo, useState, startTransition, useRef } from 'react';
|
|
14
16
|
import useBarStatus from './contraller_bar/useBarStatus';
|
|
15
17
|
import { useTimes } from './timeline';
|
|
16
18
|
import { FMT } from './util';
|
|
@@ -23,7 +25,9 @@ function FrontendTimeLine(_ref) {
|
|
|
23
25
|
duration = _ref.duration,
|
|
24
26
|
begin = _ref.begin,
|
|
25
27
|
end = _ref.end,
|
|
26
|
-
onSeek = _ref.onSeek
|
|
28
|
+
onSeek = _ref.onSeek,
|
|
29
|
+
url = _ref.url;
|
|
30
|
+
var lastSeekCTimeRef = useRef(0); // time 是记录seek时跳了多少
|
|
27
31
|
|
|
28
32
|
var _useState = useState({
|
|
29
33
|
time: 0,
|
|
@@ -35,14 +39,20 @@ function FrontendTimeLine(_ref) {
|
|
|
35
39
|
state = _useState2[0],
|
|
36
40
|
setState = _useState2[1];
|
|
37
41
|
|
|
38
|
-
var status = useBarStatus(event);
|
|
42
|
+
var status = useBarStatus(event); //获取视频当前播放时长单位s
|
|
39
43
|
|
|
40
44
|
var _useTimes = useTimes(api, event),
|
|
41
45
|
_useTimes2 = _slicedToArray(_useTimes, 1),
|
|
42
46
|
currentTime = _useTimes2[0];
|
|
43
47
|
|
|
48
|
+
_useTrackedEffect(function (changes) {
|
|
49
|
+
if (changes.includes(1)) {
|
|
50
|
+
lastSeekCTimeRef.current = currentTime;
|
|
51
|
+
}
|
|
52
|
+
}, [currentTime, url]);
|
|
53
|
+
|
|
44
54
|
var rTime = useMemo(function () {
|
|
45
|
-
return state.time + currentTime;
|
|
55
|
+
return state.time + currentTime + lastSeekCTimeRef.current;
|
|
46
56
|
}, [state.time, currentTime]);
|
|
47
57
|
useEffect(function () {
|
|
48
58
|
return setState(function (old) {
|
package/es/Player/player.d.ts
CHANGED
|
@@ -113,6 +113,11 @@ export interface ISinglePlayerProps {
|
|
|
113
113
|
*/
|
|
114
114
|
reload?: () => void;
|
|
115
115
|
|
|
116
|
+
/**
|
|
117
|
+
* extaction
|
|
118
|
+
*/
|
|
119
|
+
extActions?: { [key: string]: (...args: any) => void };
|
|
120
|
+
|
|
116
121
|
/**
|
|
117
122
|
* 视频可播放时执行钩子
|
|
118
123
|
*/
|
|
@@ -129,7 +134,7 @@ export interface ISinglePlayerProps {
|
|
|
129
134
|
playerEvents?: CustomEvent[];
|
|
130
135
|
}
|
|
131
136
|
|
|
132
|
-
export interface IFrontendPlayerProps extends Omit<ISinglePlayerProps, 'isLive' | 'reload'
|
|
137
|
+
export interface IFrontendPlayerProps extends Omit<ISinglePlayerProps, 'isLive' | 'reload'> {
|
|
133
138
|
/**
|
|
134
139
|
* 前端录像开始时间
|
|
135
140
|
*/
|
|
@@ -146,16 +151,9 @@ export interface IFrontendPlayerProps extends Omit<ISinglePlayerProps, 'isLive'
|
|
|
146
151
|
onSeek?: (time: number) => void;
|
|
147
152
|
|
|
148
153
|
forwordRef?: React.MutableRefObject<ExportPlayerType>;
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* 视频可播放时执行钩子
|
|
152
|
-
*/
|
|
153
|
-
onCanPlayerInit?: (data: any) => void;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
export interface ISegmentPlayerProps extends Omit<ISinglePlayerProps, 'url'
|
|
157
|
-
onCanPlayerInit?: (ext: { [key: string]: any }) => void;
|
|
158
|
-
|
|
156
|
+
export interface ISegmentPlayerProps extends Omit<ISinglePlayerProps, 'url'> {
|
|
159
157
|
/**
|
|
160
158
|
* 云录像片段信息
|
|
161
159
|
*/
|
|
@@ -5,5 +5,5 @@ import type { ISegmentPlayerProps } from './player';
|
|
|
5
5
|
* @param param0
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
declare function SegmentPlayer({ segments, begin, forwordRef,
|
|
8
|
+
declare function SegmentPlayer({ segments, begin, forwordRef, defaultIndex, onCanPlayerInit, customTimeLine, ...props }: ISegmentPlayerProps): JSX.Element;
|
|
9
9
|
export default SegmentPlayer;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _useUpdate from "ahooks/es/useUpdate";
|
|
2
|
+
|
|
1
3
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
4
|
|
|
3
5
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -19,17 +21,17 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
19
21
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
22
|
|
|
21
23
|
import { __rest } from "tslib";
|
|
22
|
-
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
24
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
23
25
|
import SinglePlayer from './single_player';
|
|
24
26
|
import SegmentTimeLine from './segment_timeline';
|
|
25
27
|
import Events from './event/eventName';
|
|
28
|
+
|
|
26
29
|
/**
|
|
27
30
|
* @desc 计算第一个url
|
|
28
31
|
* @param segments
|
|
29
32
|
* @param defaultIndex
|
|
30
33
|
* @returns
|
|
31
34
|
*/
|
|
32
|
-
|
|
33
35
|
function getFirstUrlIndex(segments) {
|
|
34
36
|
var defaultIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
35
37
|
|
|
@@ -60,7 +62,7 @@ function getFirstUrlIndex(segments) {
|
|
|
60
62
|
|
|
61
63
|
function usePlayIndex(event, segments) {
|
|
62
64
|
var defaultIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
63
|
-
var deps = arguments.length > 3 ? arguments[3] :
|
|
65
|
+
var deps = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
64
66
|
|
|
65
67
|
var _useState = useState({
|
|
66
68
|
index: getFirstUrlIndex(segments, defaultIndex)
|
|
@@ -89,7 +91,7 @@ function usePlayIndex(event, segments) {
|
|
|
89
91
|
});
|
|
90
92
|
});
|
|
91
93
|
}
|
|
92
|
-
}, [state.index]); // 监听片段播放状态,自动跳转下一个片段
|
|
94
|
+
}, [segments, state.index]); // 监听片段播放状态,自动跳转下一个片段
|
|
93
95
|
|
|
94
96
|
useEffect(function () {
|
|
95
97
|
if (!event) {
|
|
@@ -98,7 +100,7 @@ function usePlayIndex(event, segments) {
|
|
|
98
100
|
|
|
99
101
|
var fn = function fn() {
|
|
100
102
|
return setState(function (old) {
|
|
101
|
-
return Object.assign(Object.assign({},
|
|
103
|
+
return Object.assign(Object.assign({}, old), {
|
|
102
104
|
index: old.index + 1 < segments.length ? old.index + 1 : old.index
|
|
103
105
|
});
|
|
104
106
|
});
|
|
@@ -107,7 +109,7 @@ function usePlayIndex(event, segments) {
|
|
|
107
109
|
event.addEventListener('ended', fn);
|
|
108
110
|
return function () {
|
|
109
111
|
return event.removeEventListener('ended', fn);
|
|
110
|
-
};
|
|
112
|
+
}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
111
113
|
}, [event, segments].concat(_toConsumableArray(deps)));
|
|
112
114
|
return {
|
|
113
115
|
index: state.index,
|
|
@@ -131,10 +133,12 @@ function SegmentPlayer(_a) {
|
|
|
131
133
|
var segments = _a.segments,
|
|
132
134
|
begin = _a.begin,
|
|
133
135
|
forwordRef = _a.forwordRef,
|
|
134
|
-
_onCanPlayerInit = _a.onCanPlayerInit,
|
|
135
136
|
defaultIndex = _a.defaultIndex,
|
|
137
|
+
onCanPlayerInit = _a.onCanPlayerInit,
|
|
136
138
|
customTimeLine = _a.customTimeLine,
|
|
137
|
-
props = __rest(_a, ["segments", "begin", "forwordRef", "
|
|
139
|
+
props = __rest(_a, ["segments", "begin", "forwordRef", "defaultIndex", "onCanPlayerInit", "customTimeLine"]);
|
|
140
|
+
|
|
141
|
+
var update = _useUpdate();
|
|
138
142
|
|
|
139
143
|
var ref = useRef(null);
|
|
140
144
|
var playRef = forwordRef ? forwordRef : ref;
|
|
@@ -143,13 +147,6 @@ function SegmentPlayer(_a) {
|
|
|
143
147
|
api = _ref.api,
|
|
144
148
|
event = _ref.event;
|
|
145
149
|
|
|
146
|
-
var _useState3 = useState({
|
|
147
|
-
forceKey: Date.now()
|
|
148
|
-
}),
|
|
149
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
150
|
-
state = _useState4[0],
|
|
151
|
-
setState = _useState4[1];
|
|
152
|
-
|
|
153
150
|
var duration = useMemo(function () {
|
|
154
151
|
return segments === null || segments === void 0 ? void 0 : segments.map(function (v) {
|
|
155
152
|
return (v.endTime - v.beginTime) / 1000;
|
|
@@ -158,7 +155,7 @@ function SegmentPlayer(_a) {
|
|
|
158
155
|
}, 0);
|
|
159
156
|
}, [segments]);
|
|
160
157
|
|
|
161
|
-
var _usePlayIndex = usePlayIndex(event, segments, defaultIndex, [
|
|
158
|
+
var _usePlayIndex = usePlayIndex(event, segments, defaultIndex, [segments, defaultIndex]),
|
|
162
159
|
index = _usePlayIndex.index,
|
|
163
160
|
setIndex = _usePlayIndex.setIndex;
|
|
164
161
|
|
|
@@ -175,28 +172,30 @@ function SegmentPlayer(_a) {
|
|
|
175
172
|
|
|
176
173
|
var beginTemp = useMemo(function () {
|
|
177
174
|
return begin ? String(begin).length === 10 ? Math.floor(begin * 1000) : begin : begin;
|
|
175
|
+
}, [begin]);
|
|
176
|
+
var hasReady = api && event;
|
|
177
|
+
var timeline = customTimeLine !== null && customTimeLine !== void 0 ? customTimeLine : /*#__PURE__*/React.createElement(SegmentTimeLine, {
|
|
178
|
+
begin: beginTemp,
|
|
179
|
+
api: api,
|
|
180
|
+
event: event,
|
|
181
|
+
index: index,
|
|
182
|
+
segments: segments,
|
|
183
|
+
duration: duration,
|
|
184
|
+
setIndex: setIndex
|
|
185
|
+
});
|
|
186
|
+
var onInit = useCallback(function () {
|
|
187
|
+
update();
|
|
188
|
+
onCanPlayerInit && onCanPlayerInit(); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
178
189
|
}, []);
|
|
179
190
|
return /*#__PURE__*/React.createElement(SinglePlayer, Object.assign({
|
|
180
191
|
ref: playRef,
|
|
181
192
|
url: url,
|
|
193
|
+
onCanPlayerInit: onInit,
|
|
182
194
|
reload: reload,
|
|
183
|
-
|
|
184
|
-
setState({
|
|
185
|
-
forceKey: Date.now()
|
|
186
|
-
});
|
|
187
|
-
_onCanPlayerInit && _onCanPlayerInit({
|
|
188
|
-
setIndex: setIndex
|
|
189
|
-
});
|
|
190
|
-
},
|
|
191
|
-
customTimeLine: api && event && (customTimeLine || /*#__PURE__*/React.createElement(SegmentTimeLine, {
|
|
192
|
-
begin: beginTemp,
|
|
193
|
-
api: api,
|
|
194
|
-
event: event,
|
|
195
|
-
index: index,
|
|
196
|
-
segments: segments,
|
|
197
|
-
duration: duration,
|
|
195
|
+
extActions: {
|
|
198
196
|
setIndex: setIndex
|
|
199
|
-
}
|
|
197
|
+
},
|
|
198
|
+
customTimeLine: hasReady ? timeline : /*#__PURE__*/React.createElement(React.Fragment, null)
|
|
200
199
|
}, props));
|
|
201
200
|
}
|
|
202
201
|
|
|
@@ -34,7 +34,9 @@ var SinglePlayer = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
34
34
|
isLive = _a.isLive,
|
|
35
35
|
errorReloadTimer = _a.errorReloadTimer,
|
|
36
36
|
children = _a.children,
|
|
37
|
-
|
|
37
|
+
onCanPlayerInit = _a.onCanPlayerInit,
|
|
38
|
+
extActions = _a.extActions,
|
|
39
|
+
props = __rest(_a, ["className", "url", "type", "hideContrallerBar", "isLive", "errorReloadTimer", "children", "onCanPlayerInit", "extActions"]);
|
|
38
40
|
|
|
39
41
|
var autoPlay = props.autoPlay,
|
|
40
42
|
preload = props.preload,
|
|
@@ -113,11 +115,11 @@ var SinglePlayer = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
113
115
|
return undefined;
|
|
114
116
|
}
|
|
115
117
|
|
|
116
|
-
var map = {
|
|
118
|
+
var map = Object.assign({
|
|
117
119
|
reload: reload,
|
|
118
120
|
unload: unload,
|
|
119
121
|
toggleFit: toggle
|
|
120
|
-
};
|
|
122
|
+
}, extActions);
|
|
121
123
|
return new Proxy(api, {
|
|
122
124
|
get: function get(target, key) {
|
|
123
125
|
var _a;
|
|
@@ -127,7 +129,7 @@ var SinglePlayer = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
127
129
|
set: function set() {
|
|
128
130
|
return true;
|
|
129
131
|
}
|
|
130
|
-
});
|
|
132
|
+
}); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
131
133
|
}, [api]); // 代理Event
|
|
132
134
|
|
|
133
135
|
var playEvent = useMemo(function () {
|
|
@@ -154,11 +156,12 @@ var SinglePlayer = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
154
156
|
plugins: [flv, hls],
|
|
155
157
|
fit: fit
|
|
156
158
|
};
|
|
157
|
-
}, [
|
|
159
|
+
}, [video, state.container, playApi, playEvent, flv, hls, fit]);
|
|
158
160
|
useEffect(function () {
|
|
159
161
|
if (api && event && video) {
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
+
onCanPlayerInit && onCanPlayerInit();
|
|
163
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
164
|
+
|
|
162
165
|
}, [api, event, video]);
|
|
163
166
|
return /*#__PURE__*/React.createElement("div", {
|
|
164
167
|
className: "lm-player-container ".concat(className),
|
|
@@ -193,7 +196,7 @@ var SinglePlayer = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
193
196
|
leftMidExtContents: leftMidExtContents,
|
|
194
197
|
reload: (_b = props.reload) !== null && _b !== void 0 ? _b : reload,
|
|
195
198
|
hideTimeProgress: !!customTimeLine
|
|
196
|
-
})),
|
|
199
|
+
})), customTimeLine ? customTimeLine : !hideContrallerBar ? /*#__PURE__*/React.createElement(Timeline, {
|
|
197
200
|
api: playApi,
|
|
198
201
|
event: event
|
|
199
202
|
}) : null, /*#__PURE__*/React.createElement(ErrorEvent, {
|
|
@@ -222,6 +225,7 @@ SinglePlayer.defaultProps = {
|
|
|
222
225
|
mediaDataSource: {},
|
|
223
226
|
config: {}
|
|
224
227
|
},
|
|
225
|
-
hlsConfig: {}
|
|
228
|
+
hlsConfig: {},
|
|
229
|
+
extActions: {}
|
|
226
230
|
};
|
|
227
231
|
export default /*#__PURE__*/React.memo(SinglePlayer);
|
|
@@ -31,7 +31,7 @@ export function LivePlayerWithExt(_a) {
|
|
|
31
31
|
var ref = useRef();
|
|
32
32
|
var update = useCallback(function () {
|
|
33
33
|
return updatePlayer(ref);
|
|
34
|
-
}, []);
|
|
34
|
+
}, [updatePlayer]);
|
|
35
35
|
return /*#__PURE__*/React.createElement("div", {
|
|
36
36
|
className: "player-with-ext-layout ".concat(className),
|
|
37
37
|
style: style,
|
|
@@ -59,17 +59,9 @@ export function SegmentPlayerWithExt(_a) {
|
|
|
59
59
|
props = __rest(_a, ["begin", "style", "className", "segments", "updatePlayer", "onClick"]);
|
|
60
60
|
|
|
61
61
|
var ref = useRef();
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
for (var k in obj) {
|
|
67
|
-
ref.current[k] = obj[k];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
updatePlayer(ref);
|
|
71
|
-
};
|
|
72
|
-
|
|
62
|
+
var update = useCallback(function () {
|
|
63
|
+
return updatePlayer(ref);
|
|
64
|
+
}, [updatePlayer]);
|
|
73
65
|
return /*#__PURE__*/React.createElement("div", {
|
|
74
66
|
className: "player-with-ext-layout ".concat(className),
|
|
75
67
|
style: style,
|
|
@@ -136,18 +128,9 @@ export function FrontendPlayerWithExt(_ref) {
|
|
|
136
128
|
});
|
|
137
129
|
}, [state.url]);
|
|
138
130
|
var ref = useRef();
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
for (var k in obj) {
|
|
144
|
-
ref.current[k] = obj[k];
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
ref.current['seekTo'] = seekTo;
|
|
148
|
-
updatePlayer(ref);
|
|
149
|
-
};
|
|
150
|
-
|
|
131
|
+
var update = useCallback(function () {
|
|
132
|
+
return updatePlayer(ref);
|
|
133
|
+
}, [updatePlayer]);
|
|
151
134
|
return /*#__PURE__*/React.createElement("div", {
|
|
152
135
|
className: "player-with-ext-layout ".concat(className),
|
|
153
136
|
style: style,
|
|
@@ -161,9 +144,13 @@ export function FrontendPlayerWithExt(_ref) {
|
|
|
161
144
|
url: state.url,
|
|
162
145
|
hideContrallerBar: true,
|
|
163
146
|
forwordRef: ref,
|
|
147
|
+
extActions: {
|
|
148
|
+
seekTo: seekTo
|
|
149
|
+
},
|
|
164
150
|
begin: state.begin,
|
|
165
151
|
end: state.end,
|
|
166
152
|
onCanPlayerInit: update,
|
|
167
|
-
customTimeLine: /*#__PURE__*/React.createElement(React.Fragment, null)
|
|
153
|
+
customTimeLine: /*#__PURE__*/React.createElement(React.Fragment, null),
|
|
154
|
+
type: "flv"
|
|
168
155
|
})));
|
|
169
156
|
}
|
|
@@ -179,15 +179,11 @@ function RecordPlayer(_ref) {
|
|
|
179
179
|
var play = getPlayerItem(); // 前端录像seek 处理
|
|
180
180
|
|
|
181
181
|
if (segmentItem.recordType === 2) {
|
|
182
|
-
play.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
var seekTime = state.seekTo - item.segments[index].beginTime;
|
|
188
|
-
|
|
189
|
-
if (play.setIndex) {
|
|
190
|
-
play.setIndex(index);
|
|
182
|
+
play.api.seekTo(Math.round(state.seekTo / 1000));
|
|
183
|
+
} else {
|
|
184
|
+
// 云录像seek处理
|
|
185
|
+
var seekTime = state.seekTo - item.segments[index].beginTime;
|
|
186
|
+
play.api.setIndex(index);
|
|
191
187
|
|
|
192
188
|
_nextTick(function () {
|
|
193
189
|
return play.api.seekTo(seekTime / 1000);
|
|
@@ -5,10 +5,9 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
5
5
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
6
|
|
|
7
7
|
import moment from 'moment';
|
|
8
|
-
var
|
|
9
|
-
var currentColor = '#248ffa';
|
|
8
|
+
var currentColor = '#FF000A';
|
|
10
9
|
var normalLineColor = '#ffffff';
|
|
11
|
-
var hoverLineColor = '#
|
|
10
|
+
var hoverLineColor = '#319BFF';
|
|
12
11
|
var minPerStep = [1, 2, 5, 10, 15, 20, 30, 60, 120, 180, 240, 360, 720, 1440];
|
|
13
12
|
var minStepSize = 20;
|
|
14
13
|
|
|
@@ -99,11 +98,12 @@ var TimeSlider = /*#__PURE__*/function () {
|
|
|
99
98
|
|
|
100
99
|
_this.init(_this.start_timestamp, _this.timecell, true);
|
|
101
100
|
|
|
102
|
-
_this.drawLine(pos_x,
|
|
101
|
+
_this.drawLine(pos_x, 20, pos_x, _this.canVansH, hoverLineColor, 1);
|
|
103
102
|
|
|
104
103
|
_this.ctx.fillStyle = hoverLineColor;
|
|
104
|
+
_this.ctx.font = "10px Arial";
|
|
105
105
|
|
|
106
|
-
_this.ctx.fillText(_this.changeTime(time), pos_x - 50,
|
|
106
|
+
_this.ctx.fillText(_this.changeTime(time), pos_x - 50, 12);
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
/**
|
|
@@ -276,15 +276,15 @@ var TimeSlider = /*#__PURE__*/function () {
|
|
|
276
276
|
var px_per_ms = this.canvansW / (this.hours_per_ruler * 60 * 60 * 1000); // px/ms
|
|
277
277
|
|
|
278
278
|
var left = px_per_ms * ms_current;
|
|
279
|
-
this.ctx.fillStyle =
|
|
280
|
-
this.ctx.
|
|
281
|
-
this.
|
|
279
|
+
this.ctx.fillStyle = '#ffffff';
|
|
280
|
+
this.ctx.font = '12px Arial';
|
|
281
|
+
this.ctx.fillText(this.changeTime(time), left - 64, 14);
|
|
282
|
+
this.drawLine(left, 20, left, this.canVansH, currentColor, 2); //中间当前点线
|
|
282
283
|
}
|
|
283
284
|
}, {
|
|
284
285
|
key: "drawCellBg",
|
|
285
|
-
value: function drawCellBg() {
|
|
286
|
-
this.ctx.
|
|
287
|
-
this.ctx.fillRect(0, 0, this.canvansW, 15);
|
|
286
|
+
value: function drawCellBg() {// this.ctx.fillStyle = canvasbg;
|
|
287
|
+
// this.ctx.fillRect(0, 0, this.canvansW, 15);
|
|
288
288
|
}
|
|
289
289
|
}, {
|
|
290
290
|
key: "get_line_sizes",
|
|
@@ -308,9 +308,9 @@ var TimeSlider = /*#__PURE__*/function () {
|
|
|
308
308
|
|
|
309
309
|
var medium_step = 30;
|
|
310
310
|
|
|
311
|
-
for (var
|
|
312
|
-
if (this.distance_between_gtitle / px_per_min <= this.minutes_per_step[
|
|
313
|
-
medium_step = this.minutes_per_step[
|
|
311
|
+
for (var _i = 0; _i < this.minutes_per_step.length; _i++) {
|
|
312
|
+
if (this.distance_between_gtitle / px_per_min <= this.minutes_per_step[_i]) {
|
|
313
|
+
medium_step = this.minutes_per_step[_i];
|
|
314
314
|
break;
|
|
315
315
|
}
|
|
316
316
|
}
|
|
@@ -354,21 +354,23 @@ var TimeSlider = /*#__PURE__*/function () {
|
|
|
354
354
|
|
|
355
355
|
var date = new Date(graduation_time);
|
|
356
356
|
|
|
357
|
-
if (date.getUTCHours()
|
|
358
|
-
lineH =
|
|
357
|
+
if (date.getUTCHours() === 0 && date.getUTCMinutes() === 0) {
|
|
358
|
+
lineH = 10;
|
|
359
359
|
var big_date = this.graduation_title(date);
|
|
360
360
|
this.ctx.fillStyle = normalLineColor;
|
|
361
|
-
this.ctx.
|
|
362
|
-
|
|
363
|
-
|
|
361
|
+
this.ctx.font = "10px Arial";
|
|
362
|
+
this.ctx.fillText(big_date, graduation_left - 12, 30);
|
|
363
|
+
} else if (graduation_time / (60 * 1000) % medium_step === 0) {
|
|
364
|
+
lineH = 10;
|
|
364
365
|
var middle_date = this.graduation_title(date);
|
|
365
366
|
this.ctx.fillStyle = normalLineColor;
|
|
366
|
-
this.ctx.
|
|
367
|
+
this.ctx.font = "10px Arial";
|
|
368
|
+
this.ctx.fillText(middle_date, graduation_left - (middle_date.length > 5 ? 24 : 12), 30);
|
|
367
369
|
} else {
|
|
368
|
-
lineH =
|
|
370
|
+
lineH = 5;
|
|
369
371
|
}
|
|
370
372
|
|
|
371
|
-
this.drawLine(graduation_left,
|
|
373
|
+
this.drawLine(graduation_left, this.canVansH - lineH, graduation_left, this.canVansH, normalLineColor, 2);
|
|
372
374
|
}
|
|
373
375
|
}
|
|
374
376
|
}, {
|
|
@@ -389,7 +391,7 @@ var TimeSlider = /*#__PURE__*/function () {
|
|
|
389
391
|
var m = datetime.getMinutes();
|
|
390
392
|
var s = datetime.getMilliseconds();
|
|
391
393
|
|
|
392
|
-
if (h
|
|
394
|
+
if (h === 0 && m === 0 && s === 0) {
|
|
393
395
|
return moment(datetime).format('YYYY.MM.DD');
|
|
394
396
|
}
|
|
395
397
|
|
|
@@ -443,10 +445,10 @@ var TimeSlider = /*#__PURE__*/function () {
|
|
|
443
445
|
|
|
444
446
|
var beginX = (cell.beginTime - this.start_timestamp) * px_per_ms;
|
|
445
447
|
var cell_width = (cell.endTime - cell.beginTime) * px_per_ms;
|
|
446
|
-
this.ctx.fillStyle = cell.url ? ((_a = cell.style) === null || _a === void 0 ? void 0 : _a.background) || hoverLineColor : '#
|
|
447
|
-
this.ctx.fillRect(beginX,
|
|
448
|
+
this.ctx.fillStyle = cell.url ? ((_a = cell.style) === null || _a === void 0 ? void 0 : _a.background) || hoverLineColor : '#242C3D';
|
|
449
|
+
this.ctx.fillRect(beginX, this.canVansH - 10, cell_width + 1, this.canVansH);
|
|
448
450
|
}
|
|
449
|
-
|
|
451
|
+
/**·
|
|
450
452
|
* 时间轴事件
|
|
451
453
|
*/
|
|
452
454
|
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
}
|
|
26
26
|
.split-screen-player-wrapper.split-screen-player-wrapper-record .record-time-line {
|
|
27
27
|
width: 100%;
|
|
28
|
-
height:
|
|
28
|
+
height: 46px;
|
|
29
29
|
position: relative;
|
|
30
30
|
}
|
|
31
31
|
.split-screen-player-wrapper.split-screen-player-wrapper-record .record-time-line canvas {
|
|
@@ -33,8 +33,7 @@
|
|
|
33
33
|
width: 100%;
|
|
34
34
|
height: 100%;
|
|
35
35
|
cursor: pointer;
|
|
36
|
-
|
|
37
|
-
background-color: #2b2f33;
|
|
36
|
+
background-color: #030917;
|
|
38
37
|
}
|
|
39
38
|
.split-screen-player-wrapper.split-screen-player-wrapper-record .record-time-line .time-line-mask {
|
|
40
39
|
position: absolute;
|
package/package.json
CHANGED
package/release-build.sh
CHANGED
|
@@ -1,8 +1,37 @@
|
|
|
1
1
|
#! /bin/sh
|
|
2
2
|
|
|
3
|
+
pnpm install
|
|
4
|
+
if [ $? -eq 0 ]; then
|
|
5
|
+
echo "packages install success!"
|
|
6
|
+
else
|
|
7
|
+
echo "packages install failed!"
|
|
8
|
+
exit 1
|
|
9
|
+
fi
|
|
10
|
+
|
|
3
11
|
npm run build
|
|
12
|
+
if [ $? -eq 0 ]; then
|
|
13
|
+
echo "build success!"
|
|
14
|
+
else
|
|
15
|
+
echo "build failed!"
|
|
16
|
+
exit 1
|
|
17
|
+
fi
|
|
4
18
|
|
|
5
19
|
npm run deploy
|
|
20
|
+
if [ $? -eq 0 ]; then
|
|
21
|
+
echo "deploy success!"
|
|
22
|
+
else
|
|
23
|
+
echo "deploy failed!"
|
|
24
|
+
exit 1
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
nrm use npm
|
|
28
|
+
npm publish
|
|
29
|
+
if [ $? -eq 0 ]; then
|
|
30
|
+
echo "publish success!"
|
|
31
|
+
else
|
|
32
|
+
echo "publish failed!"
|
|
33
|
+
exit 1
|
|
34
|
+
fi
|
|
6
35
|
|
|
7
36
|
git add .
|
|
8
37
|
|
|
@@ -12,8 +41,4 @@ git pull
|
|
|
12
41
|
|
|
13
42
|
git push
|
|
14
43
|
|
|
15
|
-
nrm use npm
|
|
16
|
-
|
|
17
|
-
npm publish
|
|
18
|
-
|
|
19
44
|
exit 1
|