@realsee/vreo 2.6.2 → 2.6.4-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/lib/PlayController/createHTMLAudioElement.js +10 -14
  2. package/lib/PlayController/index.js +63 -73
  3. package/lib/Player/App.js +2 -2
  4. package/lib/Player/AudioFocus.d.ts +36 -0
  5. package/lib/Player/AudioFocus.js +139 -0
  6. package/lib/Player/Controller.d.ts +16 -0
  7. package/lib/Player/Controller.js +119 -61
  8. package/lib/Player/custom/SpatialScenePanel/index.js +34 -11
  9. package/lib/Player/index.d.ts +8 -2
  10. package/lib/Player/index.js +182 -123
  11. package/lib/Player/modules/Drawer/index.js +1 -2
  12. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +8 -1
  13. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +173 -203
  14. package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts +1 -0
  15. package/lib/Player/modules/VideoAgent/VideoAgentScene.js +6 -2
  16. package/lib/Player/modules/VideoAgent/index.js +10 -2
  17. package/lib/Player/modules/keyframes/BgMusic/index.js +46 -54
  18. package/lib/Player/modules/keyframes/CameraMovement/index.js +43 -45
  19. package/lib/Player/modules/keyframes/InfoPanel/index.js +37 -32
  20. package/lib/Player/modules/keyframes/ModelVideo/index.js +98 -57
  21. package/lib/Player/modules/keyframes/PanoTag/index.js +1 -1
  22. package/lib/Player/modules/keyframes/PanoTextLabel/index.js +3 -3
  23. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +3 -3
  24. package/lib/Player/modules/keyframes/VideoEffect/index.js +87 -74
  25. package/lib/Player/typings.d.ts +10 -0
  26. package/lib/fivePlugins/CSS3DRenderPlugin/index.js +6 -6
  27. package/lib/fivePlugins/CameraMovementPlugin/index.js +173 -180
  28. package/lib/fivePlugins/CameraMovementPlugin/typings.js +6 -6
  29. package/lib/fivePlugins/ModelTVVideoPlugin/index.d.ts +2 -0
  30. package/lib/fivePlugins/ModelTVVideoPlugin/index.js +87 -43
  31. package/lib/index.d.ts +1 -0
  32. package/lib/react/index.js +1 -1
  33. package/lib/shared-utils/Audio.js +53 -56
  34. package/lib/shared-utils/AudioLike.js +12 -14
  35. package/lib/shared-utils/animationFrame/BetterTween.js +13 -15
  36. package/lib/shared-utils/animationFrame/tween.js +1 -3
  37. package/lib/shared-utils/getMediaInfo.js +0 -1
  38. package/lib/typings/VreoUnit.js +134 -27
  39. package/package.json +6 -4
  40. package/docs/.nojekyll +0 -1
  41. package/docs/assets/custom.css +0 -78
  42. package/docs/assets/hierarchy.js +0 -1
  43. package/docs/assets/highlight.css +0 -127
  44. package/docs/assets/icons.js +0 -18
  45. package/docs/assets/icons.svg +0 -1
  46. package/docs/assets/main.js +0 -60
  47. package/docs/assets/navigation.js +0 -1
  48. package/docs/assets/search.js +0 -1
  49. package/docs/assets/style.css +0 -1640
  50. package/docs/classes/Player.AudioLike.html +0 -15
  51. package/docs/classes/Player.Controller.html +0 -87
  52. package/docs/classes/Player.Player.html +0 -54
  53. package/docs/classes/Player.VideoAgentMesh.html +0 -72
  54. package/docs/classes/Player.VideoAgentScene.html +0 -9
  55. package/docs/demo/assets/AppReact-CkuqZtcS.js +0 -1
  56. package/docs/demo/assets/default-BQGCQRLt.css +0 -1
  57. package/docs/demo/assets/default-CVvVdmSW.js +0 -5540
  58. package/docs/demo/assets/dynamic-CO5wq52h.js +0 -1
  59. package/docs/demo/assets/examples-BCLzFApO.css +0 -1
  60. package/docs/demo/assets/examples-DfiAz2fR.js +0 -25
  61. package/docs/demo/assets/index-CBBSwaYT.js +0 -1
  62. package/docs/demo/assets/index-CmEXi2sK.css +0 -1
  63. package/docs/demo/assets/main-BF1tvUg-.js +0 -25
  64. package/docs/demo/assets/react-BnzBLum3.css +0 -1
  65. package/docs/demo/assets/react-C4h9qndP.js +0 -25
  66. package/docs/demo/examples.html +0 -16
  67. package/docs/demo/index-react-dynamic.html +0 -18
  68. package/docs/demo/index-react.html +0 -19
  69. package/docs/demo/index.html +0 -19
  70. package/docs/enums/Player.InfoPanelStyleEnum.html +0 -3
  71. package/docs/enums/Player.InfoPanelTypeEnum.html +0 -4
  72. package/docs/enums/Player.PanoEffectEnum.html +0 -4
  73. package/docs/enums/Player.PanoTagEnum.html +0 -4
  74. package/docs/enums/Player.PanoTagStyleEnum.html +0 -6
  75. package/docs/enums/Player.VreoKeyframeEnum.html +0 -25
  76. package/docs/enums/fivePlugins.CameraMovementEffect.html +0 -3
  77. package/docs/enums/fivePlugins.Rotation.html +0 -4
  78. package/docs/functions/custom.SpatialScenePanel.html +0 -2
  79. package/docs/functions/react.useVreoAction.html +0 -8
  80. package/docs/functions/react.useVreoEventCallback.html +0 -10
  81. package/docs/functions/react.useVreoPausedState.html +0 -8
  82. package/docs/hierarchy.html +0 -1
  83. package/docs/index.html +0 -160
  84. package/docs/interfaces/Player.Appearance.html +0 -2
  85. package/docs/interfaces/Player.CustomVreoKeyframeProps.html +0 -3
  86. package/docs/interfaces/Player.PlayerConfigs.html +0 -20
  87. package/docs/interfaces/Player.Vertex.html +0 -5
  88. package/docs/interfaces/Player.VideoAgentMeshOptions.html +0 -9
  89. package/docs/interfaces/Player.VreoKeyframe.html +0 -8
  90. package/docs/interfaces/Player.VreoUnit.html +0 -9
  91. package/docs/interfaces/Player.VreoVideo.html +0 -7
  92. package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +0 -8
  93. package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +0 -3
  94. package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +0 -5
  95. package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +0 -1
  96. package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +0 -5
  97. package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +0 -4
  98. package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +0 -2
  99. package/docs/interfaces/fivePlugins.Vector3Position.html +0 -5
  100. package/docs/interfaces/react.VreoActionCallbacks.html +0 -18
  101. package/docs/interfaces/react.VreoProviderProps.html +0 -6
  102. package/docs/modules/Player.html +0 -1
  103. package/docs/modules/custom.html +0 -1
  104. package/docs/modules/fivePlugins.html +0 -1
  105. package/docs/modules/react.html +0 -1
  106. package/docs/modules.html +0 -1
  107. package/docs/types/Player.AppSize.html +0 -1
  108. package/docs/types/Player.AudioLikeEvent.html +0 -6
  109. package/docs/types/Player.CameraMovementData.html +0 -2
  110. package/docs/types/Player.CustomData.html +0 -2
  111. package/docs/types/Player.InfoPanelData.html +0 -7
  112. package/docs/types/Player.ModelVideoData.html +0 -9
  113. package/docs/types/Player.PanoEffectData.html +0 -4
  114. package/docs/types/Player.PanoTagData.html +0 -6
  115. package/docs/types/Player.PanoTextLabelData.html +0 -7
  116. package/docs/types/Player.PrompterData.html +0 -3
  117. package/docs/types/Player.QuadrangleVertexs.html +0 -2
  118. package/docs/types/Player.Quaternion.html +0 -6
  119. package/docs/types/Player.UpdateVRPanoramaData.html +0 -7
  120. package/docs/types/Player.Vertexs.html +0 -2
  121. package/docs/types/Player.VideoEffectData.html +0 -7
  122. package/docs/types/Player.VreoKeyframeEvent.html +0 -2
  123. package/docs/types/Player.VreoKeyframeMap.html +0 -6
  124. package/docs/types/Player.VreoSubscribe.html +0 -1
  125. package/docs/types/Player.WaveAppearance.html +0 -1
  126. package/docs/types/fivePlugins.CSS3DRenderPluginParameterType.html +0 -1
  127. package/docs/types/fivePlugins.MoveArgs.html +0 -1
  128. package/docs/types/fivePlugins.MoveOpts.html +0 -1
  129. package/docs/types/fivePlugins.RotateArgs.html +0 -1
  130. package/docs/types/fivePlugins.RotateOpts.html +0 -1
  131. package/docs/variables/fivePlugins.CSS3DRenderPlugin.html +0 -3
  132. package/docs/variables/fivePlugins.CameraMovementPlugin.html +0 -2
  133. package/docs/variables/fivePlugins.ModelTVVideoPlugin.html +0 -1
  134. package/docs/variables/react.VreoProvider.html +0 -9
