@realsee/vreo 2.6.4-alpha.1 → 2.6.4-alpha.3

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 (136) 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/Controller.d.ts +7 -1
  5. package/lib/Player/Controller.js +112 -75
  6. package/lib/Player/PlaybackLifecycle.d.ts +25 -0
  7. package/lib/Player/PlaybackLifecycle.js +117 -0
  8. package/lib/Player/custom/SpatialScenePanel/index.js +34 -11
  9. package/lib/Player/index.d.ts +7 -2
  10. package/lib/Player/index.js +198 -126
  11. package/lib/Player/modules/Drawer/index.js +1 -2
  12. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +13 -1
  13. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +209 -204
  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 +50 -74
  18. package/lib/Player/modules/keyframes/CameraMovement/index.js +43 -45
  19. package/lib/Player/modules/keyframes/InfoPanel/index.js +45 -35
  20. package/lib/Player/modules/keyframes/ModelVideo/index.js +95 -57
  21. package/lib/Player/modules/keyframes/PanoTag/index.js +4 -2
  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 +93 -79
  25. package/lib/Player/playback-types.d.ts +21 -0
  26. package/lib/Player/playback-types.js +1 -0
  27. package/lib/Player/typings.d.ts +3 -0
  28. package/lib/fivePlugins/CSS3DRenderPlugin/index.js +6 -6
  29. package/lib/fivePlugins/CameraMovementPlugin/index.js +173 -180
  30. package/lib/fivePlugins/CameraMovementPlugin/typings.js +6 -6
  31. package/lib/fivePlugins/ModelTVVideoPlugin/index.d.ts +3 -0
  32. package/lib/fivePlugins/ModelTVVideoPlugin/index.js +182 -75
  33. package/lib/index.d.ts +1 -0
  34. package/lib/react/index.js +1 -1
  35. package/lib/shared-utils/Audio.js +55 -57
  36. package/lib/shared-utils/AudioLike.js +12 -14
  37. package/lib/shared-utils/animationFrame/BetterTween.js +13 -15
  38. package/lib/shared-utils/animationFrame/tween.js +1 -3
  39. package/lib/shared-utils/getMediaInfo.js +0 -1
  40. package/lib/typings/VreoUnit.js +134 -27
  41. package/package.json +6 -4
  42. package/docs/.nojekyll +0 -1
  43. package/docs/assets/custom.css +0 -78
  44. package/docs/assets/hierarchy.js +0 -1
  45. package/docs/assets/highlight.css +0 -127
  46. package/docs/assets/icons.js +0 -18
  47. package/docs/assets/icons.svg +0 -1
  48. package/docs/assets/main.js +0 -60
  49. package/docs/assets/navigation.js +0 -1
  50. package/docs/assets/search.js +0 -1
  51. package/docs/assets/style.css +0 -1640
  52. package/docs/classes/Player.AudioLike.html +0 -15
  53. package/docs/classes/Player.Controller.html +0 -87
  54. package/docs/classes/Player.Player.html +0 -54
  55. package/docs/classes/Player.VideoAgentMesh.html +0 -72
  56. package/docs/classes/Player.VideoAgentScene.html +0 -9
  57. package/docs/demo/assets/AppReact-CkuqZtcS.js +0 -1
  58. package/docs/demo/assets/default-BQGCQRLt.css +0 -1
  59. package/docs/demo/assets/default-CVvVdmSW.js +0 -5540
  60. package/docs/demo/assets/dynamic-CO5wq52h.js +0 -1
  61. package/docs/demo/assets/examples-BCLzFApO.css +0 -1
  62. package/docs/demo/assets/examples-DfiAz2fR.js +0 -25
  63. package/docs/demo/assets/index-CBBSwaYT.js +0 -1
  64. package/docs/demo/assets/index-CmEXi2sK.css +0 -1
  65. package/docs/demo/assets/main-BF1tvUg-.js +0 -25
  66. package/docs/demo/assets/react-BnzBLum3.css +0 -1
  67. package/docs/demo/assets/react-C4h9qndP.js +0 -25
  68. package/docs/demo/examples.html +0 -16
  69. package/docs/demo/index-react-dynamic.html +0 -18
  70. package/docs/demo/index-react.html +0 -19
  71. package/docs/demo/index.html +0 -19
  72. package/docs/enums/Player.InfoPanelStyleEnum.html +0 -3
  73. package/docs/enums/Player.InfoPanelTypeEnum.html +0 -4
  74. package/docs/enums/Player.PanoEffectEnum.html +0 -4
  75. package/docs/enums/Player.PanoTagEnum.html +0 -4
  76. package/docs/enums/Player.PanoTagStyleEnum.html +0 -6
  77. package/docs/enums/Player.VreoKeyframeEnum.html +0 -25
  78. package/docs/enums/fivePlugins.CameraMovementEffect.html +0 -3
  79. package/docs/enums/fivePlugins.Rotation.html +0 -4
  80. package/docs/functions/custom.SpatialScenePanel.html +0 -2
  81. package/docs/functions/react.useVreoAction.html +0 -8
  82. package/docs/functions/react.useVreoEventCallback.html +0 -10
  83. package/docs/functions/react.useVreoPausedState.html +0 -8
  84. package/docs/hierarchy.html +0 -1
  85. package/docs/index.html +0 -160
  86. package/docs/interfaces/Player.Appearance.html +0 -2
  87. package/docs/interfaces/Player.CustomVreoKeyframeProps.html +0 -3
  88. package/docs/interfaces/Player.PlayerConfigs.html +0 -20
  89. package/docs/interfaces/Player.Vertex.html +0 -5
  90. package/docs/interfaces/Player.VideoAgentMeshOptions.html +0 -9
  91. package/docs/interfaces/Player.VreoKeyframe.html +0 -8
  92. package/docs/interfaces/Player.VreoUnit.html +0 -9
  93. package/docs/interfaces/Player.VreoVideo.html +0 -7
  94. package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +0 -8
  95. package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +0 -3
  96. package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +0 -5
  97. package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +0 -1
  98. package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +0 -5
  99. package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +0 -4
  100. package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +0 -2
  101. package/docs/interfaces/fivePlugins.Vector3Position.html +0 -5
  102. package/docs/interfaces/react.VreoActionCallbacks.html +0 -18
  103. package/docs/interfaces/react.VreoProviderProps.html +0 -6
  104. package/docs/modules/Player.html +0 -1
  105. package/docs/modules/custom.html +0 -1
  106. package/docs/modules/fivePlugins.html +0 -1
  107. package/docs/modules/react.html +0 -1
  108. package/docs/modules.html +0 -1
  109. package/docs/types/Player.AppSize.html +0 -1
  110. package/docs/types/Player.AudioLikeEvent.html +0 -6
  111. package/docs/types/Player.CameraMovementData.html +0 -2
  112. package/docs/types/Player.CustomData.html +0 -2
  113. package/docs/types/Player.InfoPanelData.html +0 -7
  114. package/docs/types/Player.ModelVideoData.html +0 -9
  115. package/docs/types/Player.PanoEffectData.html +0 -4
  116. package/docs/types/Player.PanoTagData.html +0 -6
  117. package/docs/types/Player.PanoTextLabelData.html +0 -7
  118. package/docs/types/Player.PrompterData.html +0 -3
  119. package/docs/types/Player.QuadrangleVertexs.html +0 -2
  120. package/docs/types/Player.Quaternion.html +0 -6
  121. package/docs/types/Player.UpdateVRPanoramaData.html +0 -7
  122. package/docs/types/Player.Vertexs.html +0 -2
  123. package/docs/types/Player.VideoEffectData.html +0 -7
  124. package/docs/types/Player.VreoKeyframeEvent.html +0 -2
  125. package/docs/types/Player.VreoKeyframeMap.html +0 -6
  126. package/docs/types/Player.VreoSubscribe.html +0 -1
  127. package/docs/types/Player.WaveAppearance.html +0 -1
  128. package/docs/types/fivePlugins.CSS3DRenderPluginParameterType.html +0 -1
  129. package/docs/types/fivePlugins.MoveArgs.html +0 -1
  130. package/docs/types/fivePlugins.MoveOpts.html +0 -1
  131. package/docs/types/fivePlugins.RotateArgs.html +0 -1
  132. package/docs/types/fivePlugins.RotateOpts.html +0 -1
  133. package/docs/variables/fivePlugins.CSS3DRenderPlugin.html +0 -3
  134. package/docs/variables/fivePlugins.CameraMovementPlugin.html +0 -2
  135. package/docs/variables/fivePlugins.ModelTVVideoPlugin.html +0 -1
  136. package/docs/variables/react.VreoProvider.html +0 -9
