@cloud-app-dev/vidc 3.1.21 → 3.2.1

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 CHANGED
@@ -35,9 +35,6 @@ export default defineConfig({
35
35
  '/api': {
36
36
  target: 'https://jxsr-eye.antelopecloud.cn/',
37
37
  changeOrigin: true,
38
- onProxyReq(proxyReq: any) {
39
- proxyReq.setHeader('authorization', token);
40
- },
41
38
  },
42
39
  },
43
40
  mfsu:
@@ -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 };
@@ -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
- }, [url]);
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 };
@@ -1,8 +1,4 @@
1
1
  import _useUpdateEffect from "ahooks/es/useUpdateEffect";
2
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
- 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."); }
4
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
2
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
7
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."); }
8
4
  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); }
@@ -34,7 +30,7 @@ function LivePlayer(_a) {
34
30
  var _useState = useState({
35
31
  screenNum: defaultScreen !== null && defaultScreen !== void 0 ? defaultScreen : 4,
36
32
  selectIndex: defaultSelectIndex !== null && defaultSelectIndex !== void 0 ? defaultSelectIndex : 0,
37
- modes: []
33
+ modes: {}
38
34
  }),
39
35
  _useState2 = _slicedToArray(_useState, 2),
40
36
  state = _useState2[0],
@@ -49,7 +45,7 @@ function LivePlayer(_a) {
49
45
  return (_a = options.screenNum) !== null && _a !== void 0 ? _a : state.screenNum;
50
46
  }, [options.screenNum, state.screenNum]);
51
47
  // 缓存所有player对象
52
- var playerRef = useRef([]);
48
+ var playerRef = useRef({});
53
49
  var screenType = useMemo(function () {
54
50
  return ScreenType.find(function (v) {
55
51
  return v.name === screenNum;
@@ -60,8 +56,9 @@ function LivePlayer(_a) {
60
56
  }, [list, screenNum]);
61
57
  // 获取选中player对象
62
58
  var getPlayerItem = function getPlayerItem() {
63
- var _a;
64
- return (_a = playerRef.current[state.selectIndex]) === null || _a === void 0 ? void 0 : _a.current;
59
+ var _a, _b;
60
+ var item = list[state.selectIndex];
61
+ return (_b = (_a = playerRef.current) === null || _a === void 0 ? void 0 : _a[item === null || item === void 0 ? void 0 : item.cid]) === null || _b === void 0 ? void 0 : _b.current;
65
62
  };
66
63
  // 更新状态
67
64
  var updateState = function updateState(newState) {
@@ -79,8 +76,9 @@ function LivePlayer(_a) {
79
76
  }
80
77
  }
81
78
  if (newState.hasOwnProperty('mode')) {
82
- var newModes = _toConsumableArray(state.modes);
83
- newModes[state.selectIndex] = newState.mode;
79
+ var item = list[state.selectIndex];
80
+ var newModes = Object.assign({}, state.modes);
81
+ newModes[item.cid] = newState.mode;
84
82
  obj.modes = newModes;
85
83
  }
86
84
  setState(function (old) {
@@ -126,10 +124,10 @@ function LivePlayer(_a) {
126
124
  }, screenList.map(function (item, index) {
127
125
  var _a, _b;
128
126
  return /*#__PURE__*/React.createElement(LivePlayerWithExt, Object.assign({}, item, {
129
- mode: (_a = state.modes[index]) !== null && _a !== void 0 ? _a : item.mode,
127
+ mode: (_a = state.modes[item.cid]) !== null && _a !== void 0 ? _a : item.mode,
130
128
  key: (_b = item.url) !== null && _b !== void 0 ? _b : "".concat(index),
131
129
  updatePlayer: function updatePlayer(player) {
132
- return playerRef.current[index] = player;
130
+ return playerRef.current[item.cid] = player;
133
131
  },
134
132
  className: state.selectIndex === index ? 'player-current-index' : '',
135
133
  onClick: index !== state.selectIndex ? function () {
@@ -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, queryRecord, onIndexChange, onClose, onCloseAll, download, snapshot, defaultScreen, screenChange, defaultSelectIndex, oneWinExtTools, allWinExtTools, fpsDelay, fps, queryRecordErrorHandle, getLocalRecordUrl, pluginDownloadUrl, ...options }: IRecordPlayerProps): JSX.Element;
9
+ declare function RecordPlayer({ list, children, queryRecord, onIndexChange, onClose, onCloseAll, download, snapshot, defaultScreen, screenChange, defaultSelectIndex, oneWinExtTools, allWinExtTools, fpsDelay, fps, queryRecordErrorHandle, 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
- import "antd/lib/message/style";
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 _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; } } }; }
8
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
9
- 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."); }
10
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
11
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
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, differenceWithIndexs, FILTER_KEY } from './utils';
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';
@@ -29,13 +21,10 @@ import "./index.css";
29
21
  var defaultState = {
30
22
  screenNum: 4,
31
23
  selectIndex: 0,
32
- modes: [],
33
- currentTimes: [],
34
- loading: false,
35
- seekTo: 0,
36
- mergeSegments: [],
37
- timeMode: 24,
38
- winLoadingStatus: []
24
+ modes: {},
25
+ currentTimes: {},
26
+ seekTo: {},
27
+ timeMode: 24
39
28
  };
40
29
  /**
41
30
  * @desc 录像设计的时间全部需要到毫秒
@@ -62,7 +51,9 @@ function RecordPlayer(_a) {
62
51
  queryRecordErrorHandle = _a.queryRecordErrorHandle,
63
52
  getLocalRecordUrl = _a.getLocalRecordUrl,
64
53
  pluginDownloadUrl = _a.pluginDownloadUrl,
65
- options = __rest(_a, ["list", "children", "queryRecord", "onIndexChange", "onClose", "onCloseAll", "download", "snapshot", "defaultScreen", "screenChange", "defaultSelectIndex", "oneWinExtTools", "allWinExtTools", "fpsDelay", "fps", "queryRecordErrorHandle", "getLocalRecordUrl", "pluginDownloadUrl"]);
54
+ onTimeLineChange = _a.onTimeLineChange,
55
+ seekLoading = _a.seekLoading,
56
+ options = __rest(_a, ["list", "children", "queryRecord", "onIndexChange", "onClose", "onCloseAll", "download", "snapshot", "defaultScreen", "screenChange", "defaultSelectIndex", "oneWinExtTools", "allWinExtTools", "fpsDelay", "fps", "queryRecordErrorHandle", "getLocalRecordUrl", "pluginDownloadUrl", "onTimeLineChange", "seekLoading"]);
66
57
  var _useState = useState(Object.assign(Object.assign({}, cloneDeep(defaultState)), {
67
58
  screenNum: defaultScreen !== null && defaultScreen !== void 0 ? defaultScreen : defaultState.screenNum
68
59
  })),
@@ -89,116 +80,99 @@ function RecordPlayer(_a) {
89
80
  var _useVideoFit = useVideoFit(domRef, []),
90
81
  fit = _useVideoFit.fit,
91
82
  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 status = _toConsumableArray(old.winLoadingStatus);
106
- status[idx] = loadding;
107
- return Object.assign(Object.assign({}, old), {
108
- winLoadingStatus: status
109
- });
110
- });
111
- }
112
- });
113
83
  // 缓存所有player对象
114
- var playerRef = useRef([]);
84
+ var playerRef = useRef({});
115
85
  // 获取选中player对象
116
86
  var getPlayerItem = function getPlayerItem() {
117
- var _a;
118
- return (_a = playerRef.current[state.selectIndex]) === null || _a === void 0 ? void 0 : _a.current;
87
+ var _a, _b;
88
+ var item = screenList[state.selectIndex];
89
+ 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;
119
90
  };
120
91
  // 当前窗口信息
121
92
  var segmentItem = useMemo(function () {
122
- return recordList[state.selectIndex] || {};
123
- }, [state.selectIndex, recordList]);
93
+ return screenList[state.selectIndex] || {};
94
+ }, [state.selectIndex, screenList]);
124
95
  var timeBegin = useMemo(function () {
125
96
  return segmentItem.date;
126
97
  }, [segmentItem.date]);
127
98
  var currentTime = useMemo(function () {
128
- return state.currentTimes[state.selectIndex];
129
- }, [state.currentTimes, state.selectIndex]);
130
- /**
131
- * @desc 用户缓存接收list的变化。
132
- */
133
- useEffect(function () {
134
- if (!prevListKey || !listKey) {
135
- return;
99
+ var item = screenList[state.selectIndex];
100
+ if (!item) {
101
+ return undefined;
136
102
  }
137
- var diffIndexs = differenceWithIndexs(listKey.split('-'), prevListKey.split('-'));
138
- if (diffIndexs.length === 0) {
139
- return;
140
- }
141
- setState(function (old) {
142
- var mergeList = old.mergeSegments;
143
- var times = old.currentTimes;
144
- // 批量更新调整
145
- var _iterator = _createForOfIteratorHelper(diffIndexs),
146
- _step;
147
- try {
148
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
149
- var dif = _step.value;
150
- var i = dif.idx;
151
- var item = list[i];
152
- if (!item) {
153
- // 可能是外部的关闭动作关闭
154
- mergeList[i] = undefined;
155
- } else {
156
- if (!mergeList[i]) {
157
- mergeList[i] = cloneDeep(item);
158
- }
159
- mergeList[i].date = item.date;
160
- mergeList[i].segments = mergeList[i].cid !== item.cid ? [] : mergeList[i].segments;
161
- mergeList[i].cid = item.cid;
162
- mergeList[i].recordType = item.recordType;
163
- // 更新变化的currentTime
164
- times[i] = list[i].date;
165
- }
166
- }
167
- } catch (err) {
168
- _iterator.e(err);
169
- } finally {
170
- _iterator.f();
171
- }
172
- return Object.assign(Object.assign({}, old), {
173
- mergeSegments: _toConsumableArray(mergeList),
174
- currentTimes: _toConsumableArray(times)
175
- });
176
- });
177
- }, [list, listKey, prevListKey]);
103
+ return state.currentTimes["".concat(item.cid, "-").concat(item.date)];
104
+ }, [state.currentTimes, screenList, state.selectIndex]);
178
105
  /**
179
106
  * @desc seek hook
180
107
  * 处理seek相关的包括索引和video current time
181
108
  */
182
109
  useEffect(function () {
183
- if (state.seekTo === 0) {
110
+ var _a, _b;
111
+ // 寻找需要seek的item
112
+ var key = Object.keys(state.seekTo).find(function (k) {
113
+ return state.seekTo[k] !== 0;
114
+ });
115
+ if (!key) {
184
116
  return;
185
117
  }
186
- var item = recordList[state.selectIndex];
187
- var index = item.segments.findIndex(function (v) {
188
- return state.seekTo >= v.beginTime && state.seekTo < v.endTime;
118
+ var seekTime = state.seekTo[key];
119
+ var item = list.find(function (v) {
120
+ return !!v && "".concat(v.cid, "-").concat(v.date) === key;
189
121
  });
122
+ var index = (_b = (_a = item === null || item === void 0 ? void 0 : item.segments) === null || _a === void 0 ? void 0 : _a.findIndex(function (v) {
123
+ return seekTime >= v.beginTime && seekTime < v.endTime;
124
+ })) !== null && _b !== void 0 ? _b : -1;
190
125
  if (index === -1) {
191
126
  return;
192
127
  }
193
- setState(function (old) {
194
- return Object.assign(Object.assign({}, old), {
195
- seekTo: 0
128
+ // list变化导致ref被销毁,这里设计了一个处理机制,1s内重试5次,尝试获取新的ref,正常情况下都会获取到播放器初始化很快,还未获取到那么丢弃
129
+ var timer = 0;
130
+ function getPlay(mapkey) {
131
+ var _a;
132
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
133
+ var playRef;
134
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
135
+ while (1) {
136
+ switch (_context.prev = _context.next) {
137
+ case 0:
138
+ playRef = (_a = playerRef.current) === null || _a === void 0 ? void 0 : _a[mapkey];
139
+ if (!(playRef && playRef.current && playRef.current.api)) {
140
+ _context.next = 5;
141
+ break;
142
+ }
143
+ return _context.abrupt("return", playRef.current);
144
+ case 5:
145
+ if (!(timer < 5)) {
146
+ _context.next = 10;
147
+ break;
148
+ }
149
+ timer++;
150
+ _context.next = 9;
151
+ return sleep(200);
152
+ case 9:
153
+ return _context.abrupt("return", sleep(200).then(function () {
154
+ return getPlay(mapkey);
155
+ }));
156
+ case 10:
157
+ return _context.abrupt("return", undefined);
158
+ case 11:
159
+ case "end":
160
+ return _context.stop();
161
+ }
162
+ }
163
+ }, _callee);
164
+ }));
165
+ }
166
+ getPlay(key).then(function (play) {
167
+ play && play.api.seekTo(seekTime);
168
+ setState(function (old) {
169
+ return Object.assign(Object.assign({}, old), {
170
+ seekTo: Object.assign(Object.assign({}, old.seekTo), _defineProperty({}, key, 0))
171
+ });
196
172
  });
197
173
  });
198
- var play = getPlayerItem();
199
- play.api.seekTo(state.seekTo);
200
174
  // eslint-disable-next-line react-hooks/exhaustive-deps
201
- }, [state.seekTo, state.selectIndex, recordList, segmentItem.recordType]);
175
+ }, [state.seekTo, list]);
202
176
  // 更新状态
203
177
  var updateState = function updateState(newState) {
204
178
  var obj = {};
@@ -215,8 +189,9 @@ function RecordPlayer(_a) {
215
189
  }
216
190
  }
217
191
  if (newState.hasOwnProperty('mode')) {
218
- var newModes = _toConsumableArray(state.modes);
219
- newModes[state.selectIndex] = newState.mode;
192
+ var item = screenList[state.selectIndex];
193
+ var newModes = Object.assign({}, state.modes);
194
+ newModes["".concat(item.cid, "-").concat(item.date)] = newState.mode;
220
195
  obj.modes = newModes;
221
196
  }
222
197
  if (newState.hasOwnProperty('timeMode')) {
@@ -232,82 +207,63 @@ function RecordPlayer(_a) {
232
207
  * 2:不在片断内,查询新的片段,更新mergeSegments和seekTo后交给seek hook处理
233
208
  */
234
209
  var onTimeChange = useCallback(function (time, outTimeline) {
235
- return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
236
- var index, segments;
237
- return _regeneratorRuntime().wrap(function _callee$(_context) {
210
+ return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
211
+ var index;
212
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
238
213
  while (1) {
239
- switch (_context.prev = _context.next) {
214
+ switch (_context2.prev = _context2.next) {
240
215
  case 0:
241
- if (!(!Array.isArray(segmentItem.segments) || state.loading)) {
242
- _context.next = 2;
216
+ if (!(!Array.isArray(segmentItem.segments) || seekLoading)) {
217
+ _context2.next = 2;
243
218
  break;
244
219
  }
245
- return _context.abrupt("return");
220
+ return _context2.abrupt("return");
246
221
  case 2:
247
222
  if (!(outTimeline && segmentItem.recordType === 1)) {
248
- _context.next = 5;
223
+ _context2.next = 5;
249
224
  break;
250
225
  }
251
226
  // 云录像 若点击了缺失的片段,直接忽略
252
- _message.warning('当前录像片段缺失!');
253
- return _context.abrupt("return");
227
+ console.warn('当前录像片段缺失!');
228
+ return _context2.abrupt("return");
254
229
  case 5:
255
230
  if (!(time > Date.now())) {
256
- _context.next = 8;
231
+ _context2.next = 8;
257
232
  break;
258
233
  }
259
234
  console.warn('查询时间超出正常范围!');
260
- return _context.abrupt("return");
235
+ return _context2.abrupt("return");
261
236
  case 8:
262
237
  index = segmentItem.segments.findIndex(function (v) {
263
238
  return time >= v.beginTime && time < v.endTime;
264
239
  });
265
- if (!(index === -1)) {
266
- _context.next = 14;
267
- break;
240
+ if (index === -1) {
241
+ // 触发回调
242
+ onTimeLineChange === null || onTimeLineChange === void 0 ? void 0 : onTimeLineChange(time);
268
243
  }
269
- _context.next = 12;
270
- return queryRecord({
271
- cid: segmentItem.cid,
272
- date: time,
273
- recordType: segmentItem.recordType
274
- });
275
- case 12:
276
- segments = _context.sent;
277
- setState(function (old) {
278
- return Object.assign(Object.assign({}, old), {
279
- loading: true
280
- });
281
- });
282
- case 14:
283
244
  //更新time
284
245
  setState(function (old) {
285
- var mergeSegments = old.mergeSegments;
286
- if (segments) {
287
- mergeSegments[old.selectIndex].segments = segments;
288
- mergeSegments = _toConsumableArray(mergeSegments);
289
- }
290
- var currentTimes = _toConsumableArray(old.currentTimes);
291
- currentTimes[old.selectIndex] = time;
246
+ var currentTimes = Object.assign({}, old.currentTimes);
247
+ var item = screenList[old.selectIndex];
248
+ currentTimes["".concat(item.cid, "-").concat(item.date)] = time;
292
249
  return Object.assign(Object.assign({}, old), {
293
250
  currentTimes: currentTimes,
294
- mergeSegments: mergeSegments,
295
- loading: false,
296
- seekTo: time
251
+ seekTo: Object.assign(Object.assign({}, old.seekTo), _defineProperty({}, "".concat(item.cid, "-").concat(item.date), time))
297
252
  });
298
253
  });
299
- case 15:
254
+ case 11:
300
255
  case "end":
301
- return _context.stop();
256
+ return _context2.stop();
302
257
  }
303
258
  }
304
- }, _callee);
259
+ }, _callee2);
305
260
  }));
306
261
  },
307
262
  // eslint-disable-next-line react-hooks/exhaustive-deps
308
- [segmentItem.cid, segmentItem.recordType, segmentItem.segments, state.loading]);
263
+ [segmentItem.cid, segmentItem.recordType, segmentItem.segments, seekLoading]);
309
264
  var _updatePlayer = function updatePlayer(player, index) {
310
- playerRef.current[index] = player;
265
+ var item = screenList[index];
266
+ playerRef.current["".concat(item.cid, "-").concat(item.date)] = player;
311
267
  setState(function (old) {
312
268
  return Object.assign({}, old);
313
269
  });
@@ -345,9 +301,9 @@ function RecordPlayer(_a) {
345
301
  className: "player-layout",
346
302
  ref: domRef
347
303
  }, screenList.map(function (item, index) {
348
- var _a, _b, _c, _d;
304
+ var _a, _b;
349
305
  return item.recordType === 1 ? /*#__PURE__*/React.createElement(SegmentPlayerWithExt, Object.assign({}, item, {
350
- segments: ((_a = recordList[index]) === null || _a === void 0 ? void 0 : _a.segments) || [],
306
+ segments: (item === null || item === void 0 ? void 0 : item.segments) || [],
351
307
  key: item.date && item.cid ? "".concat(item === null || item === void 0 ? void 0 : item.date, "-").concat(item.cid) : "".concat(index),
352
308
  className: state.selectIndex === index ? 'player-current-index' : '',
353
309
  updatePlayer: function updatePlayer(player) {
@@ -364,13 +320,13 @@ function RecordPlayer(_a) {
364
320
  width: screenType.width,
365
321
  height: screenType.height
366
322
  },
367
- mode: (_b = state.modes[index]) !== null && _b !== void 0 ? _b : item.mode,
323
+ mode: (_a = state.modes["".concat(item === null || item === void 0 ? void 0 : item.date, "-").concat(item.cid)]) !== null && _a !== void 0 ? _a : item.mode,
368
324
  fps: fps,
369
325
  fpsDelay: fpsDelay,
370
- httpLoading: state.winLoadingStatus[index]
326
+ httpLoading: item.loading
371
327
  })) : /*#__PURE__*/React.createElement(FrontendPlayerWithExt, Object.assign({}, item, {
372
328
  className: state.selectIndex === index ? 'player-current-index' : '',
373
- segments: ((_c = recordList[index]) === null || _c === void 0 ? void 0 : _c.segments) || [],
329
+ segments: (item === null || item === void 0 ? void 0 : item.segments) || [],
374
330
  updatePlayer: function updatePlayer(player) {
375
331
  return _updatePlayer(player, index);
376
332
  },
@@ -381,13 +337,13 @@ function RecordPlayer(_a) {
381
337
  });
382
338
  });
383
339
  },
384
- mode: (_d = state.modes[index]) !== null && _d !== void 0 ? _d : item.mode,
340
+ mode: (_b = state.modes["".concat(item === null || item === void 0 ? void 0 : item.date, "-").concat(item.cid)]) !== null && _b !== void 0 ? _b : item.mode,
385
341
  key: item.date && item.cid ? "".concat(item === null || item === void 0 ? void 0 : item.date, "-").concat(item.cid) : "".concat(index),
386
342
  style: {
387
343
  width: screenType.width,
388
344
  height: screenType.height
389
345
  },
390
- httpLoading: state.winLoadingStatus[index],
346
+ httpLoading: item.loading,
391
347
  getLocalRecordUrl: getLocalRecordUrl,
392
348
  pluginDownloadUrl: pluginDownloadUrl
393
349
  }));
@@ -397,7 +353,7 @@ function RecordPlayer(_a) {
397
353
  disabled: !segmentItem.cid,
398
354
  width: "70%"
399
355
  }, /*#__PURE__*/React.createElement(RecordTools, {
400
- time: state.currentTimes[state.selectIndex],
356
+ time: state.currentTimes["".concat(segmentItem.cid, "-").concat(segmentItem.date)],
401
357
  fit: fit,
402
358
  toggleFit: toggleFit,
403
359
  getPlayerItem: getPlayerItem,
@@ -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 && _a !== void 0 ? _a : 1
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: {