@cloud-app-dev/vidc 3.0.2 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.umirc.ts +1 -1
- package/es/LoaderApp/utils.d.ts +1 -1
- package/es/Player/api/index.js +1 -0
- package/es/Player/frontend_player.js +6 -12
- package/es/Player/segment_player.js +46 -7
- package/es/Player/single_player.d.ts +2 -2
- package/es/Player/single_player.js +1 -1
- package/es/ScreenPlayer/PlayerWithExt.js +9 -3
- package/es/ScreenPlayer/Record.d.ts +5 -0
- package/es/ScreenPlayer/Record.js +7 -15
- package/es/ScreenPlayer/TimeSlider.js +12 -10
- package/es/ScreenPlayer/demo2.js +1 -1
- package/es/ScreenPlayer/useVideoFit.d.ts +1 -1
- package/es/ScreenPlayer/useVideoFit.js +4 -2
- package/package.json +1 -1
package/.umirc.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { defineConfig } from 'dumi';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
|
|
4
4
|
const token =
|
|
5
|
-
'eyJhbGciOiJIUzI1NiJ9.
|
|
5
|
+
'eyJhbGciOiJIUzI1NiJ9.eyJvcmdhbml6YXRpb25JZCI6IjEwMDEwMTAwMDQ0NSIsImV4dCI6MTY2MTM4OTU0MzA4NSwidWlkIjoiMTAxMDAwMDAwNjk5IiwidmFsaWRTdGF0ZSI6MTA0NDA2LCJyb2xlSWQiOlsxMDAwMDAxMTA1MTgsMTAwMDAwMTEwNzI4XSwidmFsaWRUaW1lIjoxNzA0MzgzOTk5MDAwLCJvcHRDZW50ZXJJZCI6IjEwMDEwMDAwMDIzMyIsInVzZXJUeXBlIjoxMDA3MDQsImlhdCI6MTY2MTEzMDM0MzA4NX0.-0vh7SpomB6UWteJ6WIA5VneryhSW3Vrsz6RnHfgcRI';
|
|
6
6
|
|
|
7
7
|
export default defineConfig({
|
|
8
8
|
title: 'CloudApp VIDC',
|
package/es/LoaderApp/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppItemType } from '
|
|
1
|
+
import { AppItemType } from '../Config/interface';
|
|
2
2
|
export declare const getMicroConfig: (appConfig: AppItemType, appProps: any, container: HTMLDivElement) => {
|
|
3
3
|
title: string;
|
|
4
4
|
routerPrefix: string;
|
package/es/Player/api/index.js
CHANGED
|
@@ -26,23 +26,17 @@ function FrontendPlayer(_a) {
|
|
|
26
26
|
|
|
27
27
|
var _ref = playRef.current || {},
|
|
28
28
|
api = _ref.api,
|
|
29
|
-
event = _ref.event; //
|
|
29
|
+
event = _ref.event; // 转换毫秒
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
var beginTemp = useMemo(function () {
|
|
33
|
-
return begin ? String(begin).length === 10 ? Math.floor(begin * 1000) : begin : begin;
|
|
34
|
-
}, [begin]);
|
|
35
|
-
var endTemp = useMemo(function () {
|
|
36
|
-
return end ? String(end).length === 10 ? Math.floor(end * 1000) : end : end;
|
|
37
|
-
}, [end]);
|
|
38
32
|
var duration = useMemo(function () {
|
|
39
|
-
return (
|
|
40
|
-
}, [
|
|
33
|
+
return (begin - end) / 1000;
|
|
34
|
+
}, [begin, end]); //单位s 秒
|
|
41
35
|
// 重置reload
|
|
42
36
|
|
|
43
37
|
var reload = function reload() {
|
|
44
38
|
playRef.current.event.emit(Events.RELOAD);
|
|
45
|
-
onSeek && onSeek(
|
|
39
|
+
onSeek && onSeek(begin);
|
|
46
40
|
playRef.current.api.reload();
|
|
47
41
|
};
|
|
48
42
|
|
|
@@ -52,10 +46,10 @@ function FrontendPlayer(_a) {
|
|
|
52
46
|
}, []);
|
|
53
47
|
var hasReady = api && event;
|
|
54
48
|
var timeline = customTimeLine !== null && customTimeLine !== void 0 ? customTimeLine : /*#__PURE__*/React.createElement(FrontendTimeLine, {
|
|
55
|
-
end:
|
|
49
|
+
end: end,
|
|
56
50
|
url: url,
|
|
57
51
|
onSeek: onSeek,
|
|
58
|
-
begin:
|
|
52
|
+
begin: begin,
|
|
59
53
|
api: api,
|
|
60
54
|
event: event,
|
|
61
55
|
duration: duration
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _useUpdate from "ahooks/es/useUpdate";
|
|
2
|
+
import _useLatest from "ahooks/es/useLatest";
|
|
2
3
|
|
|
3
4
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
5
|
|
|
@@ -138,6 +139,15 @@ function SegmentPlayer(_a) {
|
|
|
138
139
|
customTimeLine = _a.customTimeLine,
|
|
139
140
|
props = __rest(_a, ["segments", "begin", "forwordRef", "defaultIndex", "onCanPlayerInit", "customTimeLine"]);
|
|
140
141
|
|
|
142
|
+
var _useState3 = useState({
|
|
143
|
+
seekTime: 0
|
|
144
|
+
}),
|
|
145
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
146
|
+
state = _useState4[0],
|
|
147
|
+
setState = _useState4[1];
|
|
148
|
+
|
|
149
|
+
var latestSegmentsRef = _useLatest(segments);
|
|
150
|
+
|
|
141
151
|
var update = _useUpdate();
|
|
142
152
|
|
|
143
153
|
var ref = useRef(null);
|
|
@@ -160,22 +170,50 @@ function SegmentPlayer(_a) {
|
|
|
160
170
|
setIndex = _usePlayIndex.setIndex;
|
|
161
171
|
|
|
162
172
|
var url = useMemo(function () {
|
|
163
|
-
return segments
|
|
173
|
+
return segments[index] ? segments[index].url : undefined;
|
|
164
174
|
}, [segments, index]); // 重置reload
|
|
165
175
|
|
|
166
176
|
var reload = function reload() {
|
|
167
177
|
playRef.current.event.emit(Events.RELOAD);
|
|
168
178
|
setIndex(0);
|
|
169
179
|
playRef.current.api.reload();
|
|
170
|
-
}; //
|
|
180
|
+
}; // time 毫秒的时间戳
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
var seekTo = function seekTo(time) {
|
|
184
|
+
var index = latestSegmentsRef.current.findIndex(function (v) {
|
|
185
|
+
return time >= v.beginTime && time < v.endTime;
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
if (index === -1) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
var currentTime = time - latestSegmentsRef.current[index].beginTime;
|
|
193
|
+
setIndex(index);
|
|
194
|
+
setState(function (old) {
|
|
195
|
+
return Object.assign(Object.assign({}, old), {
|
|
196
|
+
seekTime: currentTime / 1000
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
}; // 处理seek 后index变化后 cuurenttime变化的过程
|
|
171
200
|
|
|
172
201
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
202
|
+
useEffect(function () {
|
|
203
|
+
if (state.seekTime === 0) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
setState(function (old) {
|
|
208
|
+
return Object.assign(Object.assign({}, old), {
|
|
209
|
+
seekTime: 0
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
playRef.current.video.currentTime = state.seekTime; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
213
|
+
}, [state.seekTime]);
|
|
176
214
|
var hasReady = api && event;
|
|
177
215
|
var timeline = customTimeLine !== null && customTimeLine !== void 0 ? customTimeLine : /*#__PURE__*/React.createElement(SegmentTimeLine, {
|
|
178
|
-
begin:
|
|
216
|
+
begin: begin,
|
|
179
217
|
api: api,
|
|
180
218
|
event: event,
|
|
181
219
|
index: index,
|
|
@@ -193,7 +231,8 @@ function SegmentPlayer(_a) {
|
|
|
193
231
|
onCanPlayerInit: onInit,
|
|
194
232
|
reload: reload,
|
|
195
233
|
extActions: {
|
|
196
|
-
setIndex: setIndex
|
|
234
|
+
setIndex: setIndex,
|
|
235
|
+
seekTo: seekTo
|
|
197
236
|
},
|
|
198
237
|
customTimeLine: hasReady ? timeline : /*#__PURE__*/React.createElement(React.Fragment, null)
|
|
199
238
|
}, props));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ISinglePlayerProps, ExportPlayerType } from './player';
|
|
3
3
|
import './style/index.less';
|
|
4
|
-
declare const
|
|
5
|
-
export default
|
|
4
|
+
declare const SinglePlayer: React.ForwardRefExoticComponent<ISinglePlayerProps & React.RefAttributes<ExportPlayerType>>;
|
|
5
|
+
export default SinglePlayer;
|
|
@@ -16,6 +16,7 @@ import LivePlayer from '../Player/single_player';
|
|
|
16
16
|
import SegmentPlayer from '../Player/segment_player';
|
|
17
17
|
import FrontendPlayer from '../Player/frontend_player';
|
|
18
18
|
import ExtModel from '../PlayerExt';
|
|
19
|
+
import moment from 'moment';
|
|
19
20
|
export function LivePlayerWithExt(_a) {
|
|
20
21
|
var mode = _a.mode,
|
|
21
22
|
isLive = _a.isLive,
|
|
@@ -107,7 +108,8 @@ export function FrontendPlayerWithExt(_ref) {
|
|
|
107
108
|
begin = _ref2[0],
|
|
108
109
|
end = _ref2[1];
|
|
109
110
|
var videoUrl = new URL(segments[0].url);
|
|
110
|
-
videoUrl.searchParams.set('begin', "".concat(begin));
|
|
111
|
+
videoUrl.searchParams.set('begin', "".concat(moment(begin).unix()));
|
|
112
|
+
videoUrl.searchParams.set('end', "".concat(moment(end).unix()));
|
|
111
113
|
setState({
|
|
112
114
|
begin: begin,
|
|
113
115
|
end: end,
|
|
@@ -119,18 +121,22 @@ export function FrontendPlayerWithExt(_ref) {
|
|
|
119
121
|
return;
|
|
120
122
|
}
|
|
121
123
|
|
|
124
|
+
var endTime = moment(segments[segments.length - 1].endTime).unix();
|
|
125
|
+
var beginTime = moment(time).unix();
|
|
122
126
|
var videoUrl = new URL(state.url);
|
|
123
|
-
videoUrl.searchParams.set('begin', "".concat(
|
|
127
|
+
videoUrl.searchParams.set('begin', "".concat(beginTime));
|
|
128
|
+
videoUrl.searchParams.set('end', "".concat(endTime));
|
|
124
129
|
setState(function (old) {
|
|
125
130
|
return Object.assign(Object.assign({}, old), {
|
|
126
131
|
url: videoUrl.toString()
|
|
127
132
|
});
|
|
128
133
|
});
|
|
129
|
-
}, [state.url]);
|
|
134
|
+
}, [segments, state.url]);
|
|
130
135
|
var ref = useRef();
|
|
131
136
|
var update = useCallback(function () {
|
|
132
137
|
return updatePlayer(ref);
|
|
133
138
|
}, [updatePlayer]);
|
|
139
|
+
console.log(state.url);
|
|
134
140
|
return /*#__PURE__*/React.createElement("div", {
|
|
135
141
|
className: "player-with-ext-layout ".concat(className),
|
|
136
142
|
style: style,
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { IRecordPlayerProps } from './interface';
|
|
3
3
|
import './index.less';
|
|
4
|
+
/**
|
|
5
|
+
* @desc 录像设计的时间全部需要到毫秒
|
|
6
|
+
* @param param0
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
4
9
|
declare function RecordPlayer({ list, children, queryRecord, onIndexChange }: IRecordPlayerProps): JSX.Element;
|
|
5
10
|
export default RecordPlayer;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
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); }
|
|
2
2
|
|
|
3
|
-
import _nextTick from "@cloud-app-dev/utils/es/nextTick";
|
|
4
3
|
import _usePrevious from "ahooks/es/usePrevious";
|
|
5
4
|
|
|
6
5
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
@@ -34,6 +33,11 @@ import SegmentTimeLine from './SegmentTimeLine';
|
|
|
34
33
|
import useRecordList from './useRecordList';
|
|
35
34
|
import useVideoFit from './useVideoFit';
|
|
36
35
|
import "./index.css";
|
|
36
|
+
/**
|
|
37
|
+
* @desc 录像设计的时间全部需要到毫秒
|
|
38
|
+
* @param param0
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
37
41
|
|
|
38
42
|
function RecordPlayer(_ref) {
|
|
39
43
|
var _this = this;
|
|
@@ -176,20 +180,8 @@ function RecordPlayer(_ref) {
|
|
|
176
180
|
seekTo: 0
|
|
177
181
|
});
|
|
178
182
|
});
|
|
179
|
-
var play = getPlayerItem();
|
|
180
|
-
|
|
181
|
-
if (segmentItem.recordType === 2) {
|
|
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);
|
|
187
|
-
|
|
188
|
-
_nextTick(function () {
|
|
189
|
-
return play.api.seekTo(seekTime / 1000);
|
|
190
|
-
});
|
|
191
|
-
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
192
|
-
|
|
183
|
+
var play = getPlayerItem();
|
|
184
|
+
play.api.seekTo(state.seekTo); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
193
185
|
}, [state.seekTo, state.selectIndex, recordList, segmentItem.recordType]); // 更新状态
|
|
194
186
|
|
|
195
187
|
var updateState = function updateState(newState) {
|
|
@@ -88,13 +88,15 @@ var TimeSlider = /*#__PURE__*/function () {
|
|
|
88
88
|
|
|
89
89
|
this.mousemoveFunc2 = function (e) {
|
|
90
90
|
if (!_this.g_isMousedown) {
|
|
91
|
-
var pos_x = _this.get_cursor_x_position(e);
|
|
91
|
+
var pos_x = _this.get_cursor_x_position(e); // const px_per_ms = this.canvansW / (this.hours_per_ruler * 60 * 60 * 1000); // px/ms
|
|
92
|
+
// const current_timestamp = this.start_timestamp + pos_x / px_per_ms;
|
|
92
93
|
|
|
93
|
-
var px_per_ms = _this.canvansW / (_this.hours_per_ruler * 60 * 60 * 1000); // px/ms
|
|
94
94
|
|
|
95
|
-
_this.
|
|
95
|
+
var ms_per_px = _this.hours_per_ruler * 3600 * 1000 / _this.canvansW; // ms/px
|
|
96
96
|
|
|
97
|
-
var
|
|
97
|
+
var current_timestamp = _this.start_timestamp + pos_x * ms_per_px;
|
|
98
|
+
|
|
99
|
+
_this.clearCanvas();
|
|
98
100
|
|
|
99
101
|
_this.init(_this.start_timestamp, _this.timecell, true);
|
|
100
102
|
|
|
@@ -103,7 +105,7 @@ var TimeSlider = /*#__PURE__*/function () {
|
|
|
103
105
|
_this.ctx.fillStyle = hoverLineColor;
|
|
104
106
|
_this.ctx.font = "10px Arial";
|
|
105
107
|
|
|
106
|
-
_this.ctx.fillText(_this.changeTime(
|
|
108
|
+
_this.ctx.fillText(_this.changeTime(current_timestamp), pos_x - 50, 12);
|
|
107
109
|
}
|
|
108
110
|
};
|
|
109
111
|
/**
|
|
@@ -120,12 +122,12 @@ var TimeSlider = /*#__PURE__*/function () {
|
|
|
120
122
|
// click 事件
|
|
121
123
|
_this.g_isMousedown = false;
|
|
122
124
|
|
|
123
|
-
var
|
|
125
|
+
var pos_x = _this.get_cursor_x_position(e); //鼠标距离 px
|
|
124
126
|
|
|
125
127
|
|
|
126
|
-
var ms_per_px = _this.
|
|
128
|
+
var ms_per_px = _this.hours_per_ruler * 3600 * 1000 / _this.canvansW; // ms/px
|
|
127
129
|
|
|
128
|
-
var current_timestamp = _this.start_timestamp +
|
|
130
|
+
var current_timestamp = _this.start_timestamp + pos_x * ms_per_px;
|
|
129
131
|
|
|
130
132
|
var timecellItem = _this.timecell.find(function (v) {
|
|
131
133
|
return current_timestamp >= v.beginTime && current_timestamp < v.endTime;
|
|
@@ -136,11 +138,11 @@ var TimeSlider = /*#__PURE__*/function () {
|
|
|
136
138
|
return;
|
|
137
139
|
}
|
|
138
140
|
|
|
139
|
-
_this.current_timestamp =
|
|
141
|
+
_this.current_timestamp = current_timestamp;
|
|
140
142
|
|
|
141
143
|
_this.set_time_to_middle(_this.current_timestamp);
|
|
142
144
|
|
|
143
|
-
_this.options.onTimeChange && _this.options.onTimeChange(
|
|
145
|
+
_this.options.onTimeChange && _this.options.onTimeChange(current_timestamp);
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
document.removeEventListener('mousemove', _this.mousemoveFunc);
|
package/es/ScreenPlayer/demo2.js
CHANGED
|
@@ -28,7 +28,7 @@ import RecordPlayer from './Record';
|
|
|
28
28
|
import moment from 'moment';
|
|
29
29
|
import Service from '../Service';
|
|
30
30
|
import { completionSegments } from './utils';
|
|
31
|
-
var token = "eyJhbGciOiJIUzI1NiJ9.
|
|
31
|
+
var token = "eyJhbGciOiJIUzI1NiJ9.eyJvcmdhbml6YXRpb25JZCI6IjEwMDEwMTAwMDQ0NSIsImV4dCI6MTY2MTM4OTU0MzA4NSwidWlkIjoiMTAxMDAwMDAwNjk5IiwidmFsaWRTdGF0ZSI6MTA0NDA2LCJyb2xlSWQiOlsxMDAwMDAxMTA1MTgsMTAwMDAwMTEwNzI4XSwidmFsaWRUaW1lIjoxNzA0MzgzOTk5MDAwLCJvcHRDZW50ZXJJZCI6IjEwMDEwMDAwMDIzMyIsInVzZXJUeXBlIjoxMDA3MDQsImlhdCI6MTY2MTEzMDM0MzA4NX0.-0vh7SpomB6UWteJ6WIA5VneryhSW3Vrsz6RnHfgcRI";
|
|
32
32
|
var cids = ['538509097', '539172446'];
|
|
33
33
|
|
|
34
34
|
var query = function query(_ref) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export default function useVideoFit(containerRef: React.MutableRefObject<HTMLDivElement>, deps
|
|
2
|
+
export default function useVideoFit(containerRef: React.MutableRefObject<HTMLDivElement>, deps?: any[]): {
|
|
3
3
|
fit: string;
|
|
4
4
|
toggleFit: () => void;
|
|
5
5
|
};
|
|
@@ -21,7 +21,9 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
21
21
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
22
22
|
|
|
23
23
|
import { useEffect, useMemo } from 'react';
|
|
24
|
-
export default function useVideoFit(containerRef
|
|
24
|
+
export default function useVideoFit(containerRef) {
|
|
25
|
+
var deps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
26
|
+
|
|
25
27
|
var _useToggle = _useToggle3('contain', 'fill'),
|
|
26
28
|
_useToggle2 = _slicedToArray(_useToggle, 2),
|
|
27
29
|
fit = _useToggle2[0],
|
|
@@ -35,7 +37,7 @@ export default function useVideoFit(containerRef, deps) {
|
|
|
35
37
|
var videos = containerRef.current.querySelectorAll('video');
|
|
36
38
|
Array.from(videos).forEach(function (item) {
|
|
37
39
|
item.style.objectFit = fit;
|
|
38
|
-
});
|
|
40
|
+
}); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
41
|
}, [].concat(_toConsumableArray(deps), [fit]));
|
|
40
42
|
return useMemo(function () {
|
|
41
43
|
return {
|