@@ -1,15 +1,15 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
5
- import _inherits from "@babel/runtime/helpers/esm/inherits";
6
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
7
5
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
6
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
8
7
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
11
- 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); }; }
12
- 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; } }
8
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
12
+ import { PlaybackLifecycle } from "./PlaybackLifecycle.js";
13
13
  import { Subscribe } from '@realsee/five';
14
14
  import { action, makeObservable, observable, reaction } from 'mobx';
15
15
  import * as React from 'react';
@@ -42,44 +42,57 @@ import { getMediaType } from "../shared-utils/getMediaInfo.js";
42
42
  * ```
43
43
  */
44
44
  export var Controller = /*#__PURE__*/function (_Subscribe) {
45
- _inherits(Controller, _Subscribe);
46
- var _super = _createSuper(Controller);
47
- /**
48
- * 创建 Controller 实例
49
- * @param params - 构造参数对象
50
- * @param params.five - Five 渲染引擎实例
51
- * @param params.container - DOM 容器元素
52
- * @param params.configs - 播放器配置
53
- */
54
45
  function Controller(_ref) {
55
46
  var _this;
56
47
  var five = _ref.five,
57
48
  container = _ref.container,
58
49
  configs = _ref.configs;
59
50
  _classCallCheck(this, Controller);
60
- _this = _super.call(this);
61
- _defineProperty(_assertThisInitialized(_this), "playing", false);
62
- _defineProperty(_assertThisInitialized(_this), "ended", false);
63
- _defineProperty(_assertThisInitialized(_this), "loading", false);
64
- _defineProperty(_assertThisInitialized(_this), "containerSize", {
51
+ _this = _callSuper(this, Controller);
52
+ _defineProperty(_this, "playing", false);
53
+ _defineProperty(_this, "ended", false);
54
+ _defineProperty(_this, "loading", false);
55
+ // null 表示加载失败
56
+ _defineProperty(_this, "containerSize", {
65
57
  width: 0,
66
58
  height: 0
67
59
  });
68
- _defineProperty(_assertThisInitialized(_this), "waveAppearance", null);
69
- _defineProperty(_assertThisInitialized(_this), "appearance", {
60
+ _defineProperty(_this, "waveAppearance", null);
61
+ _defineProperty(_this, "appearance", {
70
62
  waveStyle: 'wave'
71
63
  });
72
- _defineProperty(_assertThisInitialized(_this), "avatar", {});
73
- _defineProperty(_assertThisInitialized(_this), "waitingForBgMusic", false);
74
- _defineProperty(_assertThisInitialized(_this), "visible", false);
75
- _defineProperty(_assertThisInitialized(_this), "popUp", null);
76
- _defineProperty(_assertThisInitialized(_this), "drawerConfig", null);
64
+ _defineProperty(_this, "avatar", {});
65
+ /**
66
+ * 是否正在等待背景音乐加载
67
+ * 当此状态为 true 时,播放流程会暂停,等待音频加载完成
68
+ */
69
+ _defineProperty(_this, "waitingForBgMusic", false);
70
+ _defineProperty(_this, "visible", false);
71
+ _defineProperty(_this, "popUp", null);
72
+ _defineProperty(_this, "drawerConfig", null);
73
+ /**
74
+ * 创建 Controller 实例
75
+ * @param params - 构造参数对象
76
+ * @param params.five - Five 渲染引擎实例
77
+ * @param params.container - DOM 容器元素
78
+ * @param params.configs - 播放器配置
79
+ */
80
+ _defineProperty(_this, "resumeGeneration", 0);
81
+ _defineProperty(_this, "disposers", []);
82
+ _this.playback = new PlaybackLifecycle(configs.mediaManager, function () {
83
+ var _this$videoAgentScene;
84
+ _this.resuming = undefined;
85
+ ++_this.resumeGeneration;
86
+ _this.setPlaying(false);
87
+ (_this$videoAgentScene = _this.videoAgentScene) === null || _this$videoAgentScene === void 0 || _this$videoAgentScene.videoAgentMesh.stop();
88
+ _this.setWaitingForBgMusic(false);
89
+ });
77
90
  _this.configs = configs;
78
91
  _this.container = container;
79
92
  _this.five = five;
80
93
  _this.appSize = configs.appSize;
81
94
  _this.appearance = _objectSpread(_objectSpread({}, _this.appearance), configs.appearance);
82
- makeObservable(_assertThisInitialized(_this), {
95
+ makeObservable(_this, {
83
96
  visible: observable,
84
97
  setVisible: action,
85
98
  playing: observable,
@@ -104,7 +117,7 @@ export var Controller = /*#__PURE__*/function (_Subscribe) {
104
117
  waitingForBgMusic: observable,
105
118
  setWaitingForBgMusic: action
106
119
  });
107
- reaction(function () {
120
+ _this.disposers.push(reaction(function () {
108
121
  return [_this.appearance.waveStyle, _this.loading];
109
122
  }, function (_ref2) {
110
123
  var _ref3 = _slicedToArray(_ref2, 2),
@@ -135,9 +148,9 @@ export var Controller = /*#__PURE__*/function (_Subscribe) {
135
148
  }
136
149
  }, {
137
150
  fireImmediately: true
138
- });
151
+ }));
139
152
  if (!_this.appSize) {
140
- reaction(function () {
153
+ _this.disposers.push(reaction(function () {
141
154
  return _this.containerSize;
142
155
  }, function (containerSize) {
143
156
  if (!(containerSize !== null && containerSize !== void 0 && containerSize.width)) return;
@@ -161,7 +174,7 @@ export var Controller = /*#__PURE__*/function (_Subscribe) {
161
174
  });
162
175
  }, {
163
176
  fireImmediately: true
164
- });
177
+ }));
165
178
  } else {
166
179
  setElementDataset(_this.container, {
167
180
  size: _this.appSize
@@ -169,20 +182,20 @@ export var Controller = /*#__PURE__*/function (_Subscribe) {
169
182
  }
170
183
 
171
184
  // 监听播放情况:抛出触发时机
172
- reaction(function () {
185
+ _this.disposers.push(reaction(function () {
173
186
  return _this.ended;
174
187
  }, function (ended) {
175
188
  if (ended) {
176
189
  _this.emit('paused', true);
177
190
  }
178
- });
179
- reaction(function () {
191
+ }));
192
+ _this.disposers.push(reaction(function () {
180
193
  return _this.playing;
181
194
  }, function (playing) {
182
195
  if (!_this.ended) {
183
196
  _this.emit(playing ? 'playing' : 'paused');
184
197
  }
185
- });
198
+ }));
186
199
  return _this;
187
200
  }
188
201
 
@@ -190,23 +203,17 @@ export var Controller = /*#__PURE__*/function (_Subscribe) {
190
203
  * 获取播放器是否准备就绪
191
204
  * @returns 是否有可用的视频代理场景
192
205
  */
193
- _createClass(Controller, [{
206
+ _inherits(Controller, _Subscribe);
207
+ return _createClass(Controller, [{
194
208
  key: "agentType",
195
209
  get:
196
- // null 表示加载失败
197
-
198
- /**
199
- * 是否正在等待背景音乐加载
200
- * 当此状态为 true 时,播放流程会暂停,等待音频加载完成
201
- */
202
-
203
210
  /**
204
211
  * 获取当前播放媒体的类型
205
212
  * @returns 'video' | 'avatar' | 'none' - 媒体类型
206
213
  */
207
214
  function get() {
208
- var _this$videoAgentScene, _this$avatar;
209
- var type = getMediaType((_this$videoAgentScene = this.videoAgentScene) === null || _this$videoAgentScene === void 0 ? void 0 : _this$videoAgentScene.videoAgentMesh.videoUrl);
215
+ var _this$videoAgentScene2, _this$avatar;
216
+ var type = getMediaType((_this$videoAgentScene2 = this.videoAgentScene) === null || _this$videoAgentScene2 === void 0 ? void 0 : _this$videoAgentScene2.videoAgentMesh.videoUrl);
210
217
  if ((_this$avatar = this.avatar) !== null && _this$avatar !== void 0 && _this$avatar.force) return 'avatar';
211
218
  if (type === 'video') return 'video';
212
219
  return 'none';
@@ -277,7 +284,9 @@ export var Controller = /*#__PURE__*/function (_Subscribe) {
277
284
  }, {
278
285
  key: "setPlaying",
279
286
  value: function setPlaying(playing) {
287
+ if (playing && !this.playback.active) return;
280
288
  this.playing = playing;
289
+ if (playing) this.resumeMedia();
281
290
  }
282
291
 
283
292
  /**
@@ -340,8 +349,8 @@ export var Controller = /*#__PURE__*/function (_Subscribe) {
340
349
  }, {
341
350
  key: "currentTime",
342
351
  get: function get() {
343
- var _this$videoAgentScene2;
344
- return ((_this$videoAgentScene2 = this.videoAgentScene) === null || _this$videoAgentScene2 === void 0 ? void 0 : _this$videoAgentScene2.videoAgentMesh.currentTime) || 0;
352
+ var _this$videoAgentScene3;
353
+ return ((_this$videoAgentScene3 = this.videoAgentScene) === null || _this$videoAgentScene3 === void 0 ? void 0 : _this$videoAgentScene3.videoAgentMesh.currentTime) || 0;
345
354
  }
346
355
 
347
356
  /**
@@ -375,8 +384,8 @@ export var Controller = /*#__PURE__*/function (_Subscribe) {
375
384
  }, {
376
385
  key: "mediaInstance",
377
386
  get: function get() {
378
- var _this$videoAgentScene3;
379
- return (_this$videoAgentScene3 = this.videoAgentScene) === null || _this$videoAgentScene3 === void 0 ? void 0 : _this$videoAgentScene3.videoAgentMesh.mediaInstance;
387
+ var _this$videoAgentScene4;
388
+ return (_this$videoAgentScene4 = this.videoAgentScene) === null || _this$videoAgentScene4 === void 0 ? void 0 : _this$videoAgentScene4.videoAgentMesh.mediaInstance;
380
389
  }
381
390
 
382
391
  /**
@@ -388,51 +397,75 @@ export var Controller = /*#__PURE__*/function (_Subscribe) {
388
397
  }, {
389
398
  key: "requestAnimationFrameLoop",
390
399
  value: function requestAnimationFrameLoop(callback) {
391
- var _this$mediaInstance3,
392
- _this$mediaInstance6,
400
+ var _this$mediaInstance2,
393
401
  _this3 = this;
394
402
  // 如果正在等待背景音乐加载,暂停整个播放流程
395
403
  if (this.waitingForBgMusic) {
396
404
  var _this$mediaInstance;
397
405
  if (!((_this$mediaInstance = this.mediaInstance) !== null && _this$mediaInstance !== void 0 && _this$mediaInstance.paused)) {
398
- var _this$mediaInstance2;
399
- (_this$mediaInstance2 = this.mediaInstance) === null || _this$mediaInstance2 === void 0 ? void 0 : _this$mediaInstance2.pause();
406
+ var _this$videoAgentScene5;
407
+ (_this$videoAgentScene5 = this.videoAgentScene) === null || _this$videoAgentScene5 === void 0 || (_this$videoAgentScene5 = _this$videoAgentScene5.videoAgentMesh.mediaOperations) === null || _this$videoAgentScene5 === void 0 || _this$videoAgentScene5.pause();
400
408
  }
401
409
  return;
402
410
  }
403
- if ((_this$mediaInstance3 = this.mediaInstance) !== null && _this$mediaInstance3 !== void 0 && _this$mediaInstance3.ended && this.mediaInstance.currentTime !== 0) {
404
- var _this$vreoUnit;
411
+ if ((_this$mediaInstance2 = this.mediaInstance) !== null && _this$mediaInstance2 !== void 0 && _this$mediaInstance2.ended && this.mediaInstance.currentTime !== 0) {
412
+ var _this$vreoUnit, _this$videoAgentScene6;
405
413
  if (this.ended) return;
406
- (_this$vreoUnit = this.vreoUnit) === null || _this$vreoUnit === void 0 ? void 0 : _this$vreoUnit.keyframes.forEach(function (keyframe) {
414
+ (_this$vreoUnit = this.vreoUnit) === null || _this$vreoUnit === void 0 || _this$vreoUnit.keyframes.forEach(function (keyframe) {
407
415
  return keyframe.parsed = false;
408
416
  });
417
+ var media = (_this$videoAgentScene6 = this.videoAgentScene) === null || _this$videoAgentScene6 === void 0 ? void 0 : _this$videoAgentScene6.videoAgentMesh.mediaOperations;
418
+ media === null || media === void 0 || media.pause();
419
+ if (media) media.currentTime = 0;
420
+ this.playback.finish();
409
421
  this.setEnded(true);
410
422
  this.setPlaying(false);
411
- this.mediaInstance.pause();
412
- this.mediaInstance.currentTime = 0;
413
423
  return;
414
424
  }
415
425
  if (!this.playing) {
416
- var _this$mediaInstance4;
417
- if (!((_this$mediaInstance4 = this.mediaInstance) !== null && _this$mediaInstance4 !== void 0 && _this$mediaInstance4.paused)) {
418
- var _this$mediaInstance5;
419
- (_this$mediaInstance5 = this.mediaInstance) === null || _this$mediaInstance5 === void 0 ? void 0 : _this$mediaInstance5.pause();
426
+ var _this$mediaInstance3;
427
+ if (!((_this$mediaInstance3 = this.mediaInstance) !== null && _this$mediaInstance3 !== void 0 && _this$mediaInstance3.paused)) {
428
+ var _this$videoAgentScene7;
429
+ (_this$videoAgentScene7 = this.videoAgentScene) === null || _this$videoAgentScene7 === void 0 || (_this$videoAgentScene7 = _this$videoAgentScene7.videoAgentMesh.mediaOperations) === null || _this$videoAgentScene7 === void 0 || _this$videoAgentScene7.pause();
420
430
  }
421
431
  return;
422
432
  }
423
- if ((_this$mediaInstance6 = this.mediaInstance) !== null && _this$mediaInstance6 !== void 0 && _this$mediaInstance6.paused && this.playing) {
424
- this.mediaInstance.play();
425
- }
433
+ this.resumeMedia();
426
434
  var currentKeyframes = this.currentKeyframes;
435
+ var run = this.playback.capture();
427
436
  currentKeyframes.forEach(function (keyframe) {
428
- if (keyframe.parsed) return;
437
+ if (!(run !== null && run !== void 0 && run.valid()) || keyframe.parsed) return;
429
438
  keyframe.parsed = true;
430
439
  _this3.emit(keyframe.type, keyframe, _this3.currentTime);
431
- if (callback) {
440
+ if (callback && run.valid()) {
432
441
  callback(keyframe.type, keyframe, _this3.currentTime);
433
442
  }
434
443
  });
435
444
  }
445
+ }, {
446
+ key: "resumeMedia",
447
+ value: function resumeMedia() {
448
+ var _this$mediaInstance4,
449
+ _this4 = this;
450
+ if (this.waitingForBgMusic) return;
451
+ if ((_this$mediaInstance4 = this.mediaInstance) !== null && _this$mediaInstance4 !== void 0 && _this$mediaInstance4.paused && this.playing && !this.resuming) {
452
+ var _this$videoAgentScene8;
453
+ var attempt = ++this.resumeGeneration;
454
+ this.resuming = attempt;
455
+ var run = this.playback.capture();
456
+ var valid = function valid() {
457
+ return !!(run !== null && run !== void 0 && run.valid());
458
+ };
459
+ void ((_this$videoAgentScene8 = this.videoAgentScene) === null || _this$videoAgentScene8 === void 0 ? void 0 : _this$videoAgentScene8.videoAgentMesh.play().catch(function (error) {
460
+ if (valid()) {
461
+ _this4.playback.cancel();
462
+ console.error(error);
463
+ }
464
+ }).finally(function () {
465
+ if (_this4.resuming === attempt) _this4.resuming = undefined;
466
+ }));
467
+ }
468
+ }
436
469
 
437
470
  /**
438
471
  * 开始运行播放器逻辑循环
@@ -443,10 +476,10 @@ export var Controller = /*#__PURE__*/function (_Subscribe) {
443
476
  }, {
444
477
  key: "run",
445
478
  value: function run(callback) {
446
- var _this4 = this;
479
+ var _this5 = this;
447
480
  if (this.stopInterval) return;
448
481
  this.stopInterval = requestAnimationFrameInterval(function () {
449
- return _this4.requestAnimationFrameLoop(callback);
482
+ return _this5.requestAnimationFrameLoop(callback);
450
483
  });
451
484
  }
452
485
 
@@ -460,7 +493,7 @@ export var Controller = /*#__PURE__*/function (_Subscribe) {
460
493
  value: function clear() {
461
494
  var _this$vreoUnit2, _this$stopInterval;
462
495
  this.setPlaying(false);
463
- (_this$vreoUnit2 = this.vreoUnit) === null || _this$vreoUnit2 === void 0 ? void 0 : _this$vreoUnit2.keyframes.forEach(function (keyframe) {
496
+ (_this$vreoUnit2 = this.vreoUnit) === null || _this$vreoUnit2 === void 0 || _this$vreoUnit2.keyframes.forEach(function (keyframe) {
464
497
  return keyframe.parsed = false;
465
498
  });
466
499
 
@@ -469,10 +502,11 @@ export var Controller = /*#__PURE__*/function (_Subscribe) {
469
502
  */
470
503
  this.vreoUnit = undefined;
471
504
  if (this.mediaInstance) {
472
- this.mediaInstance.pause();
473
- this.mediaInstance.currentTime = 0;
505
+ var _this$videoAgentScene9, _this$videoAgentScene0;
506
+ (_this$videoAgentScene9 = this.videoAgentScene) === null || _this$videoAgentScene9 === void 0 || (_this$videoAgentScene9 = _this$videoAgentScene9.videoAgentMesh.mediaOperations) === null || _this$videoAgentScene9 === void 0 || _this$videoAgentScene9.pause();
507
+ if ((_this$videoAgentScene0 = this.videoAgentScene) !== null && _this$videoAgentScene0 !== void 0 && _this$videoAgentScene0.videoAgentMesh.mediaOperations) this.videoAgentScene.videoAgentMesh.mediaOperations.currentTime = 0;
474
508
  }
475
- (_this$stopInterval = this.stopInterval) === null || _this$stopInterval === void 0 ? void 0 : _this$stopInterval.call(this);
509
+ (_this$stopInterval = this.stopInterval) === null || _this$stopInterval === void 0 || _this$stopInterval.call(this);
476
510
  this.stopInterval = undefined;
477
511
  }
478
512
 
@@ -484,10 +518,13 @@ export var Controller = /*#__PURE__*/function (_Subscribe) {
484
518
  }, {
485
519
  key: "dispose",
486
520
  value: function dispose() {
521
+ this.disposers.splice(0).forEach(function (dispose) {
522
+ return dispose();
523
+ });
524
+ this.playback.dispose();
487
525
  this.clear();
488
526
  }
489
527
  }]);
490
- return Controller;
491
528
  }(Subscribe);
492
529
  var ControllerContext = /*#__PURE__*/React.createContext(null);
493
530
  export { ControllerContext };
@@ -0,0 +1,25 @@
1
+ import type { MediaOperations, PlaybackManager, PlaybackSession } from './playback-types';
2
+ export interface PlaybackRun {
3
+ readonly session?: PlaybackSession;
4
+ readonly mediaManager?: PlaybackManager;
5
+ valid(): boolean;
6
+ bind(element: HTMLMediaElement): MediaOperations;
7
+ }
8
+ /** Local timeline lifetime only. Playback permission is owned by the injected manager. */
9
+ export declare class PlaybackLifecycle {
10
+ private onStop;
11
+ private controller?;
12
+ private run?;
13
+ private generation;
14
+ private disposed;
15
+ private members;
16
+ constructor(manager: PlaybackManager | undefined, onStop: () => void);
17
+ get active(): boolean;
18
+ capture(): PlaybackRun | undefined;
19
+ begin(userAction: boolean): boolean;
20
+ add(stop: () => void): () => void;
21
+ private stop;
22
+ cancel(): void;
23
+ finish(): void;
24
+ dispose(): void;
25
+ }
@@ -0,0 +1,117 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
5
+ /** Local timeline lifetime only. Playback permission is owned by the injected manager. */
6
+ export var PlaybackLifecycle = /*#__PURE__*/function () {
7
+ function PlaybackLifecycle(manager, onStop) {
8
+ var _this = this;
9
+ _classCallCheck(this, PlaybackLifecycle);
10
+ _defineProperty(this, "generation", 0);
11
+ _defineProperty(this, "disposed", false);
12
+ _defineProperty(this, "members", new Set());
13
+ this.onStop = onStop;
14
+ this.controller = manager === null || manager === void 0 ? void 0 : manager.createController({
15
+ label: 'vreo',
16
+ onCancel: function onCancel() {
17
+ return _this.stop();
18
+ }
19
+ });
20
+ }
21
+ return _createClass(PlaybackLifecycle, [{
22
+ key: "active",
23
+ get: function get() {
24
+ var _this$run;
25
+ return !!((_this$run = this.run) !== null && _this$run !== void 0 && _this$run.valid());
26
+ }
27
+ }, {
28
+ key: "capture",
29
+ value: function capture() {
30
+ return this.run;
31
+ }
32
+ }, {
33
+ key: "begin",
34
+ value: function begin(userAction) {
35
+ var _this$controller$begi,
36
+ _this$controller,
37
+ _this2 = this;
38
+ if (this.disposed) return false;
39
+ if (this.active) return true;
40
+ var session = (_this$controller$begi = (_this$controller = this.controller) === null || _this$controller === void 0 ? void 0 : _this$controller.begin({
41
+ userAction: userAction,
42
+ audible: true
43
+ })) !== null && _this$controller$begi !== void 0 ? _this$controller$begi : undefined;
44
+ if (this.controller && !session) return false;
45
+ var generation = ++this.generation;
46
+ var mediaManager = session === null || session === void 0 ? void 0 : session.mediaManager;
47
+ this.run = {
48
+ session: session,
49
+ mediaManager: mediaManager,
50
+ valid: function valid() {
51
+ return generation === _this2.generation && !_this2.disposed && !(session !== null && session !== void 0 && session.signal.aborted);
52
+ },
53
+ bind: function bind(element) {
54
+ return session ? session.bind(element) : element;
55
+ }
56
+ };
57
+ return true;
58
+ }
59
+ }, {
60
+ key: "add",
61
+ value: function add(stop) {
62
+ var _this3 = this;
63
+ this.members.add(stop);
64
+ return function () {
65
+ _this3.members.delete(stop);
66
+ };
67
+ }
68
+ }, {
69
+ key: "stop",
70
+ value: function stop() {
71
+ ++this.generation;
72
+ this.run = undefined;
73
+ var errors = [];
74
+ try {
75
+ this.onStop();
76
+ } catch (error) {
77
+ errors.push(error);
78
+ }
79
+ for (var _i = 0, _arr = _toConsumableArray(this.members); _i < _arr.length; _i++) {
80
+ var _stop = _arr[_i];
81
+ try {
82
+ _stop();
83
+ } catch (error) {
84
+ errors.push(error);
85
+ }
86
+ }
87
+ if (errors.length) throw errors[0];
88
+ }
89
+ }, {
90
+ key: "cancel",
91
+ value: function cancel() {
92
+ var _this$controller2;
93
+ var generation = this.generation;
94
+ (_this$controller2 = this.controller) === null || _this$controller2 === void 0 || _this$controller2.cancel();
95
+ if (generation === this.generation) this.stop();
96
+ }
97
+ }, {
98
+ key: "finish",
99
+ value: function finish() {
100
+ var _this$run2;
101
+ var session = (_this$run2 = this.run) === null || _this$run2 === void 0 ? void 0 : _this$run2.session;
102
+ this.stop();
103
+ session === null || session === void 0 || session.finish();
104
+ }
105
+ }, {
106
+ key: "dispose",
107
+ value: function dispose() {
108
+ var _this$controller3;
109
+ if (this.disposed) return;
110
+ this.disposed = true;
111
+ var generation = this.generation;
112
+ (_this$controller3 = this.controller) === null || _this$controller3 === void 0 || _this$controller3.dispose();
113
+ if (generation === this.generation) this.stop();
114
+ this.members.clear();
115
+ }
116
+ }]);
117
+ }();
@@ -4,7 +4,30 @@ import { createRoot } from 'react-dom/client';
4
4
  import { Raycaster, Vector3 } from 'three';
5
5
  import { tweenProgress } from "../../../shared-utils/animationFrame/BetterTween.js";
6
6
  import { CSS3DRenderPlugin } from "../../../fivePlugins/CSS3DRenderPlugin/index.js";
7
- import { VreoKeyframeEnum } from "../../../typings/VreoUnit.js";
7
+ import { VreoKeyframeEnum } from "../../../typings/VreoUnit.js"; // __debug__
8
+ // const mockData: SpatialScenePanelData = {
9
+ // customType: 'SpatialScenePanel',
10
+ // "stateList": [
11
+ // {
12
+ // "icon": "http://vrlab-public.ljcdn.com/release/seesay/tools/___fc42f951076607a22fd5c54f005ba553.png",
13
+ // "text": "窗帘关闭"
14
+ // },
15
+ // {
16
+ // "icon": "http://vrlab-public.ljcdn.com/release/seesay/tools/___b331e7ad732debc07250a169a3393b13.png",
17
+ // "text": "摄像头休眠"
18
+ // },
19
+ // {
20
+ // "icon": "http://vrlab-public.ljcdn.com/release/seesay/tools/___2e425a81ac0ad88232d50d4e52a9abfa.png",
21
+ // "text": "氛围音乐"
22
+ // },
23
+ // {
24
+ // "icon": "http://vrlab-public.ljcdn.com/release/seesay/tools/___bff48bb81cde37aa6a319d6f5d56e3a4.png",
25
+ // "text": "空调打开"
26
+ // }
27
+ // ],
28
+ // "temperature": "27",
29
+ // "title": "沉浸式回家"
30
+ // }
8
31
  // const getSphere = (position: Vector3, color = 0xffff00) => {
9
32
  // const geometry = new SphereGeometry(0.05, 32, 16)
10
33
  // const material = new MeshBasicMaterial({ color })
@@ -95,7 +118,7 @@ export function SpatialScenePanel(props) {
95
118
  });
96
119
  if (!container) return;
97
120
  var root = createRoot(container);
98
- root.render( /*#__PURE__*/React.createElement(Panel, {
121
+ root.render(/*#__PURE__*/React.createElement(Panel, {
99
122
  ref: function ref(_ref3) {
100
123
  return panelRef.current = _ref3;
101
124
  },
@@ -107,15 +130,15 @@ export function SpatialScenePanel(props) {
107
130
  var progress = _ref4.progress;
108
131
  var needRotateY = Math.PI / 90 * 11 * progress;
109
132
  var rotateY = needRotateY - lastRotateY;
110
- css3DObject === null || css3DObject === void 0 ? void 0 : css3DObject.rotateY(rotateY);
133
+ css3DObject === null || css3DObject === void 0 || css3DObject.rotateY(rotateY);
111
134
  // css3DObject?.rotateZ
112
135
  lastRotateY = needRotateY;
113
136
  }).onStart(function () {
114
- css3DObject === null || css3DObject === void 0 ? void 0 : css3DObject.rotateY(startRotateY);
137
+ css3DObject === null || css3DObject === void 0 || css3DObject.rotateY(startRotateY);
115
138
  render();
116
139
  }).onDispose(function () {
117
140
  var _panelRef$current;
118
- (_panelRef$current = panelRef.current) === null || _panelRef$current === void 0 ? void 0 : _panelRef$current.classList.add('show');
141
+ (_panelRef$current = panelRef.current) === null || _panelRef$current === void 0 || _panelRef$current.classList.add('show');
119
142
  }).play();
120
143
 
121
144
  // Object.assign(window, { $dispose: () => {
@@ -127,9 +150,9 @@ export function SpatialScenePanel(props) {
127
150
  end = keyframe.end;
128
151
  timeoutRef.current = setTimeout(function () {
129
152
  var _panelRef$current2;
130
- (_panelRef$current2 = panelRef.current) === null || _panelRef$current2 === void 0 ? void 0 : _panelRef$current2.classList.add('hide');
153
+ (_panelRef$current2 = panelRef.current) === null || _panelRef$current2 === void 0 || _panelRef$current2.classList.add('hide');
131
154
  timeoutRef.current = setTimeout(function () {
132
- dispose === null || dispose === void 0 ? void 0 : dispose();
155
+ dispose === null || dispose === void 0 || dispose();
133
156
  timeoutRef.current = null;
134
157
  }, 1500);
135
158
  }, end - start);
@@ -161,10 +184,10 @@ function SpatialScenePanelBg() {
161
184
  if (!ref.current) return;
162
185
  var listener = function listener() {
163
186
  var _ref$current;
164
- (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.setAttribute('class', 'SpatialScenePanel-bg');
187
+ (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.setAttribute('class', 'SpatialScenePanel-bg');
165
188
  timeoutRef.current = setTimeout(function () {
166
189
  var _ref$current2;
167
- (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.setAttribute('class', 'SpatialScenePanel-bg SpatialScenePanel-bg--animation');
190
+ (_ref$current2 = ref.current) === null || _ref$current2 === void 0 || _ref$current2.setAttribute('class', 'SpatialScenePanel-bg SpatialScenePanel-bg--animation');
168
191
  timeoutRef.current = null;
169
192
  }, 3000);
170
193
  };
@@ -180,7 +203,7 @@ function SpatialScenePanelBg() {
180
203
  });
181
204
  }
182
205
  var Panel = /*#__PURE__*/React.forwardRef(function (props, myRef) {
183
- var _props$data, _props$data2, _props$data3, _props$data3$stateLis;
206
+ var _props$data, _props$data2, _props$data3;
184
207
  return /*#__PURE__*/React.createElement("div", {
185
208
  className: "SpatialScenePanel",
186
209
  ref: myRef
@@ -194,7 +217,7 @@ var Panel = /*#__PURE__*/React.forwardRef(function (props, myRef) {
194
217
  className: "SpatialScenePanel-temperature"
195
218
  }, (_props$data2 = props.data) === null || _props$data2 === void 0 ? void 0 : _props$data2.temperature, "\u2103")), /*#__PURE__*/React.createElement("div", {
196
219
  className: "SpatialScenePanel-body"
197
- }, (_props$data3 = props.data) === null || _props$data3 === void 0 ? void 0 : (_props$data3$stateLis = _props$data3.stateList) === null || _props$data3$stateLis === void 0 ? void 0 : _props$data3$stateLis.map(function (state, index) {
220
+ }, (_props$data3 = props.data) === null || _props$data3 === void 0 || (_props$data3 = _props$data3.stateList) === null || _props$data3 === void 0 ? void 0 : _props$data3.map(function (state, index) {
198
221
  return /*#__PURE__*/React.createElement("div", {
199
222
  key: "scene-".concat(state.text),
200
223
  className: "SpatialScenePanel-item index_".concat(index)
@@ -29,6 +29,11 @@ export declare class Player extends Subscribe<VreoKeyframeEvent> {
29
29
  $five: Five;
30
30
  /** 内部控制器 */
31
31
  private controller;
32
+ private root;
33
+ private disposers;
34
+ private loadGeneration;
35
+ private disposed;
36
+ getMediaManager(): import("./playback-types").PlaybackManager | undefined;
32
37
  /** 播放器配置(只读) */
33
38
  configs: Readonly<PlayerConfigs>;
34
39
  /**
@@ -61,7 +66,7 @@ export declare class Player extends Subscribe<VreoKeyframeEvent> {
61
66
  * await player.load(vreoUnit, 0, false, true)
62
67
  * ```
63
68
  */
64
- load(vreoUnit: VreoUnit, currentTime?: number, preload?: boolean, force?: boolean): Promise<boolean>;
69
+ load(vreoUnit: VreoUnit, currentTime?: number, preload?: boolean, force?: boolean, userAction?: boolean): Promise<boolean>;
65
70
  /**
66
71
  * 获取播放器是否处于暂停状态
67
72
  * @returns 是否暂停中
@@ -82,7 +87,7 @@ export declare class Player extends Subscribe<VreoKeyframeEvent> {
82
87
  * player.play(10000) // 从10秒处开始
83
88
  * ```
84
89
  */
85
- play(currentTime?: number): boolean;
90
+ play(currentTime?: number, userAction?: boolean): boolean;
86
91
  /**
87
92
  * 设置播放器外观
88
93
  * @param appearance - 外观配置对象