@@ -1,16 +1,17 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
2
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import _inherits from "@babel/runtime/helpers/esm/inherits";
5
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
5
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
6
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
7
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
8
  var _location$search$matc, _location$search$matc2;
8
- import _regeneratorRuntime from "@babel/runtime/regenerator";
9
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
9
+ 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 }; })(); }
10
+ 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); }
11
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
12
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
13
  // 下面这一行不能删
12
14
  import * as React from 'react';
13
- import * as ReactDOM from 'react-dom';
14
15
  import { createRoot } from 'react-dom/client';
15
16
  import { Subscribe } from '@realsee/five';
16
17
  import { App } from "./App.js";
@@ -48,14 +49,6 @@ var audioCacheLength = Number((_location$search$matc = (_location$search$matc2 =
48
49
  * ```
49
50
  */
50
51
  export var Player = /*#__PURE__*/function (_Subscribe) {
51
- _inherits(Player, _Subscribe);
52
- var _super = _createSuper(Player);
53
- /** Five 渲染引擎实例 */
54
-
55
- /** 内部控制器 */
56
-
57
- /** 播放器配置(只读) */
58
-
59
52
  /**
60
53
  * 创建 Vreo 播放器实例
61
54
  *
@@ -66,7 +59,12 @@ export var Player = /*#__PURE__*/function (_Subscribe) {
66
59
  var _this;
67
60
  var configs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
68
61
  _classCallCheck(this, Player);
69
- _this = _super.call(this);
62
+ _this = _callSuper(this, Player);
63
+ /** Five 渲染引擎实例 */
64
+ /** 内部控制器 */
65
+ _defineProperty(_this, "disposers", []);
66
+ _defineProperty(_this, "loadGeneration", 0);
67
+ _defineProperty(_this, "disposed", false);
70
68
  _this.$five = five;
71
69
  generateBlankAudio(audioCacheLength);
72
70
  if (!configs.container) {
@@ -97,8 +95,8 @@ export var Player = /*#__PURE__*/function (_Subscribe) {
97
95
  container: configs.container,
98
96
  configs: _this.configs
99
97
  });
100
- var root = createRoot(configs.container);
101
- root.render( /*#__PURE__*/React.createElement(ControllerContext.Provider, {
98
+ _this.root = createRoot(configs.container);
99
+ _this.root.render(/*#__PURE__*/React.createElement(ControllerContext.Provider, {
102
100
  value: _this.controller
103
101
  }, /*#__PURE__*/React.createElement(App, null), /*#__PURE__*/React.createElement(Drawer, null), /*#__PURE__*/React.createElement(PopUp, null), _this.configs.customKeyframes && _this.configs.customKeyframes.map(function (CustomCmpt, key) {
104
102
  return /*#__PURE__*/React.createElement(CustomCmpt, {
@@ -114,25 +112,26 @@ export var Player = /*#__PURE__*/function (_Subscribe) {
114
112
  return _this.off(name, callback);
115
113
  }
116
114
  },
117
- five: five
115
+ five: five,
116
+ audioFocus: _this.audioFocus
118
117
  });
119
118
  })));
120
119
 
121
120
  // 监听播放情况:抛出触发时机
122
- reaction(function () {
121
+ _this.disposers.push(reaction(function () {
123
122
  return _this.controller.ended;
124
123
  }, function (ended) {
125
124
  if (ended) {
126
125
  _this.emit('paused', true);
127
126
  }
128
- });
129
- reaction(function () {
127
+ }));
128
+ _this.disposers.push(reaction(function () {
130
129
  return _this.controller.playing;
131
130
  }, function (playing) {
132
131
  if (!_this.controller.ended) {
133
132
  _this.emit(playing ? 'playing' : 'paused');
134
133
  }
135
- });
134
+ }));
136
135
  return _this;
137
136
  }
138
137
 
@@ -159,116 +158,168 @@ export var Player = /*#__PURE__*/function (_Subscribe) {
159
158
  * await player.load(vreoUnit, 0, false, true)
160
159
  * ```
161
160
  */
162
- _createClass(Player, [{
161
+ _inherits(Player, _Subscribe);
162
+ return _createClass(Player, [{
163
+ key: "audioFocus",
164
+ get: function get() {
165
+ return this.controller.audioFocus.host;
166
+ }
167
+ /** 播放器配置(只读) */
168
+ }, {
163
169
  key: "load",
164
- value: function () {
165
- var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(vreoUnit) {
166
- var _this$controller$medi,
167
- _this$configs$imageOp,
168
- _this$controller$vide,
169
- _this$controller$vide2,
170
- _this2 = this;
170
+ value: (function () {
171
+ var _load = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(vreoUnit) {
172
+ var _this2 = this;
171
173
  var currentTime,
172
174
  preload,
173
175
  force,
176
+ intent,
177
+ generation,
178
+ valid,
179
+ _this$controller$medi,
180
+ _this$configs$imageOp,
181
+ _this$controller$vide,
182
+ _this$controller$vide2,
174
183
  panoIndexMap,
175
184
  panoIndexes,
176
185
  i,
177
- _args = arguments;
178
- return _regeneratorRuntime.wrap(function _callee$(_context) {
179
- while (1) {
180
- switch (_context.prev = _context.next) {
181
- case 0:
182
- currentTime = _args.length > 1 && _args[1] !== undefined ? _args[1] : 0;
183
- preload = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
184
- force = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
185
- this.controller.clear();
186
- this.controller.setLoading(true);
187
- if (force) {
188
- vreoUnit = JSON.parse(JSON.stringify(vreoUnit));
189
- }
190
- // if (!this.controller.visible) {
191
- // this.controller.setVisible(true)
192
- // // 延迟 500ms 规避跟 DOM 动画冲突
193
- // await new Promise((resolve) => {
194
- // setTimeout(() => resolve(true), 500)
195
- // })
196
- // }
186
+ _args = arguments,
187
+ _t;
188
+ return _regenerator().w(function (_context) {
189
+ while (1) switch (_context.p = _context.n) {
190
+ case 0:
191
+ currentTime = _args.length > 1 && _args[1] !== undefined ? _args[1] : 0;
192
+ preload = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
193
+ force = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
194
+ intent = _args.length > 4 && _args[4] !== undefined ? _args[4] : 'auto';
195
+ generation = ++this.loadGeneration;
196
+ this.controller.audioFocus.cancel('replaced');
197
+ if (!(this.disposed || !this.controller.audioFocus.acquire(intent))) {
198
+ _context.n = 1;
199
+ break;
200
+ }
201
+ return _context.a(2, false);
202
+ case 1:
203
+ valid = this.controller.audioFocus.capture();
204
+ _context.p = 2;
205
+ this.controller.clear();
206
+ this.controller.setLoading(true);
207
+ if (force) {
208
+ vreoUnit = JSON.parse(JSON.stringify(vreoUnit));
209
+ }
210
+ // if (!this.controller.visible) {
211
+ // this.controller.setVisible(true)
212
+ // // 延迟 500ms 规避跟 DOM 动画冲突
213
+ // await new Promise((resolve) => {
214
+ // setTimeout(() => resolve(true), 500)
215
+ // })
216
+ // }
197
217
 
198
- if (this.controller.stopInterval) {
199
- this.controller.stopInterval();
200
- this.controller.stopInterval = undefined;
201
- }
202
- this.controller.vreoUnit = vreoUnit;
203
- (_this$controller$medi = this.controller.mediaInstance) === null || _this$controller$medi === void 0 ? void 0 : _this$controller$medi.pause();
218
+ if (this.controller.stopInterval) {
219
+ this.controller.stopInterval();
220
+ this.controller.stopInterval = undefined;
221
+ }
222
+ this.controller.vreoUnit = vreoUnit;
223
+ (_this$controller$medi = this.controller.mediaInstance) === null || _this$controller$medi === void 0 || _this$controller$medi.pause();
204
224
 
205
- // 预载逻辑
206
- // 是否降低图片分辨率
207
- if (this.$five.imageOptions.size && (_this$configs$imageOp = this.configs.imageOptions) !== null && _this$configs$imageOp !== void 0 && _this$configs$imageOp.size && this.$five.imageOptions.size > this.configs.imageOptions.size) {
208
- this.$five.imageOptions.size = this.configs.imageOptions.size;
209
- }
225
+ // 预载逻辑
226
+ // 是否降低图片分辨率
227
+ if (this.$five.imageOptions.size && (_this$configs$imageOp = this.configs.imageOptions) !== null && _this$configs$imageOp !== void 0 && _this$configs$imageOp.size && this.$five.imageOptions.size > this.configs.imageOptions.size) {
228
+ this.$five.imageOptions.size = this.configs.imageOptions.size;
229
+ }
210
230
 
211
- // 预载数据中的点位
212
- if (!(preload || preload === undefined && this.configs.autoPreload)) {
213
- _context.next = 20;
214
- break;
231
+ // 预载数据中的点位
232
+ if (!(preload || preload === undefined && this.configs.autoPreload)) {
233
+ _context.n = 6;
234
+ break;
235
+ }
236
+ panoIndexMap = vreoUnit.keyframes.filter(function (vreoKeyframe) {
237
+ if (vreoKeyframe.type !== VreoKeyframeEnum.CameraMovement) {
238
+ return false;
215
239
  }
216
- panoIndexMap = vreoUnit.keyframes.filter(function (vreoKeyframe) {
217
- if (vreoKeyframe.type !== VreoKeyframeEnum.CameraMovement) {
218
- return false;
219
- }
220
- var data = vreoKeyframe.data;
221
- if (data.panoIndex === undefined) {
222
- return false;
223
- }
224
- return true;
225
- }).reduce(function (accu, curr) {
226
- var panoIndex = curr.data.panoIndex;
227
- if (!accu[panoIndex]) {
228
- accu[panoIndex] = true;
229
- }
230
- return accu;
231
- }, {});
232
- panoIndexes = Object.keys(panoIndexMap);
233
- i = 0;
234
- case 14:
235
- if (!(i < panoIndexes.length)) {
236
- _context.next = 20;
237
- break;
240
+ var data = vreoKeyframe.data;
241
+ if (data.panoIndex === undefined) {
242
+ return false;
238
243
  }
239
- _context.next = 17;
240
- return this.$five.preloadPano(Number(panoIndexes[i]));
241
- case 17:
242
- i++;
243
- _context.next = 14;
244
- break;
245
- case 20:
246
- // 新数据载入就绪
247
- this.emit('loaded', vreoUnit);
248
- this.controller.emit('loaded', vreoUnit);
249
- if ((_this$controller$vide = this.controller.videoAgentScene) !== null && _this$controller$vide !== void 0 && _this$controller$vide.videoAgentMesh.mediaInstance) {
250
- this.controller.videoAgentScene.videoAgentMesh.mediaInstance.currentTime = currentTime / 1000;
244
+ return true;
245
+ }).reduce(function (accu, curr) {
246
+ var panoIndex = curr.data.panoIndex;
247
+ if (!accu[panoIndex]) {
248
+ accu[panoIndex] = true;
251
249
  }
252
- this.controller.setAvatar(vreoUnit.video.avatar);
253
- _context.next = 26;
254
- return waitForBlankAudioGenerated();
255
- case 26:
256
- _context.next = 28;
257
- return (_this$controller$vide2 = this.controller.videoAgentScene) === null || _this$controller$vide2 === void 0 ? void 0 : _this$controller$vide2.videoAgentMesh.play(vreoUnit.video.url, currentTime / 1000, vreoUnit.video.duration);
258
- case 28:
259
- this.controller.setEnded(false);
260
- this.play();
261
- this.controller.run(function (type, keyframe) {
262
- return _this2.emit(type, keyframe, _this2.controller.currentTime);
263
- });
264
- this.controller.setLoading(false);
265
- return _context.abrupt("return", true);
266
- case 33:
267
- case "end":
268
- return _context.stop();
269
- }
250
+ return accu;
251
+ }, {});
252
+ panoIndexes = Object.keys(panoIndexMap);
253
+ i = 0;
254
+ case 3:
255
+ if (!(i < panoIndexes.length)) {
256
+ _context.n = 6;
257
+ break;
258
+ }
259
+ _context.n = 4;
260
+ return this.$five.preloadPano(Number(panoIndexes[i]));
261
+ case 4:
262
+ if (!(!valid() || generation !== this.loadGeneration)) {
263
+ _context.n = 5;
264
+ break;
265
+ }
266
+ return _context.a(2, false);
267
+ case 5:
268
+ i++;
269
+ _context.n = 3;
270
+ break;
271
+ case 6:
272
+ // 新数据载入就绪
273
+ this.emit('loaded', vreoUnit);
274
+ this.controller.emit('loaded', vreoUnit);
275
+ if ((_this$controller$vide = this.controller.videoAgentScene) !== null && _this$controller$vide !== void 0 && _this$controller$vide.videoAgentMesh.mediaInstance) {
276
+ this.controller.videoAgentScene.videoAgentMesh.mediaInstance.currentTime = currentTime / 1000;
277
+ }
278
+ this.controller.setAvatar(vreoUnit.video.avatar);
279
+ _context.n = 7;
280
+ return waitForBlankAudioGenerated();
281
+ case 7:
282
+ if (!(!valid() || generation !== this.loadGeneration)) {
283
+ _context.n = 8;
284
+ break;
285
+ }
286
+ return _context.a(2, false);
287
+ case 8:
288
+ _context.n = 9;
289
+ return (_this$controller$vide2 = this.controller.videoAgentScene) === null || _this$controller$vide2 === void 0 ? void 0 : _this$controller$vide2.videoAgentMesh.play(vreoUnit.video.url, currentTime / 1000, vreoUnit.video.duration);
290
+ case 9:
291
+ if (!(!valid() || generation !== this.loadGeneration)) {
292
+ _context.n = 10;
293
+ break;
294
+ }
295
+ return _context.a(2, false);
296
+ case 10:
297
+ this.controller.setEnded(false);
298
+ this.play(undefined, intent);
299
+ this.controller.run(function (type, keyframe) {
300
+ return _this2.emit(type, keyframe, _this2.controller.currentTime);
301
+ });
302
+ this.controller.setLoading(false);
303
+ return _context.a(2, true);
304
+ case 11:
305
+ _context.p = 11;
306
+ _t = _context.v;
307
+ if (valid()) {
308
+ _context.n = 12;
309
+ break;
310
+ }
311
+ return _context.a(2, false);
312
+ case 12:
313
+ this.controller.audioFocus.cancel('paused');
314
+ throw _t;
315
+ case 13:
316
+ _context.p = 13;
317
+ if (generation === this.loadGeneration) this.controller.setLoading(false);
318
+ return _context.f(13);
319
+ case 14:
320
+ return _context.a(2);
270
321
  }
271
- }, _callee, this);
322
+ }, _callee, this, [[2, 11, 13, 14]]);
272
323
  }));
273
324
  function load(_x) {
274
325
  return _load.apply(this, arguments);
@@ -279,6 +330,7 @@ export var Player = /*#__PURE__*/function (_Subscribe) {
279
330
  * 获取播放器是否处于暂停状态
280
331
  * @returns 是否暂停中
281
332
  */
333
+ )
282
334
  }, {
283
335
  key: "paused",
284
336
  get: function get() {
@@ -304,6 +356,8 @@ export var Player = /*#__PURE__*/function (_Subscribe) {
304
356
  key: "play",
305
357
  value: function play(currentTime) {
306
358
  var _this$controller$vreo;
359
+ var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'auto';
360
+ if (this.disposed || !this.controller.audioFocus.acquire(intent)) return false;
307
361
  if (this.controller.playing) return true;
308
362
  if (currentTime && this.controller.mediaInstance) {
309
363
  this.controller.mediaInstance.currentTime = currentTime / 1000;
@@ -313,7 +367,7 @@ export var Player = /*#__PURE__*/function (_Subscribe) {
313
367
  });
314
368
  this.controller.setEnded(false);
315
369
  this.controller.setPlaying(true);
316
- (_this$controller$vreo = this.controller.vreoUnit) === null || _this$controller$vreo === void 0 ? void 0 : _this$controller$vreo.keyframes.forEach(function (keyframe) {
370
+ (_this$controller$vreo = this.controller.vreoUnit) === null || _this$controller$vreo === void 0 || _this$controller$vreo.keyframes.forEach(function (keyframe) {
317
371
  if (keyframe.type === VreoKeyframeEnum.BgMusic) {
318
372
  keyframe.parsed = false;
319
373
  }
@@ -344,7 +398,9 @@ export var Player = /*#__PURE__*/function (_Subscribe) {
344
398
  }, {
345
399
  key: "pause",
346
400
  value: function pause() {
347
- this.controller.setPlaying(false);
401
+ ++this.loadGeneration;
402
+ this.controller.audioFocus.cancel('paused');
403
+ this.controller.setLoading(false);
348
404
  }
349
405
 
350
406
  /**
@@ -383,13 +439,16 @@ export var Player = /*#__PURE__*/function (_Subscribe) {
383
439
  }, {
384
440
  key: "dispose",
385
441
  value: function dispose() {
442
+ if (this.disposed) return;
443
+ this.disposed = true;
444
+ ++this.loadGeneration;
445
+ this.disposers.forEach(function (dispose) {
446
+ return dispose();
447
+ });
386
448
  this.controller.dispose();
387
- if (this.configs.container) {
388
- ReactDOM.unmountComponentAtNode(this.configs.container);
389
- }
449
+ this.root.unmount();
390
450
  }
391
451
  }]);
392
- return Player;
393
452
  }(Subscribe);
394
453
 
395
454
  // 导出自定义组件
@@ -6,8 +6,7 @@ var DrawerView = observer(function (_ref) {
6
6
  var _controller$drawerCon2;
7
7
  var controller = _ref.controller;
8
8
  var maxHeight = '400px';
9
- var height = function () {
10
- var _controller$drawerCon;
9
+ var height = function (_controller$drawerCon) {
11
10
  var height = (_controller$drawerCon = controller.drawerConfig) === null || _controller$drawerCon === void 0 ? void 0 : _controller$drawerCon.height;
12
11
  if (!height) {
13
12
  return 'max-content';
@@ -4,6 +4,7 @@ import AudioLike from '../../../shared-utils/AudioLike';
4
4
  * 视频经纪人贴片的配置选项
5
5
  */
6
6
  export interface VideoAgentMeshOptions {
7
+ canPlay?: () => boolean;
7
8
  /**
8
9
  * 自定义视频实例。
9
10
  */
@@ -58,6 +59,11 @@ export declare class VideoAgentMesh extends THREE.Mesh {
58
59
  /** 是否暂停状态 */
59
60
  paused: boolean;
60
61
  /** 音频实例 */
62
+ private ownsVideo;
63
+ private ownsAudio;
64
+ private generation;
65
+ private removeStart?;
66
+ private objectURL?;
61
67
  audioInstance: HTMLAudioElement;
62
68
  /** AudioLike 实例 */
63
69
  audioLikeInstance: AudioLike;
@@ -125,7 +131,8 @@ export declare class VideoAgentMesh extends THREE.Mesh {
125
131
  * await mesh.play()
126
132
  * ```
127
133
  */
128
- play(videoUrl?: string, currentTime?: number, duration?: number): Promise<unknown>;
134
+ play(videoUrl?: string, currentTime?: number, duration?: number): Promise<boolean>;
135
+ stop(): void;
129
136
  /**
130
137
  * 获取当前播放时间(毫秒)
131
138
  *