@cloud-app-dev/vidc 3.1.22 → 3.2.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/.umirc.ts +0 -3
- package/es/PlayerExt/index.d.ts +3 -1
- package/es/PlayerExt/index.js +18 -6
- package/es/ScreenPlayer/PlayerWithExt.js +2 -1
- package/es/ScreenPlayer/RatePick.js +6 -0
- package/es/ScreenPlayer/Record.d.ts +1 -1
- package/es/ScreenPlayer/Record.js +100 -155
- package/es/ScreenPlayer/RecordTools.js +3 -3
- package/es/ScreenPlayer/demo2.js +132 -52
- package/es/ScreenPlayer/interface.d.ts +21 -29
- package/es/ScreenPlayer/utils.d.ts +1 -11
- package/es/ScreenPlayer/utils.js +8 -20
- package/package.json +1 -1
- package/es/ScreenPlayer/useRecordList.d.ts +0 -8
- package/es/ScreenPlayer/useRecordList.js +0 -245
package/.umirc.ts
CHANGED
package/es/PlayerExt/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { ISegmentType } from 'src/Player/player';
|
|
2
3
|
import './index.less';
|
|
3
4
|
export declare type PlayModeType = 1 | 2;
|
|
4
5
|
export interface IPluginProps {
|
|
@@ -18,6 +19,7 @@ export interface IPluginProps {
|
|
|
18
19
|
* @default ''
|
|
19
20
|
*/
|
|
20
21
|
pluginParams?: string;
|
|
22
|
+
segments?: ISegmentType[];
|
|
21
23
|
/**
|
|
22
24
|
* 正在获取视频数据
|
|
23
25
|
*/
|
|
@@ -42,5 +44,5 @@ export declare function getLocalPlayPath(url: string, params?: string): string;
|
|
|
42
44
|
export declare function usePlugin(mode: PlayModeType, key: any): {
|
|
43
45
|
needInstall: boolean;
|
|
44
46
|
};
|
|
45
|
-
export declare function ExtModel({ url, children, mode, pluginDownloadUrl, pluginParams, loading }: IPluginProps): JSX.Element;
|
|
47
|
+
export declare function ExtModel({ url, children, mode, pluginDownloadUrl, pluginParams, loading, segments }: IPluginProps): JSX.Element;
|
|
46
48
|
export { ExtModel as default };
|
package/es/PlayerExt/index.js
CHANGED
|
@@ -122,7 +122,8 @@ export function ExtModel(_ref2) {
|
|
|
122
122
|
mode = _ref2.mode,
|
|
123
123
|
pluginDownloadUrl = _ref2.pluginDownloadUrl,
|
|
124
124
|
pluginParams = _ref2.pluginParams,
|
|
125
|
-
loading = _ref2.loading
|
|
125
|
+
loading = _ref2.loading,
|
|
126
|
+
segments = _ref2.segments;
|
|
126
127
|
var _useState3 = useState({
|
|
127
128
|
forceKey: Date.now()
|
|
128
129
|
}),
|
|
@@ -130,14 +131,24 @@ export function ExtModel(_ref2) {
|
|
|
130
131
|
state = _useState4[0],
|
|
131
132
|
setState = _useState4[1];
|
|
132
133
|
var hasUrl = useMemo(function () {
|
|
133
|
-
return !!url
|
|
134
|
-
|
|
134
|
+
return !!url || Array.isArray(segments) && segments.findIndex(function (v) {
|
|
135
|
+
return v.url;
|
|
136
|
+
}) > -1;
|
|
137
|
+
}, [segments, url]);
|
|
135
138
|
var _usePlugin = usePlugin(mode, state.forceKey),
|
|
136
139
|
needInstall = _usePlugin.needInstall;
|
|
137
140
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
138
141
|
var playUrl = useMemo(function () {
|
|
139
142
|
return mode === 2 && url ? getLocalPlayPath(url, pluginParams) : url;
|
|
140
143
|
}, [url, mode]);
|
|
144
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
145
|
+
var playSegments = useMemo(function () {
|
|
146
|
+
return mode === 2 && url ? segments.map(function (v) {
|
|
147
|
+
return Object.assign(Object.assign({}, v), {
|
|
148
|
+
url: getLocalPlayPath(v.url, pluginParams)
|
|
149
|
+
});
|
|
150
|
+
}) : url;
|
|
151
|
+
}, [segments, mode]);
|
|
141
152
|
if (needInstall) {
|
|
142
153
|
return /*#__PURE__*/React.createElement(NeedInstallPlugin, {
|
|
143
154
|
pluginDownloadUrl: pluginDownloadUrl,
|
|
@@ -158,8 +169,9 @@ export function ExtModel(_ref2) {
|
|
|
158
169
|
}
|
|
159
170
|
return /*#__PURE__*/React.createElement("div", {
|
|
160
171
|
className: "lm-player-ext-layout"
|
|
161
|
-
}, /*#__PURE__*/React.cloneElement(children, {
|
|
162
|
-
url: playUrl
|
|
163
|
-
|
|
172
|
+
}, /*#__PURE__*/React.cloneElement(children, mode === 2 ? {
|
|
173
|
+
url: playUrl,
|
|
174
|
+
segments: playSegments
|
|
175
|
+
} : {}));
|
|
164
176
|
}
|
|
165
177
|
export { ExtModel as default };
|
|
@@ -82,7 +82,8 @@ export function SegmentPlayerWithExt(_a) {
|
|
|
82
82
|
onDoubleClick: toggleFullscreen
|
|
83
83
|
}, /*#__PURE__*/React.createElement(ExtModel, {
|
|
84
84
|
mode: 1,
|
|
85
|
-
loading: httpLoading
|
|
85
|
+
loading: httpLoading,
|
|
86
|
+
segments: segments
|
|
86
87
|
}, /*#__PURE__*/React.createElement(SegmentPlayer, Object.assign({}, props, {
|
|
87
88
|
segments: segments,
|
|
88
89
|
type: "hls",
|
|
@@ -16,6 +16,12 @@ function RatePick(_ref) {
|
|
|
16
16
|
onChange: onChange,
|
|
17
17
|
placement: "topLeft"
|
|
18
18
|
}, /*#__PURE__*/React.createElement(_Select.Option, {
|
|
19
|
+
value: 8
|
|
20
|
+
}, "x8"), /*#__PURE__*/React.createElement(_Select.Option, {
|
|
21
|
+
value: 6
|
|
22
|
+
}, "x6"), /*#__PURE__*/React.createElement(_Select.Option, {
|
|
23
|
+
value: 4
|
|
24
|
+
}, "x4"), /*#__PURE__*/React.createElement(_Select.Option, {
|
|
19
25
|
value: 2
|
|
20
26
|
}, "x2"), /*#__PURE__*/React.createElement(_Select.Option, {
|
|
21
27
|
value: 1.5
|
|
@@ -6,5 +6,5 @@ import './index.less';
|
|
|
6
6
|
* @param param0
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
|
-
declare function RecordPlayer({ list, children,
|
|
9
|
+
declare function RecordPlayer({ list, children, onIndexChange, onClose, onCloseAll, download, snapshot, defaultScreen, screenChange, defaultSelectIndex, oneWinExtTools, allWinExtTools, fpsDelay, fps, getLocalRecordUrl, pluginDownloadUrl, onTimeLineChange, seekLoading, ...options }: IRecordPlayerProps): JSX.Element;
|
|
10
10
|
export default RecordPlayer;
|
|
@@ -1,14 +1,7 @@
|
|
|
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
|
import _useUpdateEffect from "ahooks/es/useUpdateEffect";
|
|
3
|
-
|
|
4
|
-
import _message from "antd/lib/message";
|
|
5
|
-
import _usePrevious from "ahooks/es/usePrevious";
|
|
3
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
4
|
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; }
|
|
7
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
|
-
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."); }
|
|
9
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
10
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
11
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
12
5
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
13
6
|
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."); }
|
|
14
7
|
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); }
|
|
@@ -17,11 +10,10 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
17
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
11
|
import { __awaiter, __rest } from "tslib";
|
|
19
12
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
20
|
-
import { ScreenType, mergeFill,
|
|
13
|
+
import { ScreenType, mergeFill, sleep } from './utils';
|
|
21
14
|
import { SegmentPlayerWithExt, FrontendPlayerWithExt } from './PlayerWithExt';
|
|
22
15
|
import RecordTools from './RecordTools';
|
|
23
16
|
import SegmentTimeLine from './SegmentTimeLine';
|
|
24
|
-
import useRecordList from './useRecordList';
|
|
25
17
|
import useVideoFit from './useVideoFit';
|
|
26
18
|
import DisableMark from '../DisableMark';
|
|
27
19
|
import { cloneDeep } from 'lodash-es';
|
|
@@ -31,11 +23,8 @@ var defaultState = {
|
|
|
31
23
|
selectIndex: 0,
|
|
32
24
|
modes: {},
|
|
33
25
|
currentTimes: {},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
mergeSegments: [],
|
|
37
|
-
timeMode: 24,
|
|
38
|
-
winLoadingStatus: {}
|
|
26
|
+
seekTo: {},
|
|
27
|
+
timeMode: 24
|
|
39
28
|
};
|
|
40
29
|
/**
|
|
41
30
|
* @desc 录像设计的时间全部需要到毫秒
|
|
@@ -46,7 +35,6 @@ function RecordPlayer(_a) {
|
|
|
46
35
|
var _this = this;
|
|
47
36
|
var list = _a.list,
|
|
48
37
|
children = _a.children,
|
|
49
|
-
queryRecord = _a.queryRecord,
|
|
50
38
|
onIndexChange = _a.onIndexChange,
|
|
51
39
|
onClose = _a.onClose,
|
|
52
40
|
onCloseAll = _a.onCloseAll,
|
|
@@ -59,10 +47,11 @@ function RecordPlayer(_a) {
|
|
|
59
47
|
allWinExtTools = _a.allWinExtTools,
|
|
60
48
|
fpsDelay = _a.fpsDelay,
|
|
61
49
|
fps = _a.fps,
|
|
62
|
-
queryRecordErrorHandle = _a.queryRecordErrorHandle,
|
|
63
50
|
getLocalRecordUrl = _a.getLocalRecordUrl,
|
|
64
51
|
pluginDownloadUrl = _a.pluginDownloadUrl,
|
|
65
|
-
|
|
52
|
+
onTimeLineChange = _a.onTimeLineChange,
|
|
53
|
+
seekLoading = _a.seekLoading,
|
|
54
|
+
options = __rest(_a, ["list", "children", "onIndexChange", "onClose", "onCloseAll", "download", "snapshot", "defaultScreen", "screenChange", "defaultSelectIndex", "oneWinExtTools", "allWinExtTools", "fpsDelay", "fps", "getLocalRecordUrl", "pluginDownloadUrl", "onTimeLineChange", "seekLoading"]);
|
|
66
55
|
var _useState = useState(Object.assign(Object.assign({}, cloneDeep(defaultState)), {
|
|
67
56
|
screenNum: defaultScreen !== null && defaultScreen !== void 0 ? defaultScreen : defaultState.screenNum
|
|
68
57
|
})),
|
|
@@ -89,122 +78,99 @@ function RecordPlayer(_a) {
|
|
|
89
78
|
var _useVideoFit = useVideoFit(domRef, []),
|
|
90
79
|
fit = _useVideoFit.fit,
|
|
91
80
|
toggleFit = _useVideoFit.toggleFit;
|
|
92
|
-
// key变化
|
|
93
|
-
var listKey = useMemo(function () {
|
|
94
|
-
return screenList.map(function (v) {
|
|
95
|
-
var _a, _b;
|
|
96
|
-
return v ? "".concat((_a = v.date) !== null && _a !== void 0 ? _a : 0, "|").concat((_b = v.cid) !== null && _b !== void 0 ? _b : 1) : FILTER_KEY;
|
|
97
|
-
}).join('-');
|
|
98
|
-
}, [screenList]);
|
|
99
|
-
var prevListKey = _usePrevious(listKey);
|
|
100
|
-
// 所有窗口播放信息
|
|
101
|
-
var recordList = useRecordList(state.mergeSegments, queryRecord, {
|
|
102
|
-
errorCallback: queryRecordErrorHandle !== null && queryRecordErrorHandle !== void 0 ? queryRecordErrorHandle : function () {},
|
|
103
|
-
loaddingCallback: function loaddingCallback(idx, loadding) {
|
|
104
|
-
return setState(function (old) {
|
|
105
|
-
var item = old.mergeSegments[idx];
|
|
106
|
-
var status = Object.assign({}, old.winLoadingStatus);
|
|
107
|
-
status["".concat(item.cid, "-").concat(item.date)] = loadding;
|
|
108
|
-
return Object.assign(Object.assign({}, old), {
|
|
109
|
-
winLoadingStatus: status
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
81
|
// 缓存所有player对象
|
|
115
82
|
var playerRef = useRef({});
|
|
116
83
|
// 获取选中player对象
|
|
117
84
|
var getPlayerItem = function getPlayerItem() {
|
|
118
85
|
var _a, _b;
|
|
119
|
-
var item =
|
|
120
|
-
return (_b = (_a = playerRef.current) === null || _a === void 0 ? void 0 : _a[item
|
|
86
|
+
var item = screenList[state.selectIndex];
|
|
87
|
+
return item ? (_b = (_a = playerRef.current) === null || _a === void 0 ? void 0 : _a["".concat(item.cid, "-").concat(item.date)]) === null || _b === void 0 ? void 0 : _b.current : null;
|
|
121
88
|
};
|
|
122
89
|
// 当前窗口信息
|
|
123
90
|
var segmentItem = useMemo(function () {
|
|
124
|
-
return
|
|
125
|
-
}, [state.selectIndex,
|
|
91
|
+
return screenList[state.selectIndex] || {};
|
|
92
|
+
}, [state.selectIndex, screenList]);
|
|
126
93
|
var timeBegin = useMemo(function () {
|
|
127
94
|
return segmentItem.date;
|
|
128
95
|
}, [segmentItem.date]);
|
|
129
96
|
var currentTime = useMemo(function () {
|
|
130
|
-
var item =
|
|
97
|
+
var item = screenList[state.selectIndex];
|
|
131
98
|
if (!item) {
|
|
132
99
|
return undefined;
|
|
133
100
|
}
|
|
134
101
|
return state.currentTimes["".concat(item.cid, "-").concat(item.date)];
|
|
135
|
-
}, [state.currentTimes,
|
|
136
|
-
/**
|
|
137
|
-
* @desc 用户缓存接收list的变化。
|
|
138
|
-
*/
|
|
139
|
-
useEffect(function () {
|
|
140
|
-
if (!prevListKey || !listKey) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
var diffIndexs = differenceWithIndexs(listKey.split('-'), prevListKey.split('-'));
|
|
144
|
-
if (diffIndexs.length === 0) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
setState(function (old) {
|
|
148
|
-
var mergeList = old.mergeSegments;
|
|
149
|
-
var times = old.currentTimes;
|
|
150
|
-
// 批量更新调整
|
|
151
|
-
var _iterator = _createForOfIteratorHelper(diffIndexs),
|
|
152
|
-
_step;
|
|
153
|
-
try {
|
|
154
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
155
|
-
var dif = _step.value;
|
|
156
|
-
var i = dif.idx;
|
|
157
|
-
var item = list[i];
|
|
158
|
-
if (!item) {
|
|
159
|
-
// 可能是外部的关闭动作关闭
|
|
160
|
-
mergeList[i] = undefined;
|
|
161
|
-
} else {
|
|
162
|
-
if (!mergeList[i]) {
|
|
163
|
-
mergeList[i] = cloneDeep(item);
|
|
164
|
-
}
|
|
165
|
-
mergeList[i].date = item.date;
|
|
166
|
-
mergeList[i].segments = mergeList[i].cid !== item.cid ? [] : mergeList[i].segments;
|
|
167
|
-
mergeList[i].cid = item.cid;
|
|
168
|
-
mergeList[i].recordType = item.recordType;
|
|
169
|
-
// 更新变化的currentTime
|
|
170
|
-
times["".concat(item.cid, "-").concat(item.date)] = list[i].date;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
} catch (err) {
|
|
174
|
-
_iterator.e(err);
|
|
175
|
-
} finally {
|
|
176
|
-
_iterator.f();
|
|
177
|
-
}
|
|
178
|
-
return Object.assign(Object.assign({}, old), {
|
|
179
|
-
mergeSegments: _toConsumableArray(mergeList),
|
|
180
|
-
currentTimes: Object.assign({}, times)
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
}, [list, listKey, prevListKey]);
|
|
102
|
+
}, [state.currentTimes, screenList, state.selectIndex]);
|
|
184
103
|
/**
|
|
185
104
|
* @desc seek hook
|
|
186
105
|
* 处理seek相关的包括索引和video current time
|
|
187
106
|
*/
|
|
188
107
|
useEffect(function () {
|
|
189
|
-
|
|
108
|
+
var _a, _b;
|
|
109
|
+
// 寻找需要seek的item
|
|
110
|
+
var key = Object.keys(state.seekTo).find(function (k) {
|
|
111
|
+
return state.seekTo[k] !== 0;
|
|
112
|
+
});
|
|
113
|
+
if (!key) {
|
|
190
114
|
return;
|
|
191
115
|
}
|
|
192
|
-
var
|
|
193
|
-
var
|
|
194
|
-
return
|
|
116
|
+
var seekTime = state.seekTo[key];
|
|
117
|
+
var item = list.find(function (v) {
|
|
118
|
+
return !!v && "".concat(v.cid, "-").concat(v.date) === key;
|
|
195
119
|
});
|
|
120
|
+
var index = (_b = (_a = item === null || item === void 0 ? void 0 : item.segments) === null || _a === void 0 ? void 0 : _a.findIndex(function (v) {
|
|
121
|
+
return seekTime >= v.beginTime && seekTime < v.endTime;
|
|
122
|
+
})) !== null && _b !== void 0 ? _b : -1;
|
|
196
123
|
if (index === -1) {
|
|
197
124
|
return;
|
|
198
125
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
126
|
+
// list变化导致ref被销毁,这里设计了一个处理机制,1s内重试5次,尝试获取新的ref,正常情况下都会获取到播放器初始化很快,还未获取到那么丢弃
|
|
127
|
+
var timer = 0;
|
|
128
|
+
function getPlay(mapkey) {
|
|
129
|
+
var _a;
|
|
130
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
131
|
+
var playRef;
|
|
132
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
133
|
+
while (1) {
|
|
134
|
+
switch (_context.prev = _context.next) {
|
|
135
|
+
case 0:
|
|
136
|
+
playRef = (_a = playerRef.current) === null || _a === void 0 ? void 0 : _a[mapkey];
|
|
137
|
+
if (!(playRef && playRef.current && playRef.current.api)) {
|
|
138
|
+
_context.next = 5;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
return _context.abrupt("return", playRef.current);
|
|
142
|
+
case 5:
|
|
143
|
+
if (!(timer < 5)) {
|
|
144
|
+
_context.next = 10;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
timer++;
|
|
148
|
+
_context.next = 9;
|
|
149
|
+
return sleep(200);
|
|
150
|
+
case 9:
|
|
151
|
+
return _context.abrupt("return", sleep(200).then(function () {
|
|
152
|
+
return getPlay(mapkey);
|
|
153
|
+
}));
|
|
154
|
+
case 10:
|
|
155
|
+
return _context.abrupt("return", undefined);
|
|
156
|
+
case 11:
|
|
157
|
+
case "end":
|
|
158
|
+
return _context.stop();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}, _callee);
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
getPlay(key).then(function (play) {
|
|
165
|
+
play && play.api.seekTo(seekTime);
|
|
166
|
+
setState(function (old) {
|
|
167
|
+
return Object.assign(Object.assign({}, old), {
|
|
168
|
+
seekTo: Object.assign(Object.assign({}, old.seekTo), _defineProperty({}, key, 0))
|
|
169
|
+
});
|
|
202
170
|
});
|
|
203
171
|
});
|
|
204
|
-
var play = getPlayerItem();
|
|
205
|
-
play.api.seekTo(state.seekTo);
|
|
206
172
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
207
|
-
}, [state.seekTo,
|
|
173
|
+
}, [state.seekTo, list]);
|
|
208
174
|
// 更新状态
|
|
209
175
|
var updateState = function updateState(newState) {
|
|
210
176
|
var obj = {};
|
|
@@ -221,7 +187,7 @@ function RecordPlayer(_a) {
|
|
|
221
187
|
}
|
|
222
188
|
}
|
|
223
189
|
if (newState.hasOwnProperty('mode')) {
|
|
224
|
-
var item =
|
|
190
|
+
var item = screenList[state.selectIndex];
|
|
225
191
|
var newModes = Object.assign({}, state.modes);
|
|
226
192
|
newModes["".concat(item.cid, "-").concat(item.date)] = newState.mode;
|
|
227
193
|
obj.modes = newModes;
|
|
@@ -239,83 +205,62 @@ function RecordPlayer(_a) {
|
|
|
239
205
|
* 2:不在片断内,查询新的片段,更新mergeSegments和seekTo后交给seek hook处理
|
|
240
206
|
*/
|
|
241
207
|
var onTimeChange = useCallback(function (time, outTimeline) {
|
|
242
|
-
return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
243
|
-
var index
|
|
244
|
-
return _regeneratorRuntime().wrap(function
|
|
208
|
+
return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
209
|
+
var index;
|
|
210
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
245
211
|
while (1) {
|
|
246
|
-
switch (
|
|
212
|
+
switch (_context2.prev = _context2.next) {
|
|
247
213
|
case 0:
|
|
248
|
-
if (!(!Array.isArray(segmentItem.segments) ||
|
|
249
|
-
|
|
214
|
+
if (!(!Array.isArray(segmentItem.segments) || seekLoading)) {
|
|
215
|
+
_context2.next = 2;
|
|
250
216
|
break;
|
|
251
217
|
}
|
|
252
|
-
return
|
|
218
|
+
return _context2.abrupt("return");
|
|
253
219
|
case 2:
|
|
254
220
|
if (!(outTimeline && segmentItem.recordType === 1)) {
|
|
255
|
-
|
|
221
|
+
_context2.next = 5;
|
|
256
222
|
break;
|
|
257
223
|
}
|
|
258
224
|
// 云录像 若点击了缺失的片段,直接忽略
|
|
259
|
-
|
|
260
|
-
return
|
|
225
|
+
console.warn('当前录像片段缺失!');
|
|
226
|
+
return _context2.abrupt("return");
|
|
261
227
|
case 5:
|
|
262
228
|
if (!(time > Date.now())) {
|
|
263
|
-
|
|
229
|
+
_context2.next = 8;
|
|
264
230
|
break;
|
|
265
231
|
}
|
|
266
232
|
console.warn('查询时间超出正常范围!');
|
|
267
|
-
return
|
|
233
|
+
return _context2.abrupt("return");
|
|
268
234
|
case 8:
|
|
269
235
|
index = segmentItem.segments.findIndex(function (v) {
|
|
270
236
|
return time >= v.beginTime && time < v.endTime;
|
|
271
237
|
});
|
|
272
|
-
if (
|
|
273
|
-
|
|
274
|
-
|
|
238
|
+
if (index === -1) {
|
|
239
|
+
// 触发回调
|
|
240
|
+
onTimeLineChange === null || onTimeLineChange === void 0 ? void 0 : onTimeLineChange(time);
|
|
275
241
|
}
|
|
276
|
-
_context.next = 12;
|
|
277
|
-
return queryRecord({
|
|
278
|
-
cid: segmentItem.cid,
|
|
279
|
-
date: time,
|
|
280
|
-
recordType: segmentItem.recordType
|
|
281
|
-
});
|
|
282
|
-
case 12:
|
|
283
|
-
segments = _context.sent;
|
|
284
|
-
setState(function (old) {
|
|
285
|
-
return Object.assign(Object.assign({}, old), {
|
|
286
|
-
loading: true
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
case 14:
|
|
290
242
|
//更新time
|
|
291
243
|
setState(function (old) {
|
|
292
|
-
var mergeSegments = old.mergeSegments;
|
|
293
|
-
if (segments) {
|
|
294
|
-
mergeSegments[old.selectIndex].segments = segments;
|
|
295
|
-
mergeSegments = _toConsumableArray(mergeSegments);
|
|
296
|
-
}
|
|
297
244
|
var currentTimes = Object.assign({}, old.currentTimes);
|
|
298
|
-
var item =
|
|
245
|
+
var item = screenList[old.selectIndex];
|
|
299
246
|
currentTimes["".concat(item.cid, "-").concat(item.date)] = time;
|
|
300
247
|
return Object.assign(Object.assign({}, old), {
|
|
301
248
|
currentTimes: currentTimes,
|
|
302
|
-
|
|
303
|
-
loading: false,
|
|
304
|
-
seekTo: time
|
|
249
|
+
seekTo: Object.assign(Object.assign({}, old.seekTo), _defineProperty({}, "".concat(item.cid, "-").concat(item.date), time))
|
|
305
250
|
});
|
|
306
251
|
});
|
|
307
|
-
case
|
|
252
|
+
case 11:
|
|
308
253
|
case "end":
|
|
309
|
-
return
|
|
254
|
+
return _context2.stop();
|
|
310
255
|
}
|
|
311
256
|
}
|
|
312
|
-
},
|
|
257
|
+
}, _callee2);
|
|
313
258
|
}));
|
|
314
259
|
},
|
|
315
260
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
316
|
-
[segmentItem.cid, segmentItem.recordType, segmentItem.segments,
|
|
261
|
+
[segmentItem.cid, segmentItem.recordType, segmentItem.segments, seekLoading]);
|
|
317
262
|
var _updatePlayer = function updatePlayer(player, index) {
|
|
318
|
-
var item =
|
|
263
|
+
var item = screenList[index];
|
|
319
264
|
playerRef.current["".concat(item.cid, "-").concat(item.date)] = player;
|
|
320
265
|
setState(function (old) {
|
|
321
266
|
return Object.assign({}, old);
|
|
@@ -354,9 +299,9 @@ function RecordPlayer(_a) {
|
|
|
354
299
|
className: "player-layout",
|
|
355
300
|
ref: domRef
|
|
356
301
|
}, screenList.map(function (item, index) {
|
|
357
|
-
var _a, _b
|
|
302
|
+
var _a, _b;
|
|
358
303
|
return item.recordType === 1 ? /*#__PURE__*/React.createElement(SegmentPlayerWithExt, Object.assign({}, item, {
|
|
359
|
-
segments: (
|
|
304
|
+
segments: (item === null || item === void 0 ? void 0 : item.segments) || [],
|
|
360
305
|
key: item.date && item.cid ? "".concat(item === null || item === void 0 ? void 0 : item.date, "-").concat(item.cid) : "".concat(index),
|
|
361
306
|
className: state.selectIndex === index ? 'player-current-index' : '',
|
|
362
307
|
updatePlayer: function updatePlayer(player) {
|
|
@@ -373,13 +318,13 @@ function RecordPlayer(_a) {
|
|
|
373
318
|
width: screenType.width,
|
|
374
319
|
height: screenType.height
|
|
375
320
|
},
|
|
376
|
-
mode: (
|
|
321
|
+
mode: (_a = state.modes["".concat(item === null || item === void 0 ? void 0 : item.date, "-").concat(item.cid)]) !== null && _a !== void 0 ? _a : item.mode,
|
|
377
322
|
fps: fps,
|
|
378
323
|
fpsDelay: fpsDelay,
|
|
379
|
-
httpLoading:
|
|
324
|
+
httpLoading: item.loading
|
|
380
325
|
})) : /*#__PURE__*/React.createElement(FrontendPlayerWithExt, Object.assign({}, item, {
|
|
381
326
|
className: state.selectIndex === index ? 'player-current-index' : '',
|
|
382
|
-
segments: (
|
|
327
|
+
segments: (item === null || item === void 0 ? void 0 : item.segments) || [],
|
|
383
328
|
updatePlayer: function updatePlayer(player) {
|
|
384
329
|
return _updatePlayer(player, index);
|
|
385
330
|
},
|
|
@@ -390,13 +335,13 @@ function RecordPlayer(_a) {
|
|
|
390
335
|
});
|
|
391
336
|
});
|
|
392
337
|
},
|
|
393
|
-
mode: (
|
|
338
|
+
mode: (_b = state.modes["".concat(item === null || item === void 0 ? void 0 : item.date, "-").concat(item.cid)]) !== null && _b !== void 0 ? _b : item.mode,
|
|
394
339
|
key: item.date && item.cid ? "".concat(item === null || item === void 0 ? void 0 : item.date, "-").concat(item.cid) : "".concat(index),
|
|
395
340
|
style: {
|
|
396
341
|
width: screenType.width,
|
|
397
342
|
height: screenType.height
|
|
398
343
|
},
|
|
399
|
-
httpLoading:
|
|
344
|
+
httpLoading: item.loading,
|
|
400
345
|
getLocalRecordUrl: getLocalRecordUrl,
|
|
401
346
|
pluginDownloadUrl: pluginDownloadUrl
|
|
402
347
|
}));
|
|
@@ -34,7 +34,7 @@ function RecordTools(_ref) {
|
|
|
34
34
|
snapshot = _ref.snapshot,
|
|
35
35
|
oneWinExtTools = _ref.oneWinExtTools,
|
|
36
36
|
allWinExtTools = _ref.allWinExtTools;
|
|
37
|
-
var _a;
|
|
37
|
+
var _a, _b, _c;
|
|
38
38
|
var _useFullscreen = useFullscreen(containerRef),
|
|
39
39
|
_useFullscreen2 = _slicedToArray(_useFullscreen, 2),
|
|
40
40
|
isFullscreen = _useFullscreen2[0],
|
|
@@ -128,7 +128,7 @@ function RecordTools(_ref) {
|
|
|
128
128
|
title: "\u9010\u5E27\u64AD\u653E"
|
|
129
129
|
})), /*#__PURE__*/React.createElement(RatePick, {
|
|
130
130
|
onChange: ratechange,
|
|
131
|
-
value: (_a = player === null || player === void 0 ? void 0 : player.video.playbackRate) !== null &&
|
|
131
|
+
value: (_b = (_a = player === null || player === void 0 ? void 0 : player.video) === null || _a === void 0 ? void 0 : _a.playbackRate) !== null && _b !== void 0 ? _b : 1
|
|
132
132
|
}), oneWinExtTools), /*#__PURE__*/React.createElement("div", {
|
|
133
133
|
className: "player-tools-mid"
|
|
134
134
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -146,7 +146,7 @@ function RecordTools(_ref) {
|
|
|
146
146
|
}), /*#__PURE__*/React.createElement("div", {
|
|
147
147
|
className: "player-tools-item",
|
|
148
148
|
onClick: playToggle
|
|
149
|
-
}, player && !player.video.paused ? /*#__PURE__*/React.createElement(IconFont, {
|
|
149
|
+
}, player && !((_c = player.video) === null || _c === void 0 ? void 0 : _c.paused) ? /*#__PURE__*/React.createElement(IconFont, {
|
|
150
150
|
type: "lm-player-Pause_Main",
|
|
151
151
|
title: "\u6682\u505C",
|
|
152
152
|
style: {
|