@vtx/player 1.11.0 → 1.12.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.
Files changed (176) hide show
  1. package/lib/api/fetch.js +68 -71
  2. package/lib/api/fetch.js.map +1 -1
  3. package/lib/api/index.js +33 -51
  4. package/lib/api/index.js.map +1 -1
  5. package/lib/api/types.d.ts +14 -7
  6. package/lib/api/types.js +0 -1
  7. package/lib/api/types.js.map +1 -1
  8. package/lib/bd/PlayerManager.js +8 -7
  9. package/lib/bd/PlayerManager.js.map +1 -1
  10. package/lib/bd2.x/PlayerManager.d.ts +71 -0
  11. package/lib/bd2.x/PlayerManager.js +228 -0
  12. package/lib/bd2.x/PlayerManager.js.map +1 -0
  13. package/lib/bd2.x/swfobject-all.d.ts +11 -0
  14. package/lib/bd2.x/swfobject-all.js +158 -0
  15. package/lib/bd2.x/swfobject-all.js.map +1 -0
  16. package/lib/bd2.x/swfobject.d.ts +40 -0
  17. package/lib/bd2.x/swfobject.js +722 -0
  18. package/lib/bd2.x/swfobject.js.map +1 -0
  19. package/lib/bill-player/index.d.ts +1 -1
  20. package/lib/bill-player/index.js +9 -11
  21. package/lib/bill-player/index.js.map +1 -1
  22. package/lib/components/download-tag/index.js +7 -8
  23. package/lib/components/download-tag/index.js.map +1 -1
  24. package/lib/components/set-tag-video/index.js +7 -8
  25. package/lib/components/set-tag-video/index.js.map +1 -1
  26. package/lib/components/split-screen/index.d.ts +1 -1
  27. package/lib/components/split-screen/index.js +3 -5
  28. package/lib/components/split-screen/index.js.map +1 -1
  29. package/lib/components/tag-video/index.js +10 -11
  30. package/lib/components/tag-video/index.js.map +1 -1
  31. package/lib/components/video-scale/index.d.ts +1 -1
  32. package/lib/components/video-scale/index.js +2 -3
  33. package/lib/components/video-scale/index.js.map +1 -1
  34. package/lib/config.d.ts +1 -1
  35. package/lib/config.js +1 -2
  36. package/lib/config.js.map +1 -1
  37. package/lib/context/index.js +3 -5
  38. package/lib/context/index.js.map +1 -1
  39. package/lib/controls/index.d.ts +13 -12
  40. package/lib/controls/index.js +32 -35
  41. package/lib/controls/index.js.map +1 -1
  42. package/lib/h264/PlayerManager.js +8 -7
  43. package/lib/h264/PlayerManager.js.map +1 -1
  44. package/lib/history-control/index.d.ts +2 -2
  45. package/lib/history-control/index.js +8 -10
  46. package/lib/history-control/index.js.map +1 -1
  47. package/lib/history-control-v2/components/grid-item/index.js +33 -13
  48. package/lib/history-control-v2/components/grid-item/index.js.map +1 -1
  49. package/lib/history-control-v2/components/panel/VideoTable.d.ts +4 -2
  50. package/lib/history-control-v2/components/panel/VideoTable.js +265 -59
  51. package/lib/history-control-v2/components/panel/VideoTable.js.map +1 -1
  52. package/lib/history-control-v2/components/panel/index.d.ts +1 -0
  53. package/lib/history-control-v2/components/panel/index.js +40 -19
  54. package/lib/history-control-v2/components/panel/index.js.map +1 -1
  55. package/lib/history-control-v2/context.js +1 -2
  56. package/lib/history-control-v2/context.js.map +1 -1
  57. package/lib/history-control-v2/index.d.ts +4 -4
  58. package/lib/history-control-v2/index.js +77 -77
  59. package/lib/history-control-v2/index.js.map +1 -1
  60. package/lib/history-control-v2/interface.d.ts +20 -11
  61. package/lib/history-control-v2/utils.d.ts +1 -1
  62. package/lib/history-control-v2/utils.js +51 -27
  63. package/lib/history-control-v2/utils.js.map +1 -1
  64. package/lib/history-player/index.d.ts +20 -1
  65. package/lib/history-player/index.js +235 -184
  66. package/lib/history-player/index.js.map +1 -1
  67. package/lib/hooks/useSettings.js +1 -2
  68. package/lib/hooks/useSettings.js.map +1 -1
  69. package/lib/hooks/useTranslation.d.ts +1 -1
  70. package/lib/hooks/useTranslation.js +6 -6
  71. package/lib/hooks/useTranslation.js.map +1 -1
  72. package/lib/icc/PlayerManager.js +9 -8
  73. package/lib/icc/PlayerManager.js.map +1 -1
  74. package/lib/icc/api.d.ts +1 -68
  75. package/lib/icc/api.js +7 -3
  76. package/lib/icc/api.js.map +1 -1
  77. package/lib/icons/index.d.ts +73 -73
  78. package/lib/icons/index.js +112 -141
  79. package/lib/icons/index.js.map +1 -1
  80. package/lib/index.js +1 -1
  81. package/lib/index.js.map +1 -1
  82. package/lib/live-channel-player/index.d.ts +1 -1
  83. package/lib/live-channel-player/index.js +28 -32
  84. package/lib/live-channel-player/index.js.map +1 -1
  85. package/lib/live-control/index.d.ts +4 -2
  86. package/lib/live-control/index.js +21 -13
  87. package/lib/live-control/index.js.map +1 -1
  88. package/lib/live-control-v2/index.d.ts +5 -3
  89. package/lib/live-control-v2/index.js +22 -22
  90. package/lib/live-control-v2/index.js.map +1 -1
  91. package/lib/live-player/index.d.ts +1 -0
  92. package/lib/live-player/index.js +164 -139
  93. package/lib/live-player/index.js.map +1 -1
  94. package/lib/locales/en.json +93 -93
  95. package/lib/locales/index.d.ts +3 -3
  96. package/lib/locales/index.js +15 -24
  97. package/lib/locales/index.js.map +1 -1
  98. package/lib/locales/zh-CN.json +93 -93
  99. package/lib/mpegts/PlayerManager.js +14 -8
  100. package/lib/mpegts/PlayerManager.js.map +1 -1
  101. package/lib/player/BdPlayer.d.ts +7 -2
  102. package/lib/player/BdPlayer.js +138 -47
  103. package/lib/player/BdPlayer.js.map +1 -1
  104. package/lib/player/BdPlayer2.d.ts +117 -0
  105. package/lib/player/BdPlayer2.js +341 -0
  106. package/lib/player/BdPlayer2.js.map +1 -0
  107. package/lib/player/FlvPlayer.d.ts +2 -1
  108. package/lib/player/FlvPlayer.js +17 -20
  109. package/lib/player/FlvPlayer.js.map +1 -1
  110. package/lib/player/H264Player.d.ts +2 -1
  111. package/lib/player/H264Player.js +17 -20
  112. package/lib/player/H264Player.js.map +1 -1
  113. package/lib/player/HkcarwsPlayer.d.ts +10 -1
  114. package/lib/player/HkcarwsPlayer.js +149 -36
  115. package/lib/player/HkcarwsPlayer.js.map +1 -1
  116. package/lib/player/HkwsPlayer.d.ts +19 -1
  117. package/lib/player/HkwsPlayer.js +178 -90
  118. package/lib/player/HkwsPlayer.js.map +1 -1
  119. package/lib/player/HlsPlayer.d.ts +2 -1
  120. package/lib/player/HlsPlayer.js +17 -20
  121. package/lib/player/HlsPlayer.js.map +1 -1
  122. package/lib/player/IccwsPlayer.d.ts +2 -1
  123. package/lib/player/IccwsPlayer.js +19 -22
  124. package/lib/player/IccwsPlayer.js.map +1 -1
  125. package/lib/player/IframePlayer.d.ts +2 -1
  126. package/lib/player/IframePlayer.js +8 -7
  127. package/lib/player/IframePlayer.js.map +1 -1
  128. package/lib/player/Mp4Player.d.ts +2 -1
  129. package/lib/player/Mp4Player.js +17 -20
  130. package/lib/player/Mp4Player.js.map +1 -1
  131. package/lib/player/RslPlayer.d.ts +2 -1
  132. package/lib/player/RslPlayer.js +17 -20
  133. package/lib/player/RslPlayer.js.map +1 -1
  134. package/lib/player/VtxHlsPlayer.d.ts +2 -1
  135. package/lib/player/VtxHlsPlayer.js +17 -20
  136. package/lib/player/VtxHlsPlayer.js.map +1 -1
  137. package/lib/player/VtxwhepPlayer.d.ts +2 -1
  138. package/lib/player/VtxwhepPlayer.js +17 -20
  139. package/lib/player/VtxwhepPlayer.js.map +1 -1
  140. package/lib/player/VtxwsPlayer.d.ts +2 -1
  141. package/lib/player/VtxwsPlayer.js +16 -19
  142. package/lib/player/VtxwsPlayer.js.map +1 -1
  143. package/lib/player/Web34Player.d.ts +172 -0
  144. package/lib/player/Web34Player.js +1912 -0
  145. package/lib/player/Web34Player.js.map +1 -0
  146. package/lib/player/WebrtcPlayer.d.ts +2 -1
  147. package/lib/player/WebrtcPlayer.js +17 -20
  148. package/lib/player/WebrtcPlayer.js.map +1 -1
  149. package/lib/player/WfsPlayer.d.ts +2 -1
  150. package/lib/player/WfsPlayer.js +17 -20
  151. package/lib/player/WfsPlayer.js.map +1 -1
  152. package/lib/player/YsyPlayer.d.ts +116 -0
  153. package/lib/player/YsyPlayer.js +273 -0
  154. package/lib/player/YsyPlayer.js.map +1 -0
  155. package/lib/player/index.d.ts +4 -1
  156. package/lib/player/index.js +22 -1
  157. package/lib/player/index.js.map +1 -1
  158. package/lib/player/indexOld.d.ts +2 -1
  159. package/lib/player/indexOld.js +98 -101
  160. package/lib/player/indexOld.js.map +1 -1
  161. package/lib/rsl/PlayerManager.d.ts +1 -1
  162. package/lib/rsl/PlayerManager.js +8 -7
  163. package/lib/rsl/PlayerManager.js.map +1 -1
  164. package/lib/typings/h5player.d.ts +33 -1
  165. package/lib/utils/index.d.ts +1 -1
  166. package/lib/utils/index.js +16 -27
  167. package/lib/utils/index.js.map +1 -1
  168. package/lib/vtxHls/PlayerManager.js +8 -7
  169. package/lib/vtxHls/PlayerManager.js.map +1 -1
  170. package/lib/vtxHls/WhepManager.js +11 -10
  171. package/lib/vtxHls/WhepManager.js.map +1 -1
  172. package/lib/webrtc/PlayerManager.js +8 -7
  173. package/lib/webrtc/PlayerManager.js.map +1 -1
  174. package/lib/wfs/PlayerManager.js +8 -7
  175. package/lib/wfs/PlayerManager.js.map +1 -1
  176. package/package.json +5 -1
