@cloud-app-dev/vidc 4.0.20 → 4.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/AppContext/Sync.js +42 -0
- package/es/AppContext/index.js +141 -0
- package/es/AppContext/interface.d.ts +41 -0
- package/es/AppContext/static.js +9 -0
- package/es/Auth/index.js +14 -0
- package/es/AutoExit/index.js +19 -0
- package/es/CheckGroupFixed/demo.js +22 -0
- package/es/CheckGroupFixed/index.js +140 -0
- package/es/CheckGroupFixed/index.less +56 -0
- package/es/Config/index.js +77 -0
- package/es/Config/interface.d.ts +65 -0
- package/es/Config/utils.js +33 -0
- package/es/ConfigContext/index.js +21 -0
- package/es/CustomRenderSelect/index.js +72 -0
- package/es/CustomRenderSelect/index.less +25 -0
- package/es/DBTools/index.js +336 -0
- package/es/DisableMark/index.js +19 -0
- package/es/DisableMark/index.less +9 -0
- package/es/DomMove/demo.js +16 -0
- package/es/DomMove/index.js +139 -0
- package/es/DomMove/utils.js +32 -0
- package/es/Drag/DragAndDropItem.js +133 -0
- package/es/Drag/DropItem.js +50 -0
- package/es/Drag/index.d.ts +9 -0
- package/es/Drag/index.js +7 -0
- package/es/Drag/interface.d.ts +16 -0
- package/es/DynamicGridList/Demo.js +77 -0
- package/es/DynamicGridList/index.js +67 -0
- package/es/DynamicList/demo.js +44 -0
- package/es/DynamicList/index.js +86 -0
- package/es/DynamicList/index.less +17 -0
- package/es/DynamicList/interface.d.ts +19 -0
- package/es/DynamicList/utils.js +6 -0
- package/es/ErrorFallback/index.js +31 -0
- package/es/ErrorFallback/inerface.d.ts +48 -0
- package/es/EventTools/index.js +12 -0
- package/es/FrontendPlayer/index.js +2 -0
- package/es/FullScreen/index.js +33 -0
- package/es/FullScreen/index.less +18 -0
- package/es/GridList/Demo.js +80 -0
- package/es/GridList/data.js +609 -0
- package/es/GridList/hook.js +270 -0
- package/es/GridList/index.js +44 -0
- package/es/GridList/index.less +8 -0
- package/es/GridList/interface.d.ts +59 -0
- package/es/GridList/utils.js +42 -0
- package/es/HightLevel/index.js +18 -0
- package/es/HightLevel/index.less +3 -0
- package/es/IconFont/index.js +54 -0
- package/es/ImageView/index.js +51 -0
- package/es/ImageView/index.less +11 -0
- package/es/InstanceHistory/index.js +7 -0
- package/es/LabelPlayer/111.png +0 -0
- package/es/LabelPlayer/demo.js +115 -0
- package/es/LabelPlayer/index.js +160 -0
- package/es/LabelPlayer/index.less +24 -0
- package/es/LabelValue/index.js +27 -0
- package/es/LabelValue/index.less +23 -0
- package/es/List/demo.js +23 -0
- package/es/List/index.js +28 -0
- package/es/List/index.less +20 -0
- package/es/ListWithSizeAnimate/demo.js +98 -0
- package/es/ListWithSizeAnimate/index.js +85 -0
- package/es/ListWithSizeAnimate/index.less +23 -0
- package/es/LoaderScript/index.js +34 -0
- package/es/LoaderScript/utils.js +179 -0
- package/es/Map/AMap.d.ts +7109 -0
- package/es/Map/BasicMap/AMapInstance.js +98 -0
- package/es/Map/BasicMap/LeafletInstance.js +111 -0
- package/es/Map/BasicMap/index.js +90 -0
- package/es/Map/BasicMap/index.less +29 -0
- package/es/Map/ClusterLayer/demo.js +18 -0
- package/es/Map/ClusterLayer/hook.js +123 -0
- package/es/Map/ClusterLayer/index.js +28 -0
- package/es/Map/ClusterLayer/index.less +29 -0
- package/es/Map/ClusterLayer/props.d.ts +8 -0
- package/es/Map/Config/index.js +48 -0
- package/es/Map/Config/utils.js +65 -0
- package/es/Map/Context/index.js +51 -0
- package/es/Map/FindPio/index.js +13 -0
- package/es/Map/FindPio/index.less +7 -0
- package/es/Map/InfoWindow/MakerLikeWindow.js +108 -0
- package/es/Map/InfoWindow/demo.js +70 -0
- package/es/Map/InfoWindow/index.js +62 -0
- package/es/Map/LevelCenter/DragMarker/index.js +42 -0
- package/es/Map/LevelCenter/demo.js +38 -0
- package/es/Map/LevelCenter/index.js +66 -0
- package/es/Map/LoaderMap/index.js +62 -0
- package/es/Map/MapDrawSelect/demo.js +71 -0
- package/es/Map/MapDrawSelect/index.js +56 -0
- package/es/Map/MouseTool/index.js +40 -0
- package/es/Map/MouseTool/useMouseTools.js +83 -0
- package/es/Map/ResetTools/index.js +57 -0
- package/es/Map/ResetTools/index.less +39 -0
- package/es/Map/SinglePoint/demo.js +14 -0
- package/es/Map/SinglePoint/index.js +52 -0
- package/es/Map/SinglePoint/index.less +41 -0
- package/es/Map/hook/useMapEvent.js +19 -0
- package/es/Map/hook/useMapType.js +12 -0
- package/es/Map/icon.js +10 -0
- package/es/Map/index.js +25 -0
- package/es/Map/interface.d.ts +74 -0
- package/es/Map/points.js +1 -0
- package/es/Map/useMarker/index.js +71 -0
- package/es/Map/withMap/index.js +10 -0
- package/es/Picture/component/DefaultRects/RectInfo.js +80 -0
- package/es/Picture/component/DefaultRects/index.js +52 -0
- package/es/Picture/component/DefaultRects/index.less +211 -0
- package/es/Picture/component/DefaultRects/utils.js +11 -0
- package/es/Picture/component/DrawRect/index.js +46 -0
- package/es/Picture/component/DrawRect/index.less +8 -0
- package/es/Picture/component/RectMenu/index.js +76 -0
- package/es/Picture/component/RectMenu/index.less +36 -0
- package/es/Picture/component/RectMenu/utils.js +19 -0
- package/es/Picture/component/Tools/index.js +73 -0
- package/es/Picture/component/Tools/index.less +49 -0
- package/es/Picture/component/WheelScale/index.js +27 -0
- package/es/Picture/demo.js +105 -0
- package/es/Picture/index.js +341 -0
- package/es/Picture/index.less +20 -0
- package/es/Picture/interface.d.ts +196 -0
- package/es/Picture/loadCaptureRectImage.js +99 -0
- package/es/Picture/useDraw.js +103 -0
- package/es/Picture/utils.js +143 -0
- package/es/Player/api/index.js +309 -0
- package/es/Player/context.js +24 -0
- package/es/Player/contraller_bar/bar.js +20 -0
- package/es/Player/contraller_bar/contraller_event.js +48 -0
- package/es/Player/contraller_bar/index.js +27 -0
- package/es/Player/contraller_bar/left_bar.js +83 -0
- package/es/Player/contraller_bar/right_bar.js +32 -0
- package/es/Player/contraller_bar/time.js +19 -0
- package/es/Player/contraller_bar/useBarStatus.js +43 -0
- package/es/Player/contraller_bar/volume.js +62 -0
- package/es/Player/demo.js +266 -0
- package/es/Player/empty.js +4 -0
- package/es/Player/event/errorEvent.js +88 -0
- package/es/Player/event/eventName.js +29 -0
- package/es/Player/event/index.js +205 -0
- package/es/Player/fps_play.js +83 -0
- package/es/Player/frontend_player.js +64 -0
- package/es/Player/frontend_timeline.js +132 -0
- package/es/Player/iconfont.js +16 -0
- package/es/Player/index.js +2 -0
- package/es/Player/live_heart.js +45 -0
- package/es/Player/message.js +133 -0
- package/es/Player/player.d.ts +233 -0
- package/es/Player/segment_player.js +228 -0
- package/es/Player/segment_timeline.js +173 -0
- package/es/Player/single_player.js +262 -0
- package/es/Player/style/bar.less +43 -0
- package/es/Player/style/iconfont.js +43 -0
- package/es/Player/style/index.less +34 -0
- package/es/Player/style/message.less +56 -0
- package/es/Player/style/slider.less +106 -0
- package/es/Player/style/timeline.less +117 -0
- package/es/Player/style/volume.less +24 -0
- package/es/Player/timeline.js +95 -0
- package/es/Player/util.js +189 -0
- package/es/PlayerExt/demo.js +154 -0
- package/es/PlayerExt/index.js +188 -0
- package/es/PlayerExt/index.less +10 -0
- package/es/Progress/index.d.ts +9 -0
- package/es/Progress/index.js +53 -0
- package/es/Progress/index.less +21 -0
- package/es/ROI/demo.js +16 -0
- package/es/ROI/index.js +54 -0
- package/es/ROI/index.less +33 -0
- package/es/RefDrawer/Footer.js +22 -0
- package/es/RefDrawer/demo.js +18 -0
- package/es/RefDrawer/index.js +71 -0
- package/es/RefModal/demo.js +18 -0
- package/es/RefModal/index.js +70 -0
- package/es/ScreenPlayer/Live.js +212 -0
- package/es/ScreenPlayer/LiveTools.js +151 -0
- package/es/ScreenPlayer/PlayerWithExt.js +231 -0
- package/es/ScreenPlayer/RatePick.js +29 -0
- package/es/ScreenPlayer/Record.js +442 -0
- package/es/ScreenPlayer/RecordTools.js +169 -0
- package/es/ScreenPlayer/ScreenSelect.js +46 -0
- package/es/ScreenPlayer/SegmentTimeLine.js +36 -0
- package/es/ScreenPlayer/TimeMode.js +26 -0
- package/es/ScreenPlayer/TimeSelect.js +88 -0
- package/es/ScreenPlayer/demo.js +21 -0
- package/es/ScreenPlayer/demo2.js +194 -0
- package/es/ScreenPlayer/index.js +9 -0
- package/es/ScreenPlayer/index.less +335 -0
- package/es/ScreenPlayer/interface.d.ts +216 -0
- package/es/ScreenPlayer/useTimeSlider.js +456 -0
- package/es/ScreenPlayer/useVideoFit.js +35 -0
- package/es/ScreenPlayer/utils.js +85 -0
- package/es/SegmentPlayer/index.js +2 -0
- package/es/Service/http.js +133 -0
- package/es/Service/index.js +11 -0
- package/es/Service/interface.d.ts +23 -0
- package/es/Service/middleware.js +22 -0
- package/es/SocketEmitter/eventEmitter.js +88 -0
- package/es/SocketEmitter/index.js +125 -0
- package/es/SocketEmitter/interface.d.ts +4 -0
- package/es/TableLayout/index.js +27 -0
- package/es/TableLayout/index.less +4 -0
- package/es/ThemeAntd/demo.js +81 -0
- package/es/ThemeAntd/demo.less +20 -0
- package/es/ThemeAntd/index.js +21 -0
- package/es/ThemeAntd/index.less +4 -0
- package/es/Timeout/index.js +65 -0
- package/es/bigNumberTransformCN/index.js +58 -0
- package/es/cache/index.js +94 -0
- package/es/copy/index.js +9 -0
- package/es/core.d.ts +0 -0
- package/es/getThemeStyle/index.js +5 -0
- package/es/index.js +62 -0
- package/es/likeGo/index.js +31 -0
- package/es/likeGoSync/index.js +10 -0
- package/es/logger/index.js +30 -0
- package/es/nextTick/index.js +3 -0
- package/es/recorder/demo.js +181 -0
- package/es/recorder/index.js +992 -0
- package/es/submidstr/index.js +14 -0
- package/es/treeHelper/index.js +188 -0
- package/es/typings.d.ts +2 -0
- package/es/useDrawROI/index.js +318 -0
- package/es/useEventEmitterHandle/index.js +17 -0
- package/es/useFullscreen/demo.js +43 -0
- package/es/useFullscreen/index.js +76 -0
- package/es/useHistory/index.js +9 -0
- package/es/useHistory/interface.d.ts +3 -0
- package/es/useInfiniteScroll/index.js +102 -0
- package/es/useRafInterval/index.js +70 -0
- package/es/useSimpleState/index.js +35 -0
- package/es/useVirtualList/index.js +136 -0
- package/es/utils.js +46 -0
- package/es/uuid/index.js +19 -0
- package/package.json +2 -3
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
5
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
+
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); }
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
9
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
10
|
+
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
11
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
12
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
13
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
14
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
15
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
16
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
18
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
19
|
+
import { useMemoizedFn } from 'ahooks';
|
|
20
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
21
|
+
import nextTick from "../../nextTick";
|
|
22
|
+
import { likeGo } from "../../utils";
|
|
23
|
+
import { createFlvPlayer, createHlsPlayer } from "../util";
|
|
24
|
+
var Api = /*#__PURE__*/function () {
|
|
25
|
+
function Api(container) {
|
|
26
|
+
var _this = this;
|
|
27
|
+
_classCallCheck(this, Api);
|
|
28
|
+
_defineProperty(this, "container", void 0);
|
|
29
|
+
_defineProperty(this, "play", function () {
|
|
30
|
+
likeGo( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
31
|
+
var _this$video;
|
|
32
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
33
|
+
while (1) switch (_context.prev = _context.next) {
|
|
34
|
+
case 0:
|
|
35
|
+
return _context.abrupt("return", (_this$video = _this.video) === null || _this$video === void 0 ? void 0 : _this$video.play());
|
|
36
|
+
case 1:
|
|
37
|
+
case "end":
|
|
38
|
+
return _context.stop();
|
|
39
|
+
}
|
|
40
|
+
}, _callee);
|
|
41
|
+
})));
|
|
42
|
+
});
|
|
43
|
+
_defineProperty(this, "pause", function () {
|
|
44
|
+
var _this$video2;
|
|
45
|
+
(_this$video2 = _this.video) === null || _this$video2 === void 0 || _this$video2.pause();
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* 设置currentTime实现seek
|
|
49
|
+
* @param {*} seconds
|
|
50
|
+
*/
|
|
51
|
+
_defineProperty(this, "seekTo", function (seconds) {
|
|
52
|
+
if (_this.video) {
|
|
53
|
+
_this.video.currentTime = seconds;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
_defineProperty(this, "setVolume", function (fraction) {
|
|
57
|
+
if (_this.video) {
|
|
58
|
+
_this.video.volume = fraction;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
_defineProperty(this, "getVolume", function () {
|
|
62
|
+
var _this$video3;
|
|
63
|
+
return (_this$video3 = _this.video) === null || _this$video3 === void 0 ? void 0 : _this$video3.volume;
|
|
64
|
+
});
|
|
65
|
+
_defineProperty(this, "mute", function () {
|
|
66
|
+
if (_this.video) {
|
|
67
|
+
_this.video.muted = true;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
_defineProperty(this, "unmute", function () {
|
|
71
|
+
if (_this.video) {
|
|
72
|
+
_this.video.muted = false;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* 开启画中画功能
|
|
77
|
+
*/
|
|
78
|
+
_defineProperty(this, "requestPictureInPicture", function () {
|
|
79
|
+
var _this$video4;
|
|
80
|
+
(_this$video4 = _this.video) === null || _this$video4 === void 0 || _this$video4.requestPictureInPicture();
|
|
81
|
+
});
|
|
82
|
+
/**
|
|
83
|
+
* 关闭画中画功能
|
|
84
|
+
*/
|
|
85
|
+
_defineProperty(this, "exitPictureInPicture", function () {
|
|
86
|
+
if (document.exitPictureInPicture && document.pictureInPictureElement === _this.video) {
|
|
87
|
+
document.exitPictureInPicture();
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
/**
|
|
91
|
+
* 设置播放速率
|
|
92
|
+
* @param {*} rate
|
|
93
|
+
*/
|
|
94
|
+
_defineProperty(this, "setPlaybackRate", function (rate) {
|
|
95
|
+
if (_this.video) {
|
|
96
|
+
_this.video.playbackRate = rate;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
/**
|
|
100
|
+
* 获取视频总时长
|
|
101
|
+
*/
|
|
102
|
+
_defineProperty(this, "getDuration", function () {
|
|
103
|
+
var _ref2 = _this.video || {},
|
|
104
|
+
duration = _ref2.duration,
|
|
105
|
+
seekable = _ref2.seekable;
|
|
106
|
+
if (duration === Infinity && seekable && seekable.length > 0) {
|
|
107
|
+
return seekable.end(seekable.length - 1);
|
|
108
|
+
}
|
|
109
|
+
return duration !== null && duration !== void 0 ? duration : 0;
|
|
110
|
+
});
|
|
111
|
+
/**
|
|
112
|
+
* 获取当前播放时间
|
|
113
|
+
*/
|
|
114
|
+
_defineProperty(this, "getCurrentTime", function () {
|
|
115
|
+
var _this$video$currentTi, _this$video5;
|
|
116
|
+
return (_this$video$currentTi = (_this$video5 = _this.video) === null || _this$video5 === void 0 ? void 0 : _this$video5.currentTime) !== null && _this$video$currentTi !== void 0 ? _this$video$currentTi : 0;
|
|
117
|
+
});
|
|
118
|
+
/**
|
|
119
|
+
* 获取缓存时间
|
|
120
|
+
*/
|
|
121
|
+
_defineProperty(this, "getSecondsLoaded", function () {
|
|
122
|
+
var _this$getBufferedTime;
|
|
123
|
+
return (_this$getBufferedTime = _this.getBufferedTime()[1]) !== null && _this$getBufferedTime !== void 0 ? _this$getBufferedTime : 0;
|
|
124
|
+
});
|
|
125
|
+
/**
|
|
126
|
+
* 获取当前视频缓存的起止时间
|
|
127
|
+
*/
|
|
128
|
+
_defineProperty(this, "getBufferedTime", function () {
|
|
129
|
+
var _buffered$end, _buffered$start, _this$getDuration;
|
|
130
|
+
var _ref3 = _this.video || {},
|
|
131
|
+
buffered = _ref3.buffered;
|
|
132
|
+
if (buffered && buffered.length === 0) {
|
|
133
|
+
return [0, 0];
|
|
134
|
+
}
|
|
135
|
+
var end = (_buffered$end = buffered === null || buffered === void 0 ? void 0 : buffered.end(buffered.length - 1)) !== null && _buffered$end !== void 0 ? _buffered$end : 0;
|
|
136
|
+
var start = (_buffered$start = buffered === null || buffered === void 0 ? void 0 : buffered.start(buffered.length - 1)) !== null && _buffered$start !== void 0 ? _buffered$start : 0;
|
|
137
|
+
var duration = (_this$getDuration = _this.getDuration()) !== null && _this$getDuration !== void 0 ? _this$getDuration : 0;
|
|
138
|
+
if (end > duration) {
|
|
139
|
+
return [start, duration];
|
|
140
|
+
}
|
|
141
|
+
return [start, end];
|
|
142
|
+
});
|
|
143
|
+
/**
|
|
144
|
+
* 视频截屏方法
|
|
145
|
+
*/
|
|
146
|
+
_defineProperty(this, "snapshot", function () {
|
|
147
|
+
var _this$video$videoWidt, _this$video6, _this$video$videoHeig, _this$video7, _ctx;
|
|
148
|
+
var canvas = document.createElement('canvas');
|
|
149
|
+
var ctx = canvas.getContext('2d');
|
|
150
|
+
canvas.width = (_this$video$videoWidt = (_this$video6 = _this.video) === null || _this$video6 === void 0 ? void 0 : _this$video6.videoWidth) !== null && _this$video$videoWidt !== void 0 ? _this$video$videoWidt : 0;
|
|
151
|
+
canvas.height = (_this$video$videoHeig = (_this$video7 = _this.video) === null || _this$video7 === void 0 ? void 0 : _this$video7.videoHeight) !== null && _this$video$videoHeig !== void 0 ? _this$video$videoHeig : 0;
|
|
152
|
+
(_ctx = ctx) === null || _ctx === void 0 || _ctx.drawImage(_this.video, 0, 0, canvas.width, canvas.height);
|
|
153
|
+
setTimeout(function () {
|
|
154
|
+
canvas.remove();
|
|
155
|
+
canvas = null;
|
|
156
|
+
ctx = null;
|
|
157
|
+
}, 200);
|
|
158
|
+
return canvas.toDataURL();
|
|
159
|
+
});
|
|
160
|
+
_defineProperty(this, "unload", function () {});
|
|
161
|
+
_defineProperty(this, "reload", function () {});
|
|
162
|
+
_defineProperty(this, "toggleFit", function () {});
|
|
163
|
+
_defineProperty(this, "openFpsPlay", function () {});
|
|
164
|
+
_defineProperty(this, "closeFpsPlay", function () {});
|
|
165
|
+
_defineProperty(this, "destroy", function () {
|
|
166
|
+
_this.container = null;
|
|
167
|
+
});
|
|
168
|
+
this.container = container;
|
|
169
|
+
}
|
|
170
|
+
_createClass(Api, [{
|
|
171
|
+
key: "video",
|
|
172
|
+
get: function get() {
|
|
173
|
+
return this.container.querySelector('video');
|
|
174
|
+
}
|
|
175
|
+
}, {
|
|
176
|
+
key: "paused",
|
|
177
|
+
get: function get() {
|
|
178
|
+
var _this$video8;
|
|
179
|
+
return (_this$video8 = this.video) === null || _this$video8 === void 0 ? void 0 : _this$video8.paused;
|
|
180
|
+
}
|
|
181
|
+
}, {
|
|
182
|
+
key: "muted",
|
|
183
|
+
get: function get() {
|
|
184
|
+
var _this$video9;
|
|
185
|
+
return (_this$video9 = this.video) === null || _this$video9 === void 0 ? void 0 : _this$video9.muted;
|
|
186
|
+
}
|
|
187
|
+
}]);
|
|
188
|
+
return Api;
|
|
189
|
+
}();
|
|
190
|
+
// 创建播放介质
|
|
191
|
+
export function useTypeAndPlay(url, type, isLive, container, segments, flvConfig, hlsConfig) {
|
|
192
|
+
var _useState = useState({
|
|
193
|
+
type: '',
|
|
194
|
+
flv: undefined,
|
|
195
|
+
hls: undefined
|
|
196
|
+
}),
|
|
197
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
198
|
+
state = _useState2[0],
|
|
199
|
+
setState = _useState2[1];
|
|
200
|
+
useEffect(function () {
|
|
201
|
+
var isReady = container && (url || type === 'flv' && segments);
|
|
202
|
+
if (!isReady) {
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|
|
205
|
+
var video = container.querySelector('video');
|
|
206
|
+
var options = {};
|
|
207
|
+
switch (type) {
|
|
208
|
+
case 'flv':
|
|
209
|
+
options.type = 'flv';
|
|
210
|
+
options.flv = createFlvPlayer(video, url, isLive, flvConfig);
|
|
211
|
+
break;
|
|
212
|
+
case 'hls':
|
|
213
|
+
options.type = 'hls';
|
|
214
|
+
options.hls = createHlsPlayer(video, url, isLive, hlsConfig);
|
|
215
|
+
break;
|
|
216
|
+
default:
|
|
217
|
+
options.type = 'native';
|
|
218
|
+
video === null || video === void 0 || video.setAttribute('src', url !== null && url !== void 0 ? url : '');
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
if (video !== null && video !== void 0 && video.paused) {
|
|
222
|
+
likeGo( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
223
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
224
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
225
|
+
case 0:
|
|
226
|
+
return _context2.abrupt("return", video === null || video === void 0 ? void 0 : video.play());
|
|
227
|
+
case 1:
|
|
228
|
+
case "end":
|
|
229
|
+
return _context2.stop();
|
|
230
|
+
}
|
|
231
|
+
}, _callee2);
|
|
232
|
+
})));
|
|
233
|
+
}
|
|
234
|
+
setState(options);
|
|
235
|
+
return function () {
|
|
236
|
+
if (options.flv) {
|
|
237
|
+
options.flv.pause();
|
|
238
|
+
likeGo( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
239
|
+
var _options$flv;
|
|
240
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
241
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
242
|
+
case 0:
|
|
243
|
+
return _context3.abrupt("return", (_options$flv = options.flv) === null || _options$flv === void 0 ? void 0 : _options$flv.destroy());
|
|
244
|
+
case 1:
|
|
245
|
+
case "end":
|
|
246
|
+
return _context3.stop();
|
|
247
|
+
}
|
|
248
|
+
}, _callee3);
|
|
249
|
+
})));
|
|
250
|
+
} else if (options.hls) {
|
|
251
|
+
video === null || video === void 0 || video.pause();
|
|
252
|
+
likeGo( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
253
|
+
var _options$hls;
|
|
254
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
255
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
256
|
+
case 0:
|
|
257
|
+
return _context4.abrupt("return", (_options$hls = options.hls) === null || _options$hls === void 0 ? void 0 : _options$hls.destroy());
|
|
258
|
+
case 1:
|
|
259
|
+
case "end":
|
|
260
|
+
return _context4.stop();
|
|
261
|
+
}
|
|
262
|
+
}, _callee4);
|
|
263
|
+
})));
|
|
264
|
+
} else {
|
|
265
|
+
video === null || video === void 0 || video.pause();
|
|
266
|
+
video === null || video === void 0 || video.removeAttribute('src');
|
|
267
|
+
}
|
|
268
|
+
setState({});
|
|
269
|
+
};
|
|
270
|
+
}, [url, container, segments, type, isLive, flvConfig, hlsConfig]);
|
|
271
|
+
return [state.type, state.flv, state.hls];
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
//创建Api
|
|
275
|
+
export function usePlayerApi(url, type, isLive, container, segments, flvConfig, hlsConfig) {
|
|
276
|
+
var _useState3 = useState(undefined),
|
|
277
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
278
|
+
api = _useState4[0],
|
|
279
|
+
setApi = _useState4[1];
|
|
280
|
+
var _useState5 = useState(Date.now()),
|
|
281
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
282
|
+
forceKey = _useState6[0],
|
|
283
|
+
setForceKey = _useState6[1];
|
|
284
|
+
var config = useMemo(function () {
|
|
285
|
+
return {
|
|
286
|
+
flvConfig: _objectSpread({}, flvConfig),
|
|
287
|
+
hlsConfig: _objectSpread({}, hlsConfig)
|
|
288
|
+
};
|
|
289
|
+
}, [forceKey]);
|
|
290
|
+
var typePlay = useTypeAndPlay(url, type, isLive, container, segments, config.flvConfig, config.hlsConfig);
|
|
291
|
+
var rePlay = useMemoizedFn(function () {
|
|
292
|
+
return setForceKey(Date.now());
|
|
293
|
+
});
|
|
294
|
+
useEffect(function () {
|
|
295
|
+
if (!container) {
|
|
296
|
+
console.debug('wait create api...');
|
|
297
|
+
return undefined;
|
|
298
|
+
}
|
|
299
|
+
var api = new Api(container);
|
|
300
|
+
setApi(api);
|
|
301
|
+
return function () {
|
|
302
|
+
return nextTick(function () {
|
|
303
|
+
return api.destroy();
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
}, [container, segments]);
|
|
307
|
+
return [api, typePlay, rePlay];
|
|
308
|
+
}
|
|
309
|
+
export default Api;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _excluded = ["children", "getContainer"];
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
9
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
10
|
+
import React from 'react';
|
|
11
|
+
export var Context = /*#__PURE__*/React.createContext(null);
|
|
12
|
+
export function Provider(_ref) {
|
|
13
|
+
var children = _ref.children,
|
|
14
|
+
_ref$getContainer = _ref.getContainer,
|
|
15
|
+
getContainer = _ref$getContainer === void 0 ? function () {
|
|
16
|
+
return document.body;
|
|
17
|
+
} : _ref$getContainer,
|
|
18
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
19
|
+
return /*#__PURE__*/React.createElement(Context.Provider, {
|
|
20
|
+
value: _objectSpread({
|
|
21
|
+
getContainer: getContainer
|
|
22
|
+
}, props)
|
|
23
|
+
}, children);
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var _excluded = ["visibel", "className", "children"];
|
|
2
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
4
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
5
|
+
import React from 'react';
|
|
6
|
+
function Bar(_ref) {
|
|
7
|
+
var _ref$visibel = _ref.visibel,
|
|
8
|
+
visibel = _ref$visibel === void 0 ? true : _ref$visibel,
|
|
9
|
+
_ref$className = _ref.className,
|
|
10
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
11
|
+
children = _ref.children,
|
|
12
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
13
|
+
if (visibel === false) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return /*#__PURE__*/React.createElement("span", _extends({
|
|
17
|
+
className: "contraller-bar-item ".concat(className)
|
|
18
|
+
}, props), children);
|
|
19
|
+
}
|
|
20
|
+
export default Bar;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { useEventListener, useMount } from 'ahooks';
|
|
8
|
+
import React, { useContext, useRef, useState } from 'react';
|
|
9
|
+
import { Context } from "../context";
|
|
10
|
+
import EventName from "../event/eventName";
|
|
11
|
+
function ContrallerEvent(_ref) {
|
|
12
|
+
var children = _ref.children;
|
|
13
|
+
var _useContext = useContext(Context),
|
|
14
|
+
event = _useContext.event,
|
|
15
|
+
container = _useContext.container;
|
|
16
|
+
var timer = useRef();
|
|
17
|
+
var _useState = useState(true),
|
|
18
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
+
visibel = _useState2[0],
|
|
20
|
+
setVisibel = _useState2[1];
|
|
21
|
+
var showContraller = function showContraller() {
|
|
22
|
+
clearTimeout(timer.current);
|
|
23
|
+
setVisibel(true);
|
|
24
|
+
event === null || event === void 0 || event.emit(EventName.SHOW_CONTRALLER);
|
|
25
|
+
};
|
|
26
|
+
var hideContraller = function hideContraller() {
|
|
27
|
+
clearTimeout(timer.current);
|
|
28
|
+
timer.current = setTimeout(function () {
|
|
29
|
+
setVisibel(false);
|
|
30
|
+
event === null || event === void 0 || event.emit(EventName.HIDE_CONTRALLER);
|
|
31
|
+
}, 3 * 1000);
|
|
32
|
+
};
|
|
33
|
+
useMount(function () {
|
|
34
|
+
return hideContraller();
|
|
35
|
+
});
|
|
36
|
+
useEventListener('mouseenter', showContraller, {
|
|
37
|
+
target: container
|
|
38
|
+
});
|
|
39
|
+
useEventListener('mouseleave', hideContraller, {
|
|
40
|
+
target: container
|
|
41
|
+
});
|
|
42
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, React.Children.map(children, function (child) {
|
|
43
|
+
return /*#__PURE__*/React.isValidElement(child) ? /*#__PURE__*/React.cloneElement(child, {
|
|
44
|
+
visibel: visibel
|
|
45
|
+
}) : child;
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
export default ContrallerEvent;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import "../style/bar.less";
|
|
3
|
+
import LeftBar from "./left_bar";
|
|
4
|
+
import RightBar from "./right_bar";
|
|
5
|
+
function ContrallerBar(_ref) {
|
|
6
|
+
var rightExtContents = _ref.rightExtContents,
|
|
7
|
+
rightMidExtContents = _ref.rightMidExtContents,
|
|
8
|
+
visibel = _ref.visibel,
|
|
9
|
+
leftExtContents = _ref.leftExtContents,
|
|
10
|
+
leftMidExtContents = _ref.leftMidExtContents,
|
|
11
|
+
reload = _ref.reload,
|
|
12
|
+
hideTimeProgress = _ref.hideTimeProgress,
|
|
13
|
+
oneFpsPlay = _ref.oneFpsPlay;
|
|
14
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
15
|
+
className: "contraller-bar-layout ".concat(!visibel ? 'hide-contraller-bar' : '')
|
|
16
|
+
}, /*#__PURE__*/React.createElement(LeftBar, {
|
|
17
|
+
oneFpsPlay: oneFpsPlay,
|
|
18
|
+
hideTimeProgress: hideTimeProgress,
|
|
19
|
+
reload: reload,
|
|
20
|
+
leftMidExtContents: leftMidExtContents,
|
|
21
|
+
leftExtContents: leftExtContents
|
|
22
|
+
}), /*#__PURE__*/React.createElement(RightBar, {
|
|
23
|
+
rightExtContents: rightExtContents,
|
|
24
|
+
rightMidExtContents: rightMidExtContents
|
|
25
|
+
})));
|
|
26
|
+
}
|
|
27
|
+
export default ContrallerBar;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import React, { useCallback, useContext, useMemo, useState } from 'react';
|
|
8
|
+
import { Context } from "../context";
|
|
9
|
+
import { useVideoEvent } from "../event";
|
|
10
|
+
import EventName from "../event/eventName";
|
|
11
|
+
import IconFont from "../iconfont";
|
|
12
|
+
import Bar from "./bar";
|
|
13
|
+
import Time from "./time";
|
|
14
|
+
import Volume from "./volume";
|
|
15
|
+
function LeftBar(_ref) {
|
|
16
|
+
var reload = _ref.reload,
|
|
17
|
+
leftExtContents = _ref.leftExtContents,
|
|
18
|
+
leftMidExtContents = _ref.leftMidExtContents,
|
|
19
|
+
hideTimeProgress = _ref.hideTimeProgress,
|
|
20
|
+
oneFpsPlay = _ref.oneFpsPlay;
|
|
21
|
+
var _useContext = useContext(Context),
|
|
22
|
+
api = _useContext.api,
|
|
23
|
+
container = _useContext.container,
|
|
24
|
+
isLive = _useContext.isLive,
|
|
25
|
+
isFpsPlay = _useContext.isFpsPlay,
|
|
26
|
+
event = _useContext.event;
|
|
27
|
+
var _useState = useState(Date.now()),
|
|
28
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29
|
+
dep = _useState2[0],
|
|
30
|
+
setDep = _useState2[1];
|
|
31
|
+
var updateRender = function updateRender() {
|
|
32
|
+
return setDep(Date.now());
|
|
33
|
+
};
|
|
34
|
+
useVideoEvent('play', updateRender);
|
|
35
|
+
useVideoEvent('pause', updateRender);
|
|
36
|
+
useVideoEvent('volumechange', updateRender);
|
|
37
|
+
var video = container === null || container === void 0 ? void 0 : container.querySelector('video');
|
|
38
|
+
//缓存值
|
|
39
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
+
var paused = useMemo(function () {
|
|
41
|
+
return video === null || video === void 0 ? void 0 : video.paused;
|
|
42
|
+
}, [dep, video]);
|
|
43
|
+
var statusIconClassName = useMemo(function () {
|
|
44
|
+
return paused ? 'lm-player-Play_Main' : 'lm-player-Pause_Main';
|
|
45
|
+
}, [paused]);
|
|
46
|
+
var statusText = useMemo(function () {
|
|
47
|
+
return paused ? '播放' : '暂停';
|
|
48
|
+
}, [paused]);
|
|
49
|
+
|
|
50
|
+
//TODO 方法
|
|
51
|
+
var changePlayStatus = useCallback(function () {
|
|
52
|
+
if (video !== null && video !== void 0 && video.paused) {
|
|
53
|
+
var _api$getSecondsLoaded;
|
|
54
|
+
var buffered = (_api$getSecondsLoaded = api === null || api === void 0 ? void 0 : api.getSecondsLoaded()) !== null && _api$getSecondsLoaded !== void 0 ? _api$getSecondsLoaded : 1;
|
|
55
|
+
api === null || api === void 0 || api.seekTo(buffered - 1);
|
|
56
|
+
api === null || api === void 0 || api.play();
|
|
57
|
+
} else {
|
|
58
|
+
api === null || api === void 0 || api.pause();
|
|
59
|
+
}
|
|
60
|
+
}, [video, api]);
|
|
61
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
62
|
+
className: "contraller-left-bar"
|
|
63
|
+
}, leftExtContents, !isFpsPlay && /*#__PURE__*/React.createElement(Bar, null, /*#__PURE__*/React.createElement(IconFont, {
|
|
64
|
+
onClick: changePlayStatus,
|
|
65
|
+
type: statusIconClassName,
|
|
66
|
+
title: statusText
|
|
67
|
+
})), /*#__PURE__*/React.createElement(Bar, null, /*#__PURE__*/React.createElement(Volume, {
|
|
68
|
+
api: api
|
|
69
|
+
})), !isLive && !hideTimeProgress && /*#__PURE__*/React.createElement(Time, null), /*#__PURE__*/React.createElement(Bar, null, /*#__PURE__*/React.createElement(IconFont, {
|
|
70
|
+
onClick: function onClick() {
|
|
71
|
+
event === null || event === void 0 || event.emit(EventName.CLEAR_ERROR_TIMER);
|
|
72
|
+
event === null || event === void 0 || event.emit(EventName.RELOAD_SUCCESS);
|
|
73
|
+
reload();
|
|
74
|
+
},
|
|
75
|
+
type: "lm-player-Refresh_Main",
|
|
76
|
+
title: "\u91CD\u8F7D"
|
|
77
|
+
})), !isLive && oneFpsPlay && /*#__PURE__*/React.createElement(Bar, null, /*#__PURE__*/React.createElement(IconFont, {
|
|
78
|
+
onClick: isFpsPlay ? api === null || api === void 0 ? void 0 : api.closeFpsPlay : api === null || api === void 0 ? void 0 : api.openFpsPlay,
|
|
79
|
+
type: "lm-player-zhuzhenplay",
|
|
80
|
+
title: "\u9010\u5E27\u64AD\u653E"
|
|
81
|
+
})), leftMidExtContents);
|
|
82
|
+
}
|
|
83
|
+
export default LeftBar;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import React, { useContext } from 'react';
|
|
8
|
+
import useFullscreen from "../../useFullscreen";
|
|
9
|
+
import { Context } from "../context";
|
|
10
|
+
import IconFont from "../iconfont";
|
|
11
|
+
import Bar from "./bar";
|
|
12
|
+
function RightBar(_ref) {
|
|
13
|
+
var rightExtContents = _ref.rightExtContents,
|
|
14
|
+
rightMidExtContents = _ref.rightMidExtContents;
|
|
15
|
+
var _useContext = useContext(Context),
|
|
16
|
+
container = _useContext.container;
|
|
17
|
+
var _useFullscreen = useFullscreen(container),
|
|
18
|
+
_useFullscreen2 = _slicedToArray(_useFullscreen, 2),
|
|
19
|
+
isFullScreen = _useFullscreen2[0],
|
|
20
|
+
_useFullscreen2$ = _useFullscreen2[1],
|
|
21
|
+
enterFullscreen = _useFullscreen2$.enterFullscreen,
|
|
22
|
+
exitFullscreen = _useFullscreen2$.exitFullscreen;
|
|
23
|
+
var fullscreen = isFullScreen ? exitFullscreen : enterFullscreen;
|
|
24
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
className: "contraller-right-bar"
|
|
26
|
+
}, rightMidExtContents, /*#__PURE__*/React.createElement(Bar, null, /*#__PURE__*/React.createElement(IconFont, {
|
|
27
|
+
title: isFullScreen ? '窗口' : '全屏',
|
|
28
|
+
onClick: fullscreen,
|
|
29
|
+
type: isFullScreen ? 'lm-player-S_View_ScreenViewExit' : 'lm-player-S_View_ScreenViewFull'
|
|
30
|
+
})), rightExtContents);
|
|
31
|
+
}
|
|
32
|
+
export default RightBar;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { useTimes } from "../timeline";
|
|
9
|
+
import { timeStamp } from "../util";
|
|
10
|
+
function Time() {
|
|
11
|
+
var _useTimes = useTimes(),
|
|
12
|
+
_useTimes2 = _slicedToArray(_useTimes, 3),
|
|
13
|
+
current = _useTimes2[0],
|
|
14
|
+
duration = _useTimes2[2];
|
|
15
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
16
|
+
className: "video-time-progress"
|
|
17
|
+
}, timeStamp(current), "/", timeStamp(duration || 0));
|
|
18
|
+
}
|
|
19
|
+
export default Time;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import { useContext, useState } from 'react';
|
|
14
|
+
import { Context } from "../context";
|
|
15
|
+
import { useRegisterPlayerEvents } from "../event";
|
|
16
|
+
import EventName from "../event/eventName";
|
|
17
|
+
function useBarStatus() {
|
|
18
|
+
var _useContext = useContext(Context),
|
|
19
|
+
event = _useContext.event;
|
|
20
|
+
var _useState = useState({
|
|
21
|
+
status: 1
|
|
22
|
+
}),
|
|
23
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
24
|
+
state = _useState2[0],
|
|
25
|
+
setState = _useState2[1];
|
|
26
|
+
var show = function show() {
|
|
27
|
+
return setState(function (old) {
|
|
28
|
+
return _objectSpread(_objectSpread({}, old), {}, {
|
|
29
|
+
status: 1
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
var hide = function hide() {
|
|
34
|
+
return setState(function (old) {
|
|
35
|
+
return _objectSpread(_objectSpread({}, old), {}, {
|
|
36
|
+
status: 0
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
useRegisterPlayerEvents(event, [[EventName.SHOW_CONTRALLER, show], [EventName.HIDE_CONTRALLER, hide]]);
|
|
41
|
+
return state.status;
|
|
42
|
+
}
|
|
43
|
+
export default useBarStatus;
|