@@ -0,0 +1,1912 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = exports.changeWeb34WindowNum = void 0;
8
+ var _config = _interopRequireDefault(require("../config"));
9
+ var _moment = _interopRequireDefault(require("moment"));
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
11
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
12
+ 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."); }
13
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
14
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
15
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
16
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
17
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
19
+ 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); }
20
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
21
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
22
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
23
+ 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."); }
24
+ 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; } }
25
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
26
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
27
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
28
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
29
+ var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
30
+ function adopt(value) {
31
+ return value instanceof P ? value : new P(function (resolve) {
32
+ resolve(value);
33
+ });
34
+ }
35
+ return new (P || (P = Promise))(function (resolve, reject) {
36
+ function fulfilled(value) {
37
+ try {
38
+ step(generator.next(value));
39
+ } catch (e) {
40
+ reject(e);
41
+ }
42
+ }
43
+ function rejected(value) {
44
+ try {
45
+ step(generator["throw"](value));
46
+ } catch (e) {
47
+ reject(e);
48
+ }
49
+ }
50
+ function step(result) {
51
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
52
+ }
53
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
54
+ });
55
+ };
56
+ var WEB34_PLUGIN_ROOT_ID = 'vtx-web34-plugin-root';
57
+ var WEB34_VIDEO_CTRL_SCRIPT_ID = 'web34-videonode';
58
+ var WEB34_PROXY_COOKIE_NAMES = ['webVideoCtrlProxy', 'webVideoCtrlProxyWs', 'webVideoCtrlProxyWss', 'webVideoCtrlProxyWsChannel'];
59
+ /** 窗口索引计数器,用于为每个播放器实例分配唯一窗口索引 */
60
+ // eslint-disable-next-line no-var
61
+ var windowIndexCounter = 0;
62
+ // eslint-disable-next-line no-var
63
+ var containerIdCounter = 0;
64
+ var DEFAULT_PTZ_SPEED = 4;
65
+ var CUSTOM_WINDOW_READY_TIMEOUT = 5000;
66
+ var WEB34_PLUGIN_READY_STABLE_DELAY = 120;
67
+ var WEB34_PLAYBACK_SWITCH_DELAY = 120;
68
+ var WEB34_RECORD_SEARCH_PAGE_SIZE = 40;
69
+ var WEB34_RECORD_SEARCH_MAX_TIMES = 100;
70
+ var PTZ_COMMAND_MAP = {
71
+ UP: 1,
72
+ DOWN: 2,
73
+ LEFT: 3,
74
+ RIGHT: 4,
75
+ LEFT_UP: 5,
76
+ LEFT_DOWN: 6,
77
+ RIGHT_UP: 7,
78
+ RIGHT_DOWN: 8,
79
+ ZOOM_IN: 10,
80
+ ZOOM_OUT: 11,
81
+ FOCUS_NEAR: 12,
82
+ FOCUS_FAR: 13,
83
+ IRIS_ENLARGE: 14,
84
+ IRIS_REDUCE: 15
85
+ };
86
+ var web34SdkPromise = null;
87
+ var web34InitPromise = null;
88
+ var web34LoginPromises = new Map();
89
+ var web34DeviceRefs = new Map();
90
+ var web34ActiveLoginKeys = new Map();
91
+ var releasedWindowIndexes = [];
92
+ var web34ActiveCount = 0;
93
+ var web34LoginQueue = Promise.resolve();
94
+ var web34StartQueue = Promise.resolve();
95
+ var web34CustomWindowUnavailable = false;
96
+ var getWeb34BasePath = function getWeb34BasePath() {
97
+ var _a;
98
+ var visPlugin = ((_a = window.VtxPublicServiceAddress) === null || _a === void 0 ? void 0 : _a.visPlugin) || _config["default"].visPlugin || './resources';
99
+ return "".concat(visPlugin.replace(/\/$/, ''), "/web3.4");
100
+ };
101
+ var getWeb34LastError = function getWeb34LastError() {
102
+ var _a, _b;
103
+ try {
104
+ return (_b = (_a = window.WebVideoCtrl) === null || _a === void 0 ? void 0 : _a.I_GetLastError) === null || _b === void 0 ? void 0 : _b.call(_a);
105
+ } catch (error) {
106
+ return error;
107
+ }
108
+ };
109
+ var logWeb34SdkError = function logWeb34SdkError(apiName, detail) {
110
+ console.error("[web3.4 SDK] ".concat(apiName, " failed"), {
111
+ errorCode: getWeb34LastError(),
112
+ detail: detail
113
+ });
114
+ };
115
+ var logWeb34Login = function logWeb34Login(message, detail) {
116
+ console.info("[web3.4 login] ".concat(message), detail || '');
117
+ };
118
+ var isMissingCustomWindowMethodError = function isMissingCustomWindowMethodError(error) {
119
+ return /JS_CreateCustomPlayWindows.*not a function/.test((error === null || error === void 0 ? void 0 : error.message) || String(error || ''));
120
+ };
121
+ var isWeb34CompatibleCtrl = function isWeb34CompatibleCtrl() {
122
+ var sdk = window.WebVideoCtrl;
123
+ return typeof (sdk === null || sdk === void 0 ? void 0 : sdk.I_SupportNoPlugin) === 'function' && typeof (sdk === null || sdk === void 0 ? void 0 : sdk.I_InitPlugin) === 'function' && typeof (sdk === null || sdk === void 0 ? void 0 : sdk.I_InsertOBJECTPlugin) === 'function' && typeof (sdk === null || sdk === void 0 ? void 0 : sdk.I_CreateCustomPlayWindows) === 'function' && typeof (sdk === null || sdk === void 0 ? void 0 : sdk.I_UpdateCustomContainer) === 'function';
124
+ };
125
+ var removeScript = function removeScript(id) {
126
+ var script = document.getElementById(id);
127
+ if (script === null || script === void 0 ? void 0 : script.parentNode) {
128
+ script.parentNode.removeChild(script);
129
+ }
130
+ };
131
+ var clearCookieValue = function clearCookieValue(name) {
132
+ document.cookie = "".concat(name, "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/");
133
+ };
134
+ var clearWeb34ProxyCookies = function clearWeb34ProxyCookies() {
135
+ WEB34_PROXY_COOKIE_NAMES.forEach(clearCookieValue);
136
+ };
137
+ var safeDecodeUrlValue = function safeDecodeUrlValue() {
138
+ var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
139
+ try {
140
+ return decodeURIComponent(value);
141
+ } catch (error) {
142
+ return value;
143
+ }
144
+ };
145
+ var getDefaultUrlPort = function getDefaultUrlPort() {
146
+ var protocol = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
147
+ return ['https:', 'wss:'].includes(protocol) ? '443' : '80';
148
+ };
149
+ var _getWeb34UrlAddress = function getWeb34UrlAddress() {
150
+ var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
151
+ var fallbackUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
152
+ try {
153
+ var parsedUrl = new URL(url);
154
+ if (parsedUrl.hostname) {
155
+ return {
156
+ hostname: parsedUrl.hostname,
157
+ port: parsedUrl.port || getDefaultUrlPort(parsedUrl.protocol)
158
+ };
159
+ }
160
+ } catch (error) {
161
+ // Try the fallback URL below.
162
+ }
163
+ if (fallbackUrl && fallbackUrl !== url) {
164
+ return _getWeb34UrlAddress(fallbackUrl);
165
+ }
166
+ return {
167
+ hostname: '',
168
+ port: '443'
169
+ };
170
+ };
171
+ var getXmlText = function getXmlText(xmlDoc, tagName) {
172
+ var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
173
+ var _a, _b;
174
+ return ((_b = (_a = xmlDoc.getElementsByTagName(tagName)) === null || _a === void 0 ? void 0 : _a[index]) === null || _b === void 0 ? void 0 : _b.textContent) || '';
175
+ };
176
+ var normalizeWeb34RecordTime = function normalizeWeb34RecordTime() {
177
+ var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
178
+ return time.replace('T', ' ').replace('Z', '');
179
+ };
180
+ var hasMomentInputValue = function hasMomentInputValue(time) {
181
+ return typeof time !== 'undefined' && time !== null && time !== '';
182
+ };
183
+ var getWeb34PlaybackParam = function getWeb34PlaybackParam(playbackURI, name) {
184
+ var match = playbackURI.match(new RegExp("[?&]".concat(name, "=([^&]*)")));
185
+ if (match) return safeDecodeUrlValue(match[1]);
186
+ var startIndex = playbackURI.indexOf("".concat(name, "="));
187
+ if (startIndex < 0) return '';
188
+ var valueStartIndex = startIndex + name.length + 1;
189
+ var valueEndIndex = playbackURI.indexOf('&', valueStartIndex);
190
+ var value = valueEndIndex < 0 ? playbackURI.slice(valueStartIndex) : playbackURI.slice(valueStartIndex, valueEndIndex);
191
+ return safeDecodeUrlValue(value);
192
+ };
193
+ var parseWeb34RecordItems = function parseWeb34RecordItems(xmlDoc) {
194
+ var items = Array.from(xmlDoc.getElementsByTagName('searchMatchItem'));
195
+ return items.map(function (item) {
196
+ var _a, _b, _c, _d, _e, _f;
197
+ var playbackURI = ((_b = (_a = item.getElementsByTagName('playbackURI')) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.textContent) || '';
198
+ if (!playbackURI || playbackURI.indexOf('name=') < 0) return null;
199
+ var beginTime = normalizeWeb34RecordTime(((_d = (_c = item.getElementsByTagName('startTime')) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.textContent) || '');
200
+ var endTime = normalizeWeb34RecordTime(((_f = (_e = item.getElementsByTagName('endTime')) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.textContent) || '');
201
+ var fileName = getWeb34PlaybackParam(playbackURI, 'name');
202
+ var size = Number(getWeb34PlaybackParam(playbackURI, 'size')) || 0;
203
+ return {
204
+ beginTime: beginTime,
205
+ endTime: endTime,
206
+ playbackUrl: playbackURI,
207
+ enableAgent: false,
208
+ size: size,
209
+ code: fileName,
210
+ downloadTaskUrl: ''
211
+ };
212
+ }).filter(Boolean);
213
+ };
214
+ var EMPTY_WEB34_CREDENTIALS = {
215
+ userName: '',
216
+ password: '',
217
+ source: ''
218
+ };
219
+ var pickWeb34QueryValue = function pickWeb34QueryValue(searchParams, keys) {
220
+ var entries = Array.from(searchParams.entries());
221
+ var _iterator = _createForOfIteratorHelper(keys),
222
+ _step;
223
+ try {
224
+ var _loop = function _loop() {
225
+ var key = _step.value;
226
+ var exactValue = searchParams.get(key);
227
+ if (exactValue) return {
228
+ v: exactValue
229
+ };
230
+ var matched = entries.find(function (_ref) {
231
+ var _ref2 = _slicedToArray(_ref, 1),
232
+ name = _ref2[0];
233
+ return name.toLowerCase() === key.toLowerCase();
234
+ });
235
+ if (matched === null || matched === void 0 ? void 0 : matched[1]) return {
236
+ v: matched[1]
237
+ };
238
+ },
239
+ _ret;
240
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
241
+ _ret = _loop();
242
+ if (_ret) return _ret.v;
243
+ }
244
+ } catch (err) {
245
+ _iterator.e(err);
246
+ } finally {
247
+ _iterator.f();
248
+ }
249
+ return '';
250
+ };
251
+ var getWeb34UrlAuthorityCredentials = function getWeb34UrlAuthorityCredentials(url, source) {
252
+ var schemeMatch = url.match(/^[a-z][a-z\d+.-]*:\/\//i);
253
+ if (!schemeMatch) return EMPTY_WEB34_CREDENTIALS;
254
+ var restUrl = url.slice(schemeMatch[0].length);
255
+ var authEndIndex = restUrl.lastIndexOf('@');
256
+ if (authEndIndex <= 0) return EMPTY_WEB34_CREDENTIALS;
257
+ var userInfo = restUrl.slice(0, authEndIndex);
258
+ if (!userInfo || userInfo.includes('/')) return EMPTY_WEB34_CREDENTIALS;
259
+ var splitIndex = userInfo.indexOf(':');
260
+ if (splitIndex < 0) {
261
+ return {
262
+ userName: safeDecodeUrlValue(userInfo),
263
+ password: '',
264
+ source: source
265
+ };
266
+ }
267
+ return {
268
+ userName: safeDecodeUrlValue(userInfo.slice(0, splitIndex)),
269
+ password: safeDecodeUrlValue(userInfo.slice(splitIndex + 1)),
270
+ source: source
271
+ };
272
+ };
273
+ var _getWeb34UrlCredentials = function getWeb34UrlCredentials() {
274
+ var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
275
+ var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'url';
276
+ if (!url) return EMPTY_WEB34_CREDENTIALS;
277
+ try {
278
+ var u = new URL(url);
279
+ if (u.username || u.password) {
280
+ return {
281
+ userName: safeDecodeUrlValue(u.username),
282
+ password: safeDecodeUrlValue(u.password),
283
+ source: source
284
+ };
285
+ }
286
+ var queryUserName = pickWeb34QueryValue(u.searchParams, ['userName', 'username', 'user', 'account', 'loginName', 'szUserName']);
287
+ var queryPassword = pickWeb34QueryValue(u.searchParams, ['password', 'passwd', 'pwd', 'szPassword']);
288
+ if (queryUserName || queryPassword) {
289
+ return {
290
+ userName: safeDecodeUrlValue(queryUserName),
291
+ password: safeDecodeUrlValue(queryPassword),
292
+ source: "".concat(source, ".query")
293
+ };
294
+ }
295
+ var nestedUrl = Array.from(u.searchParams.values()).find(function (value) {
296
+ return /^[a-z][a-z\d+.-]*:\/\//i.test(value);
297
+ });
298
+ if (nestedUrl) return _getWeb34UrlCredentials(nestedUrl, "".concat(source, ".queryUrl"));
299
+ } catch (error) {
300
+ var authorityCredentials = getWeb34UrlAuthorityCredentials(url, "".concat(source, ".authority"));
301
+ if (authorityCredentials.userName || authorityCredentials.password) {
302
+ return authorityCredentials;
303
+ }
304
+ }
305
+ return getWeb34UrlAuthorityCredentials(url, "".concat(source, ".authority"));
306
+ };
307
+ var resolveWeb34Credentials = function resolveWeb34Credentials(_ref3) {
308
+ var _ref3$userName = _ref3.userName,
309
+ userName = _ref3$userName === void 0 ? '' : _ref3$userName,
310
+ _ref3$password = _ref3.password,
311
+ password = _ref3$password === void 0 ? '' : _ref3$password,
312
+ _ref3$url = _ref3.url,
313
+ url = _ref3$url === void 0 ? '' : _ref3$url,
314
+ _ref3$originalUrl = _ref3.originalUrl,
315
+ originalUrl = _ref3$originalUrl === void 0 ? '' : _ref3$originalUrl;
316
+ if (userName || password) {
317
+ return {
318
+ userName: userName,
319
+ password: password,
320
+ source: 'params'
321
+ };
322
+ }
323
+ var urlCredentials = _getWeb34UrlCredentials(url, 'url');
324
+ if (urlCredentials.userName || urlCredentials.password) return urlCredentials;
325
+ var originalUrlCredentials = _getWeb34UrlCredentials(originalUrl, 'originalUrl');
326
+ if (originalUrlCredentials.userName || originalUrlCredentials.password) {
327
+ return originalUrlCredentials;
328
+ }
329
+ return {
330
+ userName: 'admin',
331
+ password: '',
332
+ source: 'default'
333
+ };
334
+ };
335
+ var getWeb34AuthCacheKey = function getWeb34AuthCacheKey(userName, password) {
336
+ var text = "".concat(userName, "\0").concat(password);
337
+ var hash = 7;
338
+ for (var i = 0; i < text.length; i += 1) {
339
+ hash = (hash * 31 + text.charCodeAt(i)) % 2147483647;
340
+ }
341
+ return "auth_".concat(hash.toString(36));
342
+ };
343
+ var runWeb34StartTask = function runWeb34StartTask(task) {
344
+ var result = web34StartQueue["catch"](function () {
345
+ return undefined;
346
+ }).then(task);
347
+ web34StartQueue = result.then(function () {
348
+ return undefined;
349
+ }, function () {
350
+ return undefined;
351
+ });
352
+ return result;
353
+ };
354
+ var runWeb34LoginTask = function runWeb34LoginTask(task) {
355
+ var result = web34LoginQueue["catch"](function () {
356
+ return undefined;
357
+ }).then(task);
358
+ web34LoginQueue = result.then(function () {
359
+ return undefined;
360
+ }, function () {
361
+ return undefined;
362
+ });
363
+ return result;
364
+ };
365
+ var sleep = function sleep(time) {
366
+ return new Promise(function (resolve) {
367
+ return window.setTimeout(resolve, time);
368
+ });
369
+ };
370
+ var loadScript = function loadScript(src, id) {
371
+ var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
372
+ return new Promise(function (resolve, reject) {
373
+ if (id && document.getElementById(id) && !force) {
374
+ resolve();
375
+ return;
376
+ }
377
+ if (id && force) removeScript(id);
378
+ var script = document.createElement('script');
379
+ if (id) script.id = id;
380
+ script.src = src;
381
+ script.type = 'text/javascript';
382
+ script.onload = function () {
383
+ return resolve();
384
+ };
385
+ script.onerror = function () {
386
+ return reject(new Error("Failed to load ".concat(src)));
387
+ };
388
+ document.head.appendChild(script);
389
+ });
390
+ };
391
+ var loadWeb34Sdk = function loadWeb34Sdk() {
392
+ if (web34SdkPromise) return web34SdkPromise;
393
+ web34SdkPromise = function () {
394
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee() {
395
+ var _a, _b, _c, basePath;
396
+ return _regenerator().w(function (_context) {
397
+ while (1) switch (_context.n) {
398
+ case 0:
399
+ basePath = getWeb34BasePath();
400
+ _context.n = 1;
401
+ return loadScript("".concat(basePath, "/jsPlugin/jquery.min.js"), 'web34-jquery');
402
+ case 1:
403
+ _context.n = 2;
404
+ return loadScript("".concat(basePath, "/encryption/AES.js"), 'web34-aes');
405
+ case 2:
406
+ _context.n = 3;
407
+ return loadScript("".concat(basePath, "/encryption/cryptico.min.js"), 'web34-cryptico');
408
+ case 3:
409
+ _context.n = 4;
410
+ return loadScript("".concat(basePath, "/encryption/crypto-3.1.2.min.js"), 'web34-crypto');
411
+ case 4:
412
+ if (isWeb34CompatibleCtrl()) {
413
+ _context.n = 5;
414
+ break;
415
+ }
416
+ if (window.WebVideoCtrl) {
417
+ console.warn('[web3.4 SDK] incompatible WebVideoCtrl detected, reload web3.4 sdk.');
418
+ window.WebVideoCtrl = undefined;
419
+ }
420
+ _context.n = 5;
421
+ return loadScript("".concat(basePath, "/webVideoCtrl.js"), WEB34_VIDEO_CTRL_SCRIPT_ID, true);
422
+ case 5:
423
+ if ((_b = (_a = window.WebVideoCtrl) === null || _a === void 0 ? void 0 : _a.I_SupportNoPlugin) === null || _b === void 0 ? void 0 : _b.call(_a)) {
424
+ _context.n = 6;
425
+ break;
426
+ }
427
+ logWeb34SdkError('I_SupportNoPlugin');
428
+ throw new Error('Current browser does not support web3.4 no-plugin mode.');
429
+ case 6:
430
+ if (isWeb34CompatibleCtrl()) {
431
+ _context.n = 7;
432
+ break;
433
+ }
434
+ logWeb34SdkError('WebVideoCtrl.compatible', {
435
+ basePath: basePath,
436
+ sdkVersion: (_c = window.WebVideoCtrl) === null || _c === void 0 ? void 0 : _c.version,
437
+ methods: Object.keys(window.WebVideoCtrl || {})
438
+ });
439
+ throw new Error('Loaded WebVideoCtrl does not support web3.4 custom play windows.');
440
+ case 7:
441
+ return _context.a(2);
442
+ }
443
+ }, _callee);
444
+ }));
445
+ }()["catch"](function (error) {
446
+ web34SdkPromise = null;
447
+ throw error;
448
+ });
449
+ return web34SdkPromise;
450
+ };
451
+ var ensureWeb34PluginRoot = function ensureWeb34PluginRoot() {
452
+ var root = document.getElementById(WEB34_PLUGIN_ROOT_ID);
453
+ if (root) return root.id;
454
+ root = document.createElement('div');
455
+ root.id = WEB34_PLUGIN_ROOT_ID;
456
+ root.style.position = 'fixed';
457
+ root.style.left = '-9999px';
458
+ root.style.top = '-9999px';
459
+ root.style.width = '1px';
460
+ root.style.height = '1px';
461
+ root.style.overflow = 'hidden';
462
+ root.style.pointerEvents = 'none';
463
+ document.body.appendChild(root);
464
+ return root.id;
465
+ };
466
+ var ensureContainerId = function ensureContainerId(container) {
467
+ if (!container) return '';
468
+ if (container.id) return container.id;
469
+ containerIdCounter += 1;
470
+ container.id = "vtx_web34_player_".concat(Date.now(), "_").concat(containerIdCounter);
471
+ return container.id;
472
+ };
473
+ var allocateWindowIndex = function allocateWindowIndex() {
474
+ var index = releasedWindowIndexes.shift();
475
+ if (typeof index === 'number') return index;
476
+ return windowIndexCounter++;
477
+ };
478
+ var releaseWindowIndex = function releaseWindowIndex(index) {
479
+ if (releasedWindowIndexes.includes(index)) return;
480
+ releasedWindowIndexes.push(index);
481
+ releasedWindowIndexes.sort(function (a, b) {
482
+ return a - b;
483
+ });
484
+ };
485
+ var changeWeb34WindowNum = exports.changeWeb34WindowNum = function changeWeb34WindowNum(windowNum) {
486
+ var _a, _b;
487
+ var result = (_b = (_a = window.WebVideoCtrl) === null || _a === void 0 ? void 0 : _a.I_ChangeWndNum) === null || _b === void 0 ? void 0 : _b.call(_a, windowNum);
488
+ if (result === null || result === void 0 ? void 0 : result["catch"]) {
489
+ result["catch"](function (error) {
490
+ logWeb34SdkError('I_ChangeWndNum', {
491
+ windowNum: windowNum,
492
+ error: error
493
+ });
494
+ });
495
+ }
496
+ return result;
497
+ };
498
+ var initWeb34Plugin = function initWeb34Plugin() {
499
+ var maxWndNum = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 25;
500
+ var currentSplit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
501
+ if (web34InitPromise) return web34InitPromise;
502
+ web34InitPromise = new Promise(function (resolve, reject) {
503
+ var containerId = ensureWeb34PluginRoot();
504
+ var finished = false;
505
+ var timer;
506
+ var clearTimer = function clearTimer() {
507
+ if (timer) {
508
+ window.clearInterval(timer);
509
+ timer = undefined;
510
+ }
511
+ };
512
+ var rejectInit = function rejectInit(error) {
513
+ if (finished) return;
514
+ finished = true;
515
+ clearTimer();
516
+ reject(error);
517
+ };
518
+ var finishInit = function finishInit() {
519
+ var _a, _b;
520
+ if (finished) return;
521
+ var insertResult = window.WebVideoCtrl.I_InsertOBJECTPlugin(containerId);
522
+ if (insertResult === -1) {
523
+ var updateResult = (_b = (_a = window.WebVideoCtrl) === null || _a === void 0 ? void 0 : _a.I_UpdateCustomContainer) === null || _b === void 0 ? void 0 : _b.call(_a);
524
+ if (updateResult === -1) {
525
+ logWeb34SdkError('I_InsertOBJECTPlugin', {
526
+ result: insertResult,
527
+ containerId: containerId
528
+ });
529
+ rejectInit(new Error(resolveNoPluginInitError({
530
+ sdk: window.WebVideoCtrl,
531
+ fallback: 'web3.4 no-plugin insert failed'
532
+ })));
533
+ return;
534
+ }
535
+ }
536
+ finished = true;
537
+ clearTimer();
538
+ resolve();
539
+ };
540
+ var scheduleFinishInit = function scheduleFinishInit() {
541
+ if (finished) return;
542
+ clearTimer();
543
+ window.setTimeout(finishInit, WEB34_PLUGIN_READY_STABLE_DELAY);
544
+ };
545
+ var startWaitPluginReady = function startWaitPluginReady() {
546
+ var startTime = Date.now();
547
+ timer = window.setInterval(function () {
548
+ if (window.JSPlugin) {
549
+ scheduleFinishInit();
550
+ return;
551
+ }
552
+ if (Date.now() - startTime >= 10000) {
553
+ rejectInit(new Error('web3.4 no-plugin init timeout.'));
554
+ }
555
+ }, 100);
556
+ };
557
+ var result = window.WebVideoCtrl.I_InitPlugin('100%', '100%', {
558
+ szContainerID: containerId,
559
+ szBasePath: getWeb34BasePath(),
560
+ bWndFull: true,
561
+ iPackageType: 2,
562
+ iMaxSplit: Math.ceil(Math.sqrt(maxWndNum)),
563
+ iWndowType: currentSplit,
564
+ bNoPlugin: true,
565
+ bDebugMode: true,
566
+ supportCustomContainer: true,
567
+ maxWndNum: maxWndNum,
568
+ customContainerStyle: 'relative',
569
+ cbInitPluginComplete: scheduleFinishInit,
570
+ cbPluginErrorHandler: function cbPluginErrorHandler(_index, code, error) {
571
+ logWeb34SdkError('I_InitPlugin.cbPluginErrorHandler', {
572
+ index: _index,
573
+ code: code,
574
+ error: error
575
+ });
576
+ }
577
+ });
578
+ if (result === -1) {
579
+ logWeb34SdkError('I_InitPlugin', {
580
+ result: result,
581
+ containerId: containerId
582
+ });
583
+ }
584
+ startWaitPluginReady();
585
+ })["catch"](function (error) {
586
+ web34InitPromise = null;
587
+ throw error;
588
+ });
589
+ return web34InitPromise;
590
+ };
591
+ /**
592
+ * web3.4 无插件播放器
593
+ */
594
+ var Player = /*#__PURE__*/function () {
595
+ function Player(params) {
596
+ var _this = this;
597
+ _classCallCheck(this, Player);
598
+ this.containerId = '';
599
+ this.deviceIp = '';
600
+ this.devicePort = '';
601
+ this.userName = '';
602
+ this.password = '';
603
+ this.credentialsSource = '';
604
+ this.preSpeed = 1;
605
+ this.playing = false;
606
+ this.destroyed = false;
607
+ this.autoWindowIndex = true;
608
+ this.maxSplit = 25;
609
+ this.currentSplit = 1;
610
+ this.acquiredLoginKey = '';
611
+ this.recordSearchKey = '';
612
+ var _params$url = params.url,
613
+ url = _params$url === void 0 ? '' : _params$url,
614
+ originalUrl = params.originalUrl,
615
+ _params$channelNum = params.channelNum,
616
+ channelNum = _params$channelNum === void 0 ? '' : _params$channelNum,
617
+ _params$channelId = params.channelId,
618
+ channelId = _params$channelId === void 0 ? '' : _params$channelId,
619
+ deviceCode = params.deviceCode,
620
+ deviceIp = params.deviceIp,
621
+ devicePort = params.devicePort,
622
+ userName = params.userName,
623
+ password = params.password,
624
+ _params$enableAgent = params.enableAgent,
625
+ enableAgent = _params$enableAgent === void 0 ? false : _params$enableAgent,
626
+ container = params.container,
627
+ startTime = params.startTime,
628
+ endTime = params.endTime,
629
+ recordSearchStartTime = params.recordSearchStartTime,
630
+ recordSearchEndTime = params.recordSearchEndTime,
631
+ streamType = params.streamType,
632
+ reload = params.reload,
633
+ onClose = params.onClose,
634
+ onRecordSearch = params.onRecordSearch,
635
+ windowIndex = params.windowIndex,
636
+ maxSplit = params.maxSplit,
637
+ currentSplit = params.currentSplit;
638
+ this.url = url;
639
+ this.originalUrl = originalUrl || url;
640
+ this.channelNum = channelNum;
641
+ this.channelId = channelId;
642
+ this.deviceCode = deviceCode || '';
643
+ this.streamType = streamType || '0';
644
+ this.enableAgent = enableAgent;
645
+ this.reload = reload;
646
+ this.onClose = onClose;
647
+ this.onRecordSearch = onRecordSearch;
648
+ this.deviceIp = deviceIp || '218.108.174.174';
649
+ this.devicePort = devicePort || '9001';
650
+ var credentials = resolveWeb34Credentials({
651
+ userName: userName,
652
+ password: password,
653
+ url: url,
654
+ originalUrl: originalUrl
655
+ });
656
+ this.userName = credentials.userName;
657
+ this.password = credentials.password;
658
+ this.credentialsSource = credentials.source;
659
+ this.startTime = startTime;
660
+ this.endTime = endTime;
661
+ this.recordSearchStartTime = hasMomentInputValue(recordSearchStartTime) ? recordSearchStartTime : startTime;
662
+ this.recordSearchEndTime = hasMomentInputValue(recordSearchEndTime) ? recordSearchEndTime : endTime;
663
+ this.containerId = ensureContainerId(container);
664
+ /** 为当前实例分配唯一窗口索引 */
665
+ if (typeof windowIndex === 'number') {
666
+ this.windowIndex = windowIndex;
667
+ this.autoWindowIndex = false;
668
+ } else {
669
+ this.windowIndex = allocateWindowIndex();
670
+ }
671
+ this.maxSplit = maxSplit || 25;
672
+ this.currentSplit = currentSplit || 1;
673
+ web34ActiveCount += 1;
674
+ logWeb34Login('credentials resolved', {
675
+ identify: this.getDeviceIdentify(),
676
+ source: this.credentialsSource,
677
+ userName: this.userName,
678
+ hasPassword: !!this.password,
679
+ urlHasAuth: !!_getWeb34UrlCredentials(url, 'url').source,
680
+ originalUrlHasAuth: !!_getWeb34UrlCredentials(originalUrl || '', 'originalUrl').source
681
+ });
682
+ this.readyPromise = this.init()["catch"](function (error) {
683
+ logWeb34SdkError('Player.init', {
684
+ error: error,
685
+ containerId: _this.containerId,
686
+ iWndIndex: _this.windowIndex
687
+ });
688
+ throw error;
689
+ });
690
+ }
691
+ return _createClass(Player, [{
692
+ key: "init",
693
+ value: function init() {
694
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee2() {
695
+ return _regenerator().w(function (_context2) {
696
+ while (1) switch (_context2.n) {
697
+ case 0:
698
+ _context2.n = 1;
699
+ return loadWeb34Sdk();
700
+ case 1:
701
+ if (!this.destroyed) {
702
+ _context2.n = 2;
703
+ break;
704
+ }
705
+ return _context2.a(2);
706
+ case 2:
707
+ _context2.n = 3;
708
+ return initWeb34Plugin(this.maxSplit, this.currentSplit);
709
+ case 3:
710
+ if (!this.destroyed) {
711
+ _context2.n = 4;
712
+ break;
713
+ }
714
+ return _context2.a(2);
715
+ case 4:
716
+ _context2.n = 5;
717
+ return this.createCustomPlayWindow();
718
+ case 5:
719
+ if (!this.destroyed) {
720
+ _context2.n = 6;
721
+ break;
722
+ }
723
+ return _context2.a(2);
724
+ case 6:
725
+ _context2.n = 7;
726
+ return this.login();
727
+ case 7:
728
+ return _context2.a(2);
729
+ }
730
+ }, _callee2, this);
731
+ }));
732
+ }
733
+ }, {
734
+ key: "createCustomPlayWindow",
735
+ value: function createCustomPlayWindow() {
736
+ var _this2 = this;
737
+ return new Promise(function (resolve, reject) {
738
+ var startTime = Date.now();
739
+ var timer;
740
+ var lastError = null;
741
+ var pending = false;
742
+ var clearTimer = function clearTimer() {
743
+ if (timer) {
744
+ window.clearTimeout(timer);
745
+ timer = undefined;
746
+ }
747
+ };
748
+ var rejectWindow = function rejectWindow() {
749
+ clearTimer();
750
+ reject(new Error(resolveNoPluginInitError({
751
+ sdk: window.WebVideoCtrl,
752
+ error: lastError,
753
+ fallback: 'web3.4 custom play window create failed'
754
+ })));
755
+ };
756
+ var retry = function retry() {
757
+ if (Date.now() - startTime >= CUSTOM_WINDOW_READY_TIMEOUT) {
758
+ if (isMissingCustomWindowMethodError(lastError)) {
759
+ web34CustomWindowUnavailable = true;
760
+ logWeb34SdkError('I_CreateCustomPlayWindows.unsupported', {
761
+ error: lastError,
762
+ iWndIndex: _this2.windowIndex,
763
+ containerId: _this2.containerId
764
+ });
765
+ resolveWindow();
766
+ return;
767
+ }
768
+ logWeb34SdkError('I_CreateCustomPlayWindows', {
769
+ error: lastError,
770
+ iWndIndex: _this2.windowIndex,
771
+ containerId: _this2.containerId
772
+ });
773
+ rejectWindow();
774
+ return;
775
+ }
776
+ timer = window.setTimeout(createWindow, 100);
777
+ };
778
+ var resolveWindow = function resolveWindow() {
779
+ var _a, _b;
780
+ clearTimer();
781
+ (_b = (_a = window.WebVideoCtrl) === null || _a === void 0 ? void 0 : _a.I_UpdateCustomContainer) === null || _b === void 0 ? void 0 : _b.call(_a);
782
+ resolve();
783
+ };
784
+ var handleResult = function handleResult(result) {
785
+ if (result === -1) {
786
+ lastError = {
787
+ result: result,
788
+ errorCode: getWeb34LastError()
789
+ };
790
+ retry();
791
+ return;
792
+ }
793
+ resolveWindow();
794
+ };
795
+ var createWindow = function createWindow() {
796
+ var _a;
797
+ if (_this2.destroyed) {
798
+ resolveWindow();
799
+ return;
800
+ }
801
+ if (web34CustomWindowUnavailable) {
802
+ resolveWindow();
803
+ return;
804
+ }
805
+ var container = document.getElementById(_this2.containerId);
806
+ if (!container) {
807
+ lastError = new Error("web3.4 container ".concat(_this2.containerId, " does not exist."));
808
+ retry();
809
+ return;
810
+ }
811
+ if (typeof ((_a = window.WebVideoCtrl) === null || _a === void 0 ? void 0 : _a.I_CreateCustomPlayWindows) !== 'function') {
812
+ lastError = new Error('web3.4 custom container API is not available.');
813
+ retry();
814
+ return;
815
+ }
816
+ if (pending) return;
817
+ try {
818
+ var result = window.WebVideoCtrl.I_CreateCustomPlayWindows(_this2.windowIndex, _this2.containerId);
819
+ if (result === null || result === void 0 ? void 0 : result.then) {
820
+ pending = true;
821
+ result.then(function (res) {
822
+ pending = false;
823
+ handleResult(res);
824
+ }, function (error) {
825
+ pending = false;
826
+ lastError = error;
827
+ retry();
828
+ });
829
+ return;
830
+ }
831
+ handleResult(result);
832
+ } catch (error) {
833
+ if (isMissingCustomWindowMethodError(error)) {
834
+ lastError = error;
835
+ retry();
836
+ return;
837
+ }
838
+ lastError = error;
839
+ retry();
840
+ }
841
+ };
842
+ createWindow();
843
+ });
844
+ }
845
+ }, {
846
+ key: "restoreCustomPlayWindow",
847
+ value: function restoreCustomPlayWindow() {
848
+ var _a, _b;
849
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee3() {
850
+ var updateResult, _t;
851
+ return _regenerator().w(function (_context3) {
852
+ while (1) switch (_context3.p = _context3.n) {
853
+ case 0:
854
+ if (!this.destroyed) {
855
+ _context3.n = 1;
856
+ break;
857
+ }
858
+ return _context3.a(2);
859
+ case 1:
860
+ _context3.n = 2;
861
+ return sleep(WEB34_PLAYBACK_SWITCH_DELAY);
862
+ case 2:
863
+ updateResult = (_b = (_a = window.WebVideoCtrl) === null || _a === void 0 ? void 0 : _a.I_UpdateCustomContainer) === null || _b === void 0 ? void 0 : _b.call(_a);
864
+ if (updateResult === -1) {
865
+ logWeb34SdkError('I_UpdateCustomContainer.restore', {
866
+ result: updateResult,
867
+ iWndIndex: this.windowIndex,
868
+ containerId: this.containerId
869
+ });
870
+ }
871
+ if (!web34CustomWindowUnavailable) {
872
+ _context3.n = 3;
873
+ break;
874
+ }
875
+ return _context3.a(2);
876
+ case 3:
877
+ _context3.p = 3;
878
+ _context3.n = 4;
879
+ return this.createCustomPlayWindow();
880
+ case 4:
881
+ _context3.n = 6;
882
+ break;
883
+ case 5:
884
+ _context3.p = 5;
885
+ _t = _context3.v;
886
+ logWeb34SdkError('I_CreateCustomPlayWindows.restore', {
887
+ error: _t,
888
+ iWndIndex: this.windowIndex,
889
+ containerId: this.containerId
890
+ });
891
+ case 6:
892
+ return _context3.a(2);
893
+ }
894
+ }, _callee3, this, [[3, 5]]);
895
+ }));
896
+ }
897
+ }, {
898
+ key: "getDeviceIdentify",
899
+ value: function getDeviceIdentify() {
900
+ return "".concat(this.deviceIp, "_").concat(this.devicePort);
901
+ }
902
+ }, {
903
+ key: "getProtocol",
904
+ value: function getProtocol() {
905
+ return location.protocol === 'https:' ? 2 : 1;
906
+ }
907
+ }, {
908
+ key: "getStreamType",
909
+ value: function getStreamType() {
910
+ return this.streamType === '1' ? 2 : 1;
911
+ }
912
+ }, {
913
+ key: "getChannelId",
914
+ value: function getChannelId() {
915
+ var channelId = parseInt(this.channelNum, 10);
916
+ return Number.isNaN(channelId) ? 1 : channelId;
917
+ }
918
+ }, {
919
+ key: "getWsPort",
920
+ value: function getWsPort() {
921
+ return Number(_getWeb34UrlAddress(this.url, this.originalUrl).port);
922
+ }
923
+ // private getWsPort() {
924
+ // const portInfo = window.WebVideoCtrl.I_GetDevicePort?.(this.getDeviceIdentify());
925
+ // if (!portInfo) {
926
+ // logWeb34SdkError('I_GetDevicePort.ws', {
927
+ // deviceIdentify: this.getDeviceIdentify(),
928
+ // });
929
+ // }
930
+ // const sdkWsPort =
931
+ // location.protocol === 'https:' ? portInfo?.iWebSocketsPort : portInfo?.iWebSocketPort;
932
+ // return sdkWsPort || Number(getWeb34UrlAddress(this.url, this.originalUrl).port);
933
+ // }
934
+ }, {
935
+ key: "getLoginKey",
936
+ value: function getLoginKey() {
937
+ return "".concat(this.getDeviceIdentify(), "_").concat(this.getProtocol(), "_").concat(getWeb34AuthCacheKey(this.userName, this.password));
938
+ }
939
+ }, {
940
+ key: "isDeviceLoggedIn",
941
+ value: function isDeviceLoggedIn() {
942
+ var _a, _b;
943
+ var identify = this.getDeviceIdentify();
944
+ return (_b = (_a = window.WebVideoCtrl.w_deviceSet) === null || _a === void 0 ? void 0 : _a.some) === null || _b === void 0 ? void 0 : _b.call(_a, function (item) {
945
+ return item.szDeviceIdentify === identify;
946
+ });
947
+ }
948
+ }, {
949
+ key: "logoutDevice",
950
+ value: function logoutDevice(identify, reason) {
951
+ var ignoreNotFound = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
952
+ var _a, _b;
953
+ var logoutResult = (_b = (_a = window.WebVideoCtrl) === null || _a === void 0 ? void 0 : _a.I_Logout) === null || _b === void 0 ? void 0 : _b.call(_a, identify);
954
+ if (logoutResult === -1) {
955
+ if (ignoreNotFound) {
956
+ logWeb34Login('I_Logout skipped', {
957
+ identify: identify,
958
+ reason: reason,
959
+ result: logoutResult
960
+ });
961
+ return logoutResult;
962
+ }
963
+ logWeb34SdkError('I_Logout', {
964
+ result: logoutResult,
965
+ deviceIdentify: identify,
966
+ reason: reason
967
+ });
968
+ } else {
969
+ logWeb34Login('I_Logout result', {
970
+ identify: identify,
971
+ reason: reason,
972
+ result: logoutResult
973
+ });
974
+ }
975
+ return logoutResult;
976
+ }
977
+ }, {
978
+ key: "login",
979
+ value: function login() {
980
+ var _a;
981
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee4() {
982
+ var _this3 = this;
983
+ var identify, loginKey, lastLogin, activeLoginKey, deviceLoggedIn, shouldClearProxyCookies, shouldLogoutBeforeLogin, needLogin, loginPromise;
984
+ return _regenerator().w(function (_context4) {
985
+ while (1) switch (_context4.n) {
986
+ case 0:
987
+ identify = this.getDeviceIdentify();
988
+ loginKey = this.getLoginKey();
989
+ lastLogin = web34LoginPromises.get(identify);
990
+ activeLoginKey = web34ActiveLoginKeys.get(identify);
991
+ deviceLoggedIn = this.isDeviceLoggedIn();
992
+ shouldClearProxyCookies = !!lastLogin && lastLogin.loginKey !== loginKey || !!activeLoginKey && activeLoginKey !== loginKey;
993
+ shouldLogoutBeforeLogin = deviceLoggedIn || !!activeLoginKey || !!lastLogin;
994
+ needLogin = !lastLogin || lastLogin.loginKey !== loginKey || activeLoginKey !== loginKey || !deviceLoggedIn;
995
+ logWeb34Login('check', {
996
+ identify: identify,
997
+ loginKey: loginKey,
998
+ lastLoginKey: lastLogin === null || lastLogin === void 0 ? void 0 : lastLogin.loginKey,
999
+ activeLoginKey: activeLoginKey,
1000
+ wsPort: this.getWsPort(),
1001
+ deviceLoggedIn: deviceLoggedIn,
1002
+ needLogin: needLogin,
1003
+ shouldClearProxyCookies: shouldClearProxyCookies,
1004
+ shouldLogoutBeforeLogin: shouldLogoutBeforeLogin
1005
+ });
1006
+ if (needLogin) {
1007
+ logWeb34Login('schedule login', {
1008
+ identify: identify,
1009
+ loginKey: loginKey,
1010
+ lastLoginKey: lastLogin === null || lastLogin === void 0 ? void 0 : lastLogin.loginKey,
1011
+ activeLoginKey: activeLoginKey,
1012
+ wsPort: this.getWsPort(),
1013
+ shouldClearProxyCookies: shouldClearProxyCookies,
1014
+ shouldLogoutBeforeLogin: shouldLogoutBeforeLogin
1015
+ });
1016
+ loginPromise = runWeb34LoginTask(function () {
1017
+ return _this3.doLogin(loginKey, shouldClearProxyCookies, shouldLogoutBeforeLogin);
1018
+ })["catch"](function (error) {
1019
+ var _a;
1020
+ logWeb34Login('login promise rejected', {
1021
+ identify: identify,
1022
+ loginKey: loginKey,
1023
+ error: error
1024
+ });
1025
+ if (((_a = web34LoginPromises.get(identify)) === null || _a === void 0 ? void 0 : _a.loginKey) === loginKey) {
1026
+ web34LoginPromises["delete"](identify);
1027
+ }
1028
+ throw error;
1029
+ });
1030
+ web34LoginPromises.set(identify, {
1031
+ loginKey: loginKey,
1032
+ promise: loginPromise
1033
+ });
1034
+ } else {
1035
+ logWeb34Login('reuse login promise', {
1036
+ identify: identify,
1037
+ loginKey: loginKey
1038
+ });
1039
+ }
1040
+ _context4.n = 1;
1041
+ return (_a = web34LoginPromises.get(identify)) === null || _a === void 0 ? void 0 : _a.promise;
1042
+ case 1:
1043
+ logWeb34Login('login promise resolved', {
1044
+ identify: identify,
1045
+ loginKey: loginKey,
1046
+ acquiredLoginKey: this.acquiredLoginKey,
1047
+ activeLoginKey: web34ActiveLoginKeys.get(identify),
1048
+ wsPort: this.getWsPort()
1049
+ });
1050
+ if (!(this.acquiredLoginKey === loginKey)) {
1051
+ _context4.n = 2;
1052
+ break;
1053
+ }
1054
+ logWeb34Login('login ref already acquired', {
1055
+ identify: identify,
1056
+ loginKey: loginKey
1057
+ });
1058
+ return _context4.a(2);
1059
+ case 2:
1060
+ this.releaseLoginRef();
1061
+ web34DeviceRefs.set(loginKey, (web34DeviceRefs.get(loginKey) || 0) + 1);
1062
+ this.acquiredLoginKey = loginKey;
1063
+ logWeb34Login('login ready', {
1064
+ identify: identify,
1065
+ loginKey: loginKey,
1066
+ refCount: web34DeviceRefs.get(loginKey)
1067
+ });
1068
+ case 3:
1069
+ return _context4.a(2);
1070
+ }
1071
+ }, _callee4, this);
1072
+ }));
1073
+ }
1074
+ }, {
1075
+ key: "doLogin",
1076
+ value: function doLogin(loginKey) {
1077
+ var _this4 = this;
1078
+ var clearProxyCookies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1079
+ var logoutBeforeLogin = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1080
+ var identify = this.getDeviceIdentify();
1081
+ var activeLoginKey = web34ActiveLoginKeys.get(identify);
1082
+ var exists = this.isDeviceLoggedIn();
1083
+ if (exists && activeLoginKey === loginKey && !logoutBeforeLogin) {
1084
+ logWeb34Login('sdk already logged in', {
1085
+ identify: identify,
1086
+ loginKey: loginKey
1087
+ });
1088
+ return Promise.resolve();
1089
+ }
1090
+ if (clearProxyCookies) {
1091
+ logWeb34Login('clear proxy cookies before relogin', {
1092
+ identify: identify,
1093
+ loginKey: loginKey,
1094
+ activeLoginKey: activeLoginKey
1095
+ });
1096
+ clearWeb34ProxyCookies();
1097
+ }
1098
+ if (logoutBeforeLogin) {
1099
+ logWeb34Login('logout before login', {
1100
+ identify: identify,
1101
+ loginKey: loginKey,
1102
+ activeLoginKey: activeLoginKey,
1103
+ deviceLoggedIn: exists
1104
+ });
1105
+ this.logoutDevice(identify, activeLoginKey ? 'relogin' : 'stale login cache', !exists);
1106
+ web34ActiveLoginKeys["delete"](identify);
1107
+ }
1108
+ logWeb34Login('call I_Login', {
1109
+ identify: identify,
1110
+ loginKey: loginKey,
1111
+ deviceIp: this.deviceIp,
1112
+ devicePort: this.devicePort,
1113
+ wsPort: this.getWsPort(),
1114
+ protocol: this.getProtocol(),
1115
+ userName: this.userName,
1116
+ hasPassword: !!this.password,
1117
+ credentialsSource: this.credentialsSource
1118
+ });
1119
+ return new Promise(function (resolve, reject) {
1120
+ var result = window.WebVideoCtrl.I_Login(_this4.deviceIp, _this4.getProtocol(), _this4.devicePort, _this4.userName, _this4.password, {
1121
+ success: function success() {
1122
+ web34ActiveLoginKeys.set(identify, loginKey);
1123
+ logWeb34Login('I_Login success', {
1124
+ identify: identify,
1125
+ loginKey: loginKey,
1126
+ activeLoginKey: web34ActiveLoginKeys.get(identify),
1127
+ userName: _this4.userName,
1128
+ hasPassword: !!_this4.password,
1129
+ credentialsSource: _this4.credentialsSource
1130
+ });
1131
+ resolve();
1132
+ },
1133
+ error: function error(status, xmlDoc) {
1134
+ logWeb34Login('I_Login error callback', {
1135
+ identify: identify,
1136
+ loginKey: loginKey,
1137
+ status: status,
1138
+ xmlDoc: xmlDoc
1139
+ });
1140
+ logWeb34SdkError('I_Login', {
1141
+ status: status,
1142
+ xmlDoc: xmlDoc,
1143
+ deviceIp: _this4.deviceIp,
1144
+ devicePort: _this4.devicePort,
1145
+ wsPort: _this4.getWsPort(),
1146
+ protocol: _this4.getProtocol(),
1147
+ userName: _this4.userName,
1148
+ hasPassword: !!_this4.password,
1149
+ credentialsSource: _this4.credentialsSource
1150
+ });
1151
+ reject({
1152
+ status: status,
1153
+ xmlDoc: xmlDoc
1154
+ });
1155
+ }
1156
+ });
1157
+ if (result === -1) {
1158
+ logWeb34Login('I_Login returned -1', {
1159
+ identify: identify,
1160
+ loginKey: loginKey,
1161
+ errorCode: getWeb34LastError()
1162
+ });
1163
+ logWeb34SdkError('I_Login', {
1164
+ result: result,
1165
+ deviceIp: _this4.deviceIp,
1166
+ devicePort: _this4.devicePort,
1167
+ wsPort: _this4.getWsPort(),
1168
+ protocol: _this4.getProtocol()
1169
+ });
1170
+ reject(new Error('web3.4 login failed.'));
1171
+ }
1172
+ });
1173
+ }
1174
+ }, {
1175
+ key: "releaseLoginRef",
1176
+ value: function releaseLoginRef() {
1177
+ var _a;
1178
+ var loginKey = this.acquiredLoginKey;
1179
+ if (!loginKey || !web34DeviceRefs.has(loginKey)) {
1180
+ this.acquiredLoginKey = '';
1181
+ return;
1182
+ }
1183
+ var identify = this.getDeviceIdentify();
1184
+ var deviceRefCount = Math.max((web34DeviceRefs.get(loginKey) || 0) - 1, 0);
1185
+ if (deviceRefCount > 0) {
1186
+ web34DeviceRefs.set(loginKey, deviceRefCount);
1187
+ } else {
1188
+ web34DeviceRefs["delete"](loginKey);
1189
+ if (((_a = web34LoginPromises.get(identify)) === null || _a === void 0 ? void 0 : _a.loginKey) === loginKey) {
1190
+ web34LoginPromises["delete"](identify);
1191
+ }
1192
+ if (web34ActiveLoginKeys.get(identify) === loginKey) {
1193
+ this.logoutDevice(identify, 'last reference released');
1194
+ web34ActiveLoginKeys["delete"](identify);
1195
+ }
1196
+ }
1197
+ this.acquiredLoginKey = '';
1198
+ }
1199
+ }, {
1200
+ key: "getRtspPort",
1201
+ value: function getRtspPort() {
1202
+ var _a, _b;
1203
+ var portInfo = (_b = (_a = window.WebVideoCtrl).I_GetDevicePort) === null || _b === void 0 ? void 0 : _b.call(_a, this.getDeviceIdentify());
1204
+ if (!portInfo) {
1205
+ logWeb34SdkError('I_GetDevicePort', {
1206
+ deviceIdentify: this.getDeviceIdentify()
1207
+ });
1208
+ }
1209
+ return (portInfo === null || portInfo === void 0 ? void 0 : portInfo.iRtspPort) || Number(this.devicePort);
1210
+ }
1211
+ /** 播放 */
1212
+ }, {
1213
+ key: "play",
1214
+ value: function play() {
1215
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee6() {
1216
+ var _this5 = this;
1217
+ return _regenerator().w(function (_context6) {
1218
+ while (1) switch (_context6.n) {
1219
+ case 0:
1220
+ _context6.n = 1;
1221
+ return this.readyPromise;
1222
+ case 1:
1223
+ if (!this.destroyed) {
1224
+ _context6.n = 2;
1225
+ break;
1226
+ }
1227
+ return _context6.a(2, Promise.reject());
1228
+ case 2:
1229
+ _context6.n = 3;
1230
+ return this.stopCurrent();
1231
+ case 3:
1232
+ return _context6.a(2, runWeb34StartTask(function () {
1233
+ return __awaiter(_this5, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee5() {
1234
+ var _this6 = this;
1235
+ return _regenerator().w(function (_context5) {
1236
+ while (1) switch (_context5.n) {
1237
+ case 0:
1238
+ _context5.n = 1;
1239
+ return this.login();
1240
+ case 1:
1241
+ if (!this.destroyed) {
1242
+ _context5.n = 2;
1243
+ break;
1244
+ }
1245
+ return _context5.a(2, Promise.reject());
1246
+ case 2:
1247
+ return _context5.a(2, new Promise(function (resolve, reject) {
1248
+ var result = window.WebVideoCtrl.I_StartRealPlay(_this6.getDeviceIdentify(), {
1249
+ iWndIndex: _this6.windowIndex,
1250
+ iRtspPort: _this6.getRtspPort(),
1251
+ iStreamType: _this6.getStreamType(),
1252
+ iChannelID: _this6.getChannelId(),
1253
+ iWSPort: _this6.getWsPort(),
1254
+ bProxy: _this6.enableAgent,
1255
+ success: function success() {
1256
+ _this6.playing = true;
1257
+ resolve();
1258
+ },
1259
+ error: function error(status, xmlDoc) {
1260
+ // this.reload && this.reload();
1261
+ logWeb34SdkError('I_StartRealPlay', {
1262
+ status: status,
1263
+ xmlDoc: xmlDoc,
1264
+ deviceIdentify: _this6.getDeviceIdentify(),
1265
+ channelNum: _this6.getChannelId()
1266
+ });
1267
+ reject({
1268
+ status: status,
1269
+ xmlDoc: xmlDoc
1270
+ });
1271
+ }
1272
+ });
1273
+ if (result === -1) {
1274
+ logWeb34SdkError('I_StartRealPlay', {
1275
+ result: result,
1276
+ deviceIdentify: _this6.getDeviceIdentify(),
1277
+ channelNum: _this6.getChannelId()
1278
+ });
1279
+ reject(new Error('web3.4 real play start failed.'));
1280
+ }
1281
+ }));
1282
+ }
1283
+ }, _callee5, this);
1284
+ }));
1285
+ }));
1286
+ }
1287
+ }, _callee6, this);
1288
+ }));
1289
+ }
1290
+ /** 回放 */
1291
+ }, {
1292
+ key: "playBack",
1293
+ value: function playBack() {
1294
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee7() {
1295
+ return _regenerator().w(function (_context7) {
1296
+ while (1) switch (_context7.n) {
1297
+ case 0:
1298
+ return _context7.a(2, this.startPlayback());
1299
+ }
1300
+ }, _callee7, this);
1301
+ }));
1302
+ }
1303
+ }, {
1304
+ key: "searchRecords",
1305
+ value: function searchRecords() {
1306
+ var _this7 = this;
1307
+ var _a, _b;
1308
+ if (!hasMomentInputValue(this.recordSearchStartTime) || !hasMomentInputValue(this.recordSearchEndTime)) {
1309
+ logWeb34SdkError('I_RecordSearch.time', {
1310
+ startTime: this.recordSearchStartTime,
1311
+ endTime: this.recordSearchEndTime
1312
+ });
1313
+ (_a = this.onRecordSearch) === null || _a === void 0 ? void 0 : _a.call(this, []);
1314
+ return Promise.resolve();
1315
+ }
1316
+ var startTime = (0, _moment["default"])(this.recordSearchStartTime);
1317
+ var endTime = (0, _moment["default"])(this.recordSearchEndTime);
1318
+ if (!startTime.isValid() || !endTime.isValid()) {
1319
+ logWeb34SdkError('I_RecordSearch.time', {
1320
+ startTime: this.recordSearchStartTime,
1321
+ endTime: this.recordSearchEndTime
1322
+ });
1323
+ (_b = this.onRecordSearch) === null || _b === void 0 ? void 0 : _b.call(this, []);
1324
+ return Promise.resolve();
1325
+ }
1326
+ var szStartTime = startTime.format('YYYY-MM-DD HH:mm:ss');
1327
+ var szEndTime = endTime.format('YYYY-MM-DD HH:mm:ss');
1328
+ var searchKey = "".concat(this.getDeviceIdentify(), "_").concat(this.getChannelId(), "_").concat(szStartTime, "_").concat(szEndTime);
1329
+ if (!this.onRecordSearch || this.recordSearchKey === searchKey) {
1330
+ return Promise.resolve();
1331
+ }
1332
+ this.recordSearchKey = searchKey;
1333
+ var list = [];
1334
+ var _doSearch = function doSearch() {
1335
+ var searchTimes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
1336
+ var _a;
1337
+ if (searchTimes >= WEB34_RECORD_SEARCH_MAX_TIMES) {
1338
+ (_a = _this7.onRecordSearch) === null || _a === void 0 ? void 0 : _a.call(_this7, list);
1339
+ return Promise.resolve();
1340
+ }
1341
+ return new Promise(function (resolve) {
1342
+ var _a;
1343
+ var result = window.WebVideoCtrl.I_RecordSearch(_this7.getDeviceIdentify(), _this7.getChannelId(), szStartTime, szEndTime, {
1344
+ iStreamType: _this7.getStreamType(),
1345
+ iSearchPos: searchTimes * WEB34_RECORD_SEARCH_PAGE_SIZE,
1346
+ success: function success(xmlDoc) {
1347
+ var _a;
1348
+ var responseStatus = getXmlText(xmlDoc, 'responseStatusStrg');
1349
+ list.push.apply(list, _toConsumableArray(parseWeb34RecordItems(xmlDoc)));
1350
+ if (responseStatus === 'MORE') {
1351
+ _doSearch(searchTimes + 1).then(resolve);
1352
+ return;
1353
+ }
1354
+ (_a = _this7.onRecordSearch) === null || _a === void 0 ? void 0 : _a.call(_this7, list);
1355
+ resolve();
1356
+ },
1357
+ error: function error(status, xmlDoc) {
1358
+ var _a;
1359
+ logWeb34SdkError('I_RecordSearch', {
1360
+ status: status,
1361
+ xmlDoc: xmlDoc,
1362
+ deviceIdentify: _this7.getDeviceIdentify(),
1363
+ channelNum: _this7.getChannelId(),
1364
+ startTime: szStartTime,
1365
+ endTime: szEndTime
1366
+ });
1367
+ (_a = _this7.onRecordSearch) === null || _a === void 0 ? void 0 : _a.call(_this7, list);
1368
+ resolve();
1369
+ }
1370
+ });
1371
+ if (result === -1) {
1372
+ logWeb34SdkError('I_RecordSearch', {
1373
+ result: result,
1374
+ deviceIdentify: _this7.getDeviceIdentify(),
1375
+ channelNum: _this7.getChannelId(),
1376
+ startTime: szStartTime,
1377
+ endTime: szEndTime
1378
+ });
1379
+ (_a = _this7.onRecordSearch) === null || _a === void 0 ? void 0 : _a.call(_this7, list);
1380
+ resolve();
1381
+ }
1382
+ });
1383
+ };
1384
+ return _doSearch();
1385
+ }
1386
+ }, {
1387
+ key: "startPlayback",
1388
+ value: function startPlayback() {
1389
+ var startTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.startTime;
1390
+ var endTime = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.endTime;
1391
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee9() {
1392
+ var _this8 = this;
1393
+ var switchingPlayback;
1394
+ return _regenerator().w(function (_context9) {
1395
+ while (1) switch (_context9.n) {
1396
+ case 0:
1397
+ _context9.n = 1;
1398
+ return this.readyPromise;
1399
+ case 1:
1400
+ if (!this.destroyed) {
1401
+ _context9.n = 2;
1402
+ break;
1403
+ }
1404
+ return _context9.a(2, Promise.reject());
1405
+ case 2:
1406
+ switchingPlayback = this.playing;
1407
+ _context9.n = 3;
1408
+ return this.stopCurrent();
1409
+ case 3:
1410
+ if (!switchingPlayback) {
1411
+ _context9.n = 4;
1412
+ break;
1413
+ }
1414
+ _context9.n = 4;
1415
+ return this.restoreCustomPlayWindow();
1416
+ case 4:
1417
+ return _context9.a(2, runWeb34StartTask(function () {
1418
+ return __awaiter(_this8, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee8() {
1419
+ var _this9 = this;
1420
+ var playbackStartTime, playbackEndTime;
1421
+ return _regenerator().w(function (_context8) {
1422
+ while (1) switch (_context8.n) {
1423
+ case 0:
1424
+ _context8.n = 1;
1425
+ return this.login();
1426
+ case 1:
1427
+ if (!this.destroyed) {
1428
+ _context8.n = 2;
1429
+ break;
1430
+ }
1431
+ return _context8.a(2, Promise.reject());
1432
+ case 2:
1433
+ _context8.n = 3;
1434
+ return this.searchRecords();
1435
+ case 3:
1436
+ if (!(!hasMomentInputValue(startTime) || !hasMomentInputValue(endTime))) {
1437
+ _context8.n = 4;
1438
+ break;
1439
+ }
1440
+ logWeb34SdkError('I_StartPlayback.time', {
1441
+ startTime: startTime,
1442
+ endTime: endTime
1443
+ });
1444
+ return _context8.a(2, Promise.reject(new Error('web3.4 playback time is invalid.')));
1445
+ case 4:
1446
+ playbackStartTime = (0, _moment["default"])(startTime);
1447
+ playbackEndTime = (0, _moment["default"])(endTime);
1448
+ if (!(!playbackStartTime.isValid() || !playbackEndTime.isValid())) {
1449
+ _context8.n = 5;
1450
+ break;
1451
+ }
1452
+ logWeb34SdkError('I_StartPlayback.time', {
1453
+ startTime: startTime,
1454
+ endTime: endTime
1455
+ });
1456
+ return _context8.a(2, Promise.reject(new Error('web3.4 playback time is invalid.')));
1457
+ case 5:
1458
+ this.startTime = startTime;
1459
+ this.endTime = endTime;
1460
+ return _context8.a(2, new Promise(function (resolve, reject) {
1461
+ var result = window.WebVideoCtrl.I_StartPlayback(_this9.getDeviceIdentify(), {
1462
+ iWndIndex: _this9.windowIndex,
1463
+ iRtspPort: _this9.getRtspPort(),
1464
+ iStreamType: _this9.getStreamType(),
1465
+ iChannelID: _this9.getChannelId(),
1466
+ szStartTime: playbackStartTime.format('YYYY-MM-DD HH:mm:ss'),
1467
+ szEndTime: playbackEndTime.format('YYYY-MM-DD HH:mm:ss'),
1468
+ bProxy: _this9.enableAgent,
1469
+ iWSPort: _this9.getWsPort(),
1470
+ success: function success() {
1471
+ _this9.playing = true;
1472
+ resolve();
1473
+ },
1474
+ error: function error(status, xmlDoc) {
1475
+ logWeb34SdkError('I_StartPlayback', {
1476
+ status: status,
1477
+ xmlDoc: xmlDoc,
1478
+ deviceIdentify: _this9.getDeviceIdentify(),
1479
+ channelNum: _this9.getChannelId(),
1480
+ startTime: startTime,
1481
+ endTime: endTime
1482
+ });
1483
+ reject({
1484
+ status: status,
1485
+ xmlDoc: xmlDoc
1486
+ });
1487
+ }
1488
+ });
1489
+ if (result === -1) {
1490
+ logWeb34SdkError('I_StartPlayback', {
1491
+ result: result,
1492
+ deviceIdentify: _this9.getDeviceIdentify(),
1493
+ channelNum: _this9.getChannelId(),
1494
+ startTime: startTime,
1495
+ endTime: endTime
1496
+ });
1497
+ reject(new Error('web3.4 playback start failed.'));
1498
+ }
1499
+ }));
1500
+ }
1501
+ }, _callee8, this);
1502
+ }));
1503
+ }));
1504
+ }
1505
+ }, _callee9, this);
1506
+ }));
1507
+ }
1508
+ }, {
1509
+ key: "stopCurrent",
1510
+ value: function stopCurrent() {
1511
+ var _this0 = this;
1512
+ var _a, _b, _c;
1513
+ if (!((_a = window.WebVideoCtrl) === null || _a === void 0 ? void 0 : _a.I_Stop)) return Promise.resolve();
1514
+ var wndInfo = (_c = (_b = window.WebVideoCtrl).I_GetWindowStatus) === null || _c === void 0 ? void 0 : _c.call(_b, this.windowIndex);
1515
+ if (!wndInfo) return Promise.resolve();
1516
+ return new Promise(function (resolve) {
1517
+ var result = window.WebVideoCtrl.I_Stop({
1518
+ iIndex: _this0.windowIndex,
1519
+ success: function success() {
1520
+ _this0.playing = false;
1521
+ resolve();
1522
+ },
1523
+ error: function error() {
1524
+ logWeb34SdkError('I_Stop', {
1525
+ iWndIndex: _this0.windowIndex
1526
+ });
1527
+ _this0.playing = false;
1528
+ resolve();
1529
+ }
1530
+ });
1531
+ if (result === -1) {
1532
+ logWeb34SdkError('I_Stop', {
1533
+ result: result,
1534
+ iWndIndex: _this0.windowIndex
1535
+ });
1536
+ }
1537
+ });
1538
+ }
1539
+ }, {
1540
+ key: "download",
1541
+ value: function download(options) {
1542
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee0() {
1543
+ var _this1 = this;
1544
+ var _ref4, _ref4$playbackURI, playbackURI, _ref4$fileName, fileName;
1545
+ return _regenerator().w(function (_context0) {
1546
+ while (1) switch (_context0.n) {
1547
+ case 0:
1548
+ _context0.n = 1;
1549
+ return this.readyPromise;
1550
+ case 1:
1551
+ // await this.login();
1552
+ _ref4 = options || {}, _ref4$playbackURI = _ref4.playbackURI, playbackURI = _ref4$playbackURI === void 0 ? '' : _ref4$playbackURI, _ref4$fileName = _ref4.fileName, fileName = _ref4$fileName === void 0 ? '' : _ref4$fileName;
1553
+ if (playbackURI) {
1554
+ _context0.n = 2;
1555
+ break;
1556
+ }
1557
+ return _context0.a(2, Promise.reject(new Error('web3.4 download playbackURI is empty.')));
1558
+ case 2:
1559
+ return _context0.a(2, new Promise(function (resolve, reject) {
1560
+ var result = window.WebVideoCtrl.I_StartDownloadRecord(_this1.getDeviceIdentify(), playbackURI, fileName || getWeb34PlaybackParam(playbackURI, 'name') || "".concat(Date.now()), {
1561
+ success: function success() {
1562
+ resolve();
1563
+ },
1564
+ error: function error(status, xmlDoc) {
1565
+ logWeb34SdkError('I_StartDownloadRecord', {
1566
+ status: status,
1567
+ xmlDoc: xmlDoc,
1568
+ deviceIdentify: _this1.getDeviceIdentify(),
1569
+ playbackURI: playbackURI,
1570
+ fileName: fileName
1571
+ });
1572
+ reject({
1573
+ status: status,
1574
+ xmlDoc: xmlDoc
1575
+ });
1576
+ }
1577
+ });
1578
+ if (result === -1) {
1579
+ logWeb34SdkError('I_StartDownloadRecord', {
1580
+ result: result,
1581
+ deviceIdentify: _this1.getDeviceIdentify(),
1582
+ playbackURI: playbackURI,
1583
+ fileName: fileName
1584
+ });
1585
+ reject(new Error('web3.4 download start failed.'));
1586
+ }
1587
+ }));
1588
+ }
1589
+ }, _callee0, this);
1590
+ }));
1591
+ }
1592
+ }, {
1593
+ key: "destroy",
1594
+ value: function destroy() {
1595
+ var _this10 = this;
1596
+ if (this.destroyed) return;
1597
+ this.destroyed = true;
1598
+ if (this.timeUpdateTimer) {
1599
+ clearInterval(this.timeUpdateTimer);
1600
+ this.timeUpdateTimer = undefined;
1601
+ }
1602
+ this.stopCurrent()["finally"](function () {
1603
+ var _a, _b;
1604
+ _this10.playing = false;
1605
+ if (_this10.autoWindowIndex) {
1606
+ releaseWindowIndex(_this10.windowIndex);
1607
+ }
1608
+ web34ActiveCount = Math.max(web34ActiveCount - 1, 0);
1609
+ _this10.releaseLoginRef();
1610
+ if (web34ActiveCount === 0) {
1611
+ var destroyResult = (_b = (_a = window.WebVideoCtrl) === null || _a === void 0 ? void 0 : _a.I_DestroyWorker) === null || _b === void 0 ? void 0 : _b.call(_a);
1612
+ if (destroyResult === -1) {
1613
+ logWeb34SdkError('I_DestroyWorker', {
1614
+ result: destroyResult
1615
+ });
1616
+ }
1617
+ web34InitPromise = null;
1618
+ windowIndexCounter = 0;
1619
+ releasedWindowIndexes.length = 0;
1620
+ web34ActiveLoginKeys.clear();
1621
+ web34LoginPromises.clear();
1622
+ web34DeviceRefs.clear();
1623
+ web34CustomWindowUnavailable = false;
1624
+ }
1625
+ });
1626
+ }
1627
+ /** 截图 */
1628
+ }, {
1629
+ key: "capture",
1630
+ value: function capture() {
1631
+ var captureName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '视频截图';
1632
+ var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1633
+ var time = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
1634
+ var _a, _b;
1635
+ var name = captureName;
1636
+ if (time) name += "-".concat((0, _moment["default"])().format('YYYYMMDDHHmmss'));
1637
+ var result = (_b = (_a = window.WebVideoCtrl) === null || _a === void 0 ? void 0 : _a.I2_CapturePic) === null || _b === void 0 ? void 0 : _b.call(_a, "".concat(name, ".jpg"), {
1638
+ iWndIndex: this.windowIndex,
1639
+ cbCallback: function cbCallback(res) {
1640
+ callback && callback(res);
1641
+ }
1642
+ });
1643
+ if (result === -1) {
1644
+ logWeb34SdkError('I2_CapturePic', {
1645
+ result: result,
1646
+ iWndIndex: this.windowIndex,
1647
+ name: name
1648
+ });
1649
+ }
1650
+ }
1651
+ /** 尺寸重置 */
1652
+ }, {
1653
+ key: "resize",
1654
+ value: function resize() {
1655
+ var _a, _b;
1656
+ var container = document.getElementById(this.containerId);
1657
+ if (!container) return;
1658
+ var result = (_b = (_a = window.WebVideoCtrl) === null || _a === void 0 ? void 0 : _a.I_UpdateCustomContainer) === null || _b === void 0 ? void 0 : _b.call(_a);
1659
+ if (result === -1) {
1660
+ logWeb34SdkError('I_UpdateCustomContainer', {
1661
+ result: result,
1662
+ width: container.clientWidth,
1663
+ height: container.clientHeight
1664
+ });
1665
+ }
1666
+ }
1667
+ /**
1668
+ * 设置音量
1669
+ * @param value
1670
+ */
1671
+ }, {
1672
+ key: "setVolume",
1673
+ value: function setVolume(value) {
1674
+ var _this11 = this;
1675
+ var _a, _b, _c, _d;
1676
+ if (!this.playing) return;
1677
+ if (value < 1) {
1678
+ var result = (_b = (_a = window.WebVideoCtrl) === null || _a === void 0 ? void 0 : _a.I_CloseSound) === null || _b === void 0 ? void 0 : _b.call(_a, this.windowIndex);
1679
+ if (result === -1) {
1680
+ logWeb34SdkError('I_CloseSound', {
1681
+ result: result,
1682
+ iWndIndex: this.windowIndex
1683
+ });
1684
+ }
1685
+ return;
1686
+ }
1687
+ (_d = (_c = window.WebVideoCtrl) === null || _c === void 0 ? void 0 : _c.I_OpenSound) === null || _d === void 0 ? void 0 : _d.call(_c, this.windowIndex).then(function () {
1688
+ var _a, _b;
1689
+ var result = (_b = (_a = window.WebVideoCtrl) === null || _a === void 0 ? void 0 : _a.I_SetVolume) === null || _b === void 0 ? void 0 : _b.call(_a, value, _this11.windowIndex);
1690
+ if (result === -1) {
1691
+ logWeb34SdkError('I_SetVolume', {
1692
+ result: result,
1693
+ value: value,
1694
+ iWndIndex: _this11.windowIndex
1695
+ });
1696
+ }
1697
+ }, function (error) {
1698
+ logWeb34SdkError('I_OpenSound', {
1699
+ error: error,
1700
+ iWndIndex: _this11.windowIndex
1701
+ });
1702
+ });
1703
+ }
1704
+ /**
1705
+ * 设置播放速度
1706
+ * @param speed
1707
+ */
1708
+ }, {
1709
+ key: "setSpeed",
1710
+ value: function setSpeed(speed) {
1711
+ var _this12 = this;
1712
+ var changeSpeed = speed > this.preSpeed ? 'I_PlayFast' : 'I_PlaySlow';
1713
+ var count = Math.abs(Math.log2(speed / this.preSpeed));
1714
+ var promise = Promise.resolve();
1715
+ for (var i = 0; i < count; i++) {
1716
+ promise = promise.then(function () {
1717
+ return new Promise(function (resolve, reject) {
1718
+ var _a, _b;
1719
+ (_b = (_a = window.WebVideoCtrl) === null || _a === void 0 ? void 0 : _a[changeSpeed]) === null || _b === void 0 ? void 0 : _b.call(_a, {
1720
+ iWndIndex: _this12.windowIndex,
1721
+ success: function success() {
1722
+ return resolve();
1723
+ },
1724
+ error: function error() {
1725
+ logWeb34SdkError(changeSpeed, {
1726
+ iWndIndex: _this12.windowIndex,
1727
+ speed: speed
1728
+ });
1729
+ reject();
1730
+ }
1731
+ });
1732
+ });
1733
+ });
1734
+ }
1735
+ this.preSpeed = speed;
1736
+ }
1737
+ /**
1738
+ * 时间更新事件
1739
+ * @param callback 回调函数
1740
+ */
1741
+ }, {
1742
+ key: "onTimeUpdate",
1743
+ value: function onTimeUpdate(callback) {
1744
+ var _this13 = this;
1745
+ if (this.timeUpdateTimer) clearInterval(this.timeUpdateTimer);
1746
+ this.timeUpdateTimer = window.setInterval(function () {
1747
+ var _a, _b;
1748
+ if (!_this13.playing) return;
1749
+ var osdTime = (_b = (_a = window.WebVideoCtrl) === null || _a === void 0 ? void 0 : _a.I_GetOSDTime) === null || _b === void 0 ? void 0 : _b.call(_a, {
1750
+ iWndIndex: _this13.windowIndex
1751
+ });
1752
+ if (!osdTime || !_this13.startTime) return;
1753
+ var currentTime = (0, _moment["default"])(osdTime).diff((0, _moment["default"])(_this13.startTime), 'seconds');
1754
+ callback(currentTime, _this13.preSpeed);
1755
+ }, 1000);
1756
+ this.readyPromise["catch"](function () {
1757
+ if (_this13.timeUpdateTimer) {
1758
+ clearInterval(_this13.timeUpdateTimer);
1759
+ _this13.timeUpdateTimer = undefined;
1760
+ }
1761
+ });
1762
+ }
1763
+ /** 跳转到 */
1764
+ }, {
1765
+ key: "seekTo",
1766
+ value: function seekTo(time) {
1767
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee1() {
1768
+ var seekTime;
1769
+ return _regenerator().w(function (_context1) {
1770
+ while (1) switch (_context1.n) {
1771
+ case 0:
1772
+ seekTime = (0, _moment["default"])(this.startTime).add(time, 'seconds');
1773
+ return _context1.a(2, this.startPlayback(seekTime, this.endTime));
1774
+ }
1775
+ }, _callee1, this);
1776
+ }));
1777
+ }
1778
+ }, {
1779
+ key: "playBackByTime",
1780
+ value: function playBackByTime(startTime, endTime) {
1781
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee10() {
1782
+ return _regenerator().w(function (_context10) {
1783
+ while (1) switch (_context10.n) {
1784
+ case 0:
1785
+ return _context10.a(2, this.startPlayback(startTime, endTime));
1786
+ }
1787
+ }, _callee10, this);
1788
+ }));
1789
+ }
1790
+ /**
1791
+ * 暂停播放
1792
+ * @param callback 回调函数
1793
+ */
1794
+ }, {
1795
+ key: "pause",
1796
+ value: function pause(callback) {
1797
+ var _this14 = this;
1798
+ var _a, _b;
1799
+ var result = (_b = (_a = window.WebVideoCtrl) === null || _a === void 0 ? void 0 : _a.I_Pause) === null || _b === void 0 ? void 0 : _b.call(_a, {
1800
+ iWndIndex: this.windowIndex,
1801
+ success: function success() {
1802
+ return callback && callback();
1803
+ },
1804
+ error: function error() {
1805
+ logWeb34SdkError('I_Pause', {
1806
+ iWndIndex: _this14.windowIndex
1807
+ });
1808
+ callback && callback();
1809
+ }
1810
+ });
1811
+ if (result === -1) {
1812
+ logWeb34SdkError('I_Pause', {
1813
+ result: result,
1814
+ iWndIndex: this.windowIndex
1815
+ });
1816
+ }
1817
+ }
1818
+ /**
1819
+ * 恢复播放
1820
+ * @param callback 回调函数
1821
+ */
1822
+ }, {
1823
+ key: "resume",
1824
+ value: function resume(callback) {
1825
+ var _this15 = this;
1826
+ var _a, _b;
1827
+ var result = (_b = (_a = window.WebVideoCtrl) === null || _a === void 0 ? void 0 : _a.I_Resume) === null || _b === void 0 ? void 0 : _b.call(_a, {
1828
+ iWndIndex: this.windowIndex,
1829
+ success: function success() {
1830
+ return callback && callback();
1831
+ },
1832
+ error: function error() {
1833
+ logWeb34SdkError('I_Resume', {
1834
+ iWndIndex: _this15.windowIndex
1835
+ });
1836
+ callback && callback();
1837
+ }
1838
+ });
1839
+ if (result === -1) {
1840
+ logWeb34SdkError('I_Resume', {
1841
+ result: result,
1842
+ iWndIndex: this.windowIndex
1843
+ });
1844
+ }
1845
+ }
1846
+ }, {
1847
+ key: "ptzControl",
1848
+ value: function ptzControl(action, command) {
1849
+ var _this16 = this;
1850
+ var speed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_PTZ_SPEED;
1851
+ var ptzIndex = PTZ_COMMAND_MAP[command];
1852
+ if (!ptzIndex) return Promise.resolve();
1853
+ return this.readyPromise.then(function () {
1854
+ var _a, _b;
1855
+ var result = (_b = (_a = window.WebVideoCtrl) === null || _a === void 0 ? void 0 : _a.I_PTZControl) === null || _b === void 0 ? void 0 : _b.call(_a, ptzIndex, action === 0, {
1856
+ iWndIndex: _this16.windowIndex,
1857
+ iPTZSpeed: speed
1858
+ });
1859
+ if (result === -1) {
1860
+ logWeb34SdkError('I_PTZControl', {
1861
+ result: result,
1862
+ ptzIndex: ptzIndex,
1863
+ bStop: action === 0,
1864
+ iWndIndex: _this16.windowIndex,
1865
+ iPTZSpeed: speed
1866
+ });
1867
+ }
1868
+ return result;
1869
+ });
1870
+ }
1871
+ /**
1872
+ * 开始对讲
1873
+ * @param url 对讲地址
1874
+ */
1875
+ }, {
1876
+ key: "startTalk",
1877
+ value: function startTalk() {
1878
+ return Promise.reject();
1879
+ }
1880
+ /**
1881
+ * 停止对讲
1882
+ */
1883
+ }, {
1884
+ key: "stopTalk",
1885
+ value: function stopTalk() {
1886
+ return Promise.reject();
1887
+ }
1888
+ }]);
1889
+ }();
1890
+ var _default = exports["default"] = Player;
1891
+ function resolveNoPluginInitError(_ref5) {
1892
+ var sdk = _ref5.sdk,
1893
+ code = _ref5.code,
1894
+ msg = _ref5.msg,
1895
+ error = _ref5.error,
1896
+ _ref5$fallback = _ref5.fallback,
1897
+ fallback = _ref5$fallback === void 0 ? 'No-plugin init failed' : _ref5$fallback;
1898
+ if (!sdk || typeof sdk.I_InitPlugin !== 'function') {
1899
+ return 'No-plugin WebVideoCtrl is not available';
1900
+ }
1901
+ if (msg) {
1902
+ return msg;
1903
+ }
1904
+ if (typeof code !== 'undefined' && code !== null && code !== '') {
1905
+ return "".concat(fallback, " (").concat(code, ")");
1906
+ }
1907
+ if (error === null || error === void 0 ? void 0 : error.message) {
1908
+ return error.message;
1909
+ }
1910
+ return fallback;
1911
+ }
1912
+ //# sourceMappingURL=Web34Player.js.map