@realsee/vreo 2.6.4-alpha.5 → 3.0.0-webgpu-react18.8

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 (174) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +6 -6
  3. package/lib/PlayController/createHTMLAudioElement.d.ts +1 -0
  4. package/lib/PlayController/createHTMLAudioElement.d.ts.map +1 -0
  5. package/lib/PlayController/index.d.ts +14 -24
  6. package/lib/PlayController/index.d.ts.map +1 -0
  7. package/lib/PlayController/index.js +74 -210
  8. package/lib/PlayController/index.js.map +1 -0
  9. package/lib/Player/App.d.ts +2 -2
  10. package/lib/Player/App.d.ts.map +1 -0
  11. package/lib/Player/Controller.d.ts +11 -6
  12. package/lib/Player/Controller.d.ts.map +1 -0
  13. package/lib/Player/PlaybackLifecycle.d.ts +1 -0
  14. package/lib/Player/PlaybackLifecycle.d.ts.map +1 -0
  15. package/lib/Player/custom/SpatialScenePanel/index.d.ts +2 -2
  16. package/lib/Player/custom/SpatialScenePanel/index.d.ts.map +1 -0
  17. package/lib/Player/hooks.d.ts +3 -2
  18. package/lib/Player/hooks.d.ts.map +1 -0
  19. package/lib/Player/index.d.ts +3 -2
  20. package/lib/Player/index.d.ts.map +1 -0
  21. package/lib/Player/index.js +1769 -430
  22. package/lib/Player/index.js.map +1 -0
  23. package/lib/Player/modules/Drawer/index.d.ts +2 -2
  24. package/lib/Player/modules/Drawer/index.d.ts.map +1 -0
  25. package/lib/Player/modules/PopUp/index.d.ts +2 -2
  26. package/lib/Player/modules/PopUp/index.d.ts.map +1 -0
  27. package/lib/Player/modules/ResizeObserver/index.d.ts +2 -2
  28. package/lib/Player/modules/ResizeObserver/index.d.ts.map +1 -0
  29. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +5 -2
  30. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts.map +1 -0
  31. package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts +8 -5
  32. package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts.map +1 -0
  33. package/lib/Player/modules/VideoAgent/index.d.ts +11 -2
  34. package/lib/Player/modules/VideoAgent/index.d.ts.map +1 -0
  35. package/lib/Player/modules/Wave/index.d.ts +2 -2
  36. package/lib/Player/modules/Wave/index.d.ts.map +1 -0
  37. package/lib/Player/modules/keyframes/BgMusic/index.d.ts +2 -2
  38. package/lib/Player/modules/keyframes/BgMusic/index.d.ts.map +1 -0
  39. package/lib/Player/modules/keyframes/CameraMovement/index.d.ts +2 -2
  40. package/lib/Player/modules/keyframes/CameraMovement/index.d.ts.map +1 -0
  41. package/lib/Player/modules/keyframes/InfoPanel/index.d.ts +2 -2
  42. package/lib/Player/modules/keyframes/InfoPanel/index.d.ts.map +1 -0
  43. package/lib/Player/modules/keyframes/ModelVideo/index.d.ts +2 -2
  44. package/lib/Player/modules/keyframes/ModelVideo/index.d.ts.map +1 -0
  45. package/lib/Player/modules/keyframes/PanoEffect/index.d.ts +2 -2
  46. package/lib/Player/modules/keyframes/PanoEffect/index.d.ts.map +1 -0
  47. package/lib/Player/modules/keyframes/PanoEffect/lineAnime.d.ts +3 -2
  48. package/lib/Player/modules/keyframes/PanoEffect/lineAnime.d.ts.map +1 -0
  49. package/lib/Player/modules/keyframes/PanoTag/index.d.ts +1 -0
  50. package/lib/Player/modules/keyframes/PanoTag/index.d.ts.map +1 -0
  51. package/lib/Player/modules/keyframes/PanoTextLabel/index.d.ts +2 -2
  52. package/lib/Player/modules/keyframes/PanoTextLabel/index.d.ts.map +1 -0
  53. package/lib/Player/modules/keyframes/Prompter/index.d.ts +2 -2
  54. package/lib/Player/modules/keyframes/Prompter/index.d.ts.map +1 -0
  55. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.d.ts +2 -2
  56. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.d.ts.map +1 -0
  57. package/lib/Player/modules/keyframes/VideoEffect/index.d.ts +2 -2
  58. package/lib/Player/modules/keyframes/VideoEffect/index.d.ts.map +1 -0
  59. package/lib/Player/playback-types.d.ts +1 -0
  60. package/lib/Player/playback-types.d.ts.map +1 -0
  61. package/lib/Player/typings.d.ts +2 -1
  62. package/lib/Player/typings.d.ts.map +1 -0
  63. package/lib/chunks/index-BgPSzRSs.js +93 -0
  64. package/lib/chunks/index-BgPSzRSs.js.map +1 -0
  65. package/lib/chunks/index-CunyJn6H.js +51 -0
  66. package/lib/chunks/index-CunyJn6H.js.map +1 -0
  67. package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.d.ts +2 -1
  68. package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.d.ts.map +1 -0
  69. package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.d.ts +5 -6
  70. package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.d.ts.map +1 -0
  71. package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.d.ts +1 -0
  72. package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.d.ts.map +1 -0
  73. package/lib/fivePlugins/CSS3DRenderPlugin/index.d.ts +5 -22
  74. package/lib/fivePlugins/CSS3DRenderPlugin/index.d.ts.map +1 -0
  75. package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.d.ts +2 -1
  76. package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.d.ts.map +1 -0
  77. package/lib/fivePlugins/CameraMovementPlugin/index.d.ts +2 -1
  78. package/lib/fivePlugins/CameraMovementPlugin/index.d.ts.map +1 -0
  79. package/lib/fivePlugins/CameraMovementPlugin/typings.d.ts +2 -1
  80. package/lib/fivePlugins/CameraMovementPlugin/typings.d.ts.map +1 -0
  81. package/lib/fivePlugins/ModelTVVideoPlugin/index.d.ts +2 -1
  82. package/lib/fivePlugins/ModelTVVideoPlugin/index.d.ts.map +1 -0
  83. package/lib/index.d.ts +3 -0
  84. package/lib/index.d.ts.map +1 -0
  85. package/lib/index.js +12 -1
  86. package/lib/index.js.map +1 -0
  87. package/lib/plugins/CSS3DRenderPlugin.js +115 -0
  88. package/lib/plugins/CSS3DRenderPlugin.js.map +1 -0
  89. package/lib/plugins/CameraMovementPlugin.js +6 -0
  90. package/lib/plugins/CameraMovementPlugin.js.map +1 -0
  91. package/lib/plugins/ModelTVVideoPlugin.js +162 -0
  92. package/lib/plugins/ModelTVVideoPlugin.js.map +1 -0
  93. package/lib/react/index.d.ts +5 -4
  94. package/lib/react/index.d.ts.map +1 -0
  95. package/lib/react/index.js +39 -226
  96. package/lib/react/index.js.map +1 -0
  97. package/lib/shared-utils/Audio.d.ts +3 -1
  98. package/lib/shared-utils/Audio.d.ts.map +1 -0
  99. package/lib/shared-utils/AudioLike.d.ts +2 -1
  100. package/lib/shared-utils/AudioLike.d.ts.map +1 -0
  101. package/lib/shared-utils/Preloader.d.ts +1 -0
  102. package/lib/shared-utils/Preloader.d.ts.map +1 -0
  103. package/lib/shared-utils/addResizeListener.d.ts +2 -1
  104. package/lib/shared-utils/addResizeListener.d.ts.map +1 -0
  105. package/lib/shared-utils/animationFrame/BetterTween.d.ts +1 -0
  106. package/lib/shared-utils/animationFrame/BetterTween.d.ts.map +1 -0
  107. package/lib/shared-utils/animationFrame/index.d.ts +5 -14
  108. package/lib/shared-utils/animationFrame/index.d.ts.map +1 -0
  109. package/lib/shared-utils/animationFrame/tween.d.ts +1 -0
  110. package/lib/shared-utils/animationFrame/tween.d.ts.map +1 -0
  111. package/lib/shared-utils/createTransMatrix.d.ts +3 -1
  112. package/lib/shared-utils/createTransMatrix.d.ts.map +1 -0
  113. package/lib/shared-utils/getFileExpandedName.d.ts +1 -0
  114. package/lib/shared-utils/getFileExpandedName.d.ts.map +1 -0
  115. package/lib/shared-utils/getMediaInfo.d.ts +1 -0
  116. package/lib/shared-utils/getMediaInfo.d.ts.map +1 -0
  117. package/lib/shared-utils/setElementDataset.d.ts +1 -0
  118. package/lib/shared-utils/setElementDataset.d.ts.map +1 -0
  119. package/lib/timeline/index.d.ts +18 -0
  120. package/lib/timeline/index.d.ts.map +1 -0
  121. package/lib/types/index.js +10 -0
  122. package/lib/types/index.js.map +1 -0
  123. package/lib/typings/VreoUnit.d.ts +2 -1
  124. package/lib/typings/VreoUnit.d.ts.map +1 -0
  125. package/lib/typings/index.d.ts +1 -0
  126. package/lib/typings/index.d.ts.map +1 -0
  127. package/package.json +51 -71
  128. package/lib/PlayController/createHTMLAudioElement.js +0 -30
  129. package/lib/Player/App.js +0 -52
  130. package/lib/Player/Controller.js +0 -530
  131. package/lib/Player/PlaybackLifecycle.js +0 -117
  132. package/lib/Player/custom/SpatialScenePanel/index.js +0 -263
  133. package/lib/Player/hooks.js +0 -22
  134. package/lib/Player/modules/Drawer/index.js +0 -39
  135. package/lib/Player/modules/PopUp/index.js +0 -23
  136. package/lib/Player/modules/ResizeObserver/index.js +0 -22
  137. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +0 -445
  138. package/lib/Player/modules/VideoAgent/VideoAgentScene.js +0 -53
  139. package/lib/Player/modules/VideoAgent/index.js +0 -72
  140. package/lib/Player/modules/Wave/index.js +0 -171
  141. package/lib/Player/modules/keyframes/BgMusic/index.js +0 -65
  142. package/lib/Player/modules/keyframes/CameraMovement/index.js +0 -73
  143. package/lib/Player/modules/keyframes/InfoPanel/index.js +0 -170
  144. package/lib/Player/modules/keyframes/ModelVideo/index.js +0 -126
  145. package/lib/Player/modules/keyframes/PanoEffect/index.js +0 -99
  146. package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +0 -30
  147. package/lib/Player/modules/keyframes/PanoTag/index.js +0 -110
  148. package/lib/Player/modules/keyframes/PanoTextLabel/index.js +0 -122
  149. package/lib/Player/modules/keyframes/Prompter/index.js +0 -56
  150. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +0 -98
  151. package/lib/Player/modules/keyframes/VideoEffect/index.js +0 -152
  152. package/lib/Player/playback-types.js +0 -1
  153. package/lib/Player/typings.js +0 -1
  154. package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +0 -4
  155. package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +0 -25
  156. package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +0 -4
  157. package/lib/fivePlugins/CSS3DRenderPlugin/index.js +0 -226
  158. package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +0 -8
  159. package/lib/fivePlugins/CameraMovementPlugin/index.js +0 -238
  160. package/lib/fivePlugins/CameraMovementPlugin/typings.js +0 -15
  161. package/lib/fivePlugins/ModelTVVideoPlugin/index.js +0 -347
  162. package/lib/shared-utils/Audio.js +0 -147
  163. package/lib/shared-utils/AudioLike.js +0 -120
  164. package/lib/shared-utils/Preloader.js +0 -37
  165. package/lib/shared-utils/addResizeListener.js +0 -39
  166. package/lib/shared-utils/animationFrame/BetterTween.js +0 -56
  167. package/lib/shared-utils/animationFrame/index.js +0 -52
  168. package/lib/shared-utils/animationFrame/tween.js +0 -56
  169. package/lib/shared-utils/createTransMatrix.js +0 -12
  170. package/lib/shared-utils/getFileExpandedName.js +0 -6
  171. package/lib/shared-utils/getMediaInfo.js +0 -54
  172. package/lib/shared-utils/setElementDataset.js +0 -16
  173. package/lib/typings/VreoUnit.js +0 -171
  174. package/lib/typings/index.js +0 -1
@@ -1,530 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
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";
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
- import { Subscribe } from '@realsee/five';
14
- import { action, makeObservable, observable, reaction } from 'mobx';
15
- import * as React from 'react';
16
- import { requestAnimationFrameInterval } from "../shared-utils/animationFrame/index.js";
17
- import { VreoKeyframeEnum } from "../typings/VreoUnit.js";
18
- import setElementDataset from "../shared-utils/setElementDataset.js";
19
- import { getMediaType } from "../shared-utils/getMediaInfo.js";
20
- /**
21
- * Vreo 播放器逻辑控制器
22
- *
23
- * 负责管理播放器的内部状态、事件处理、UI 控制和剧本执行。
24
- * 提供播放控制、外观设置、弹窗管理、抽屉控制等功能。
25
- *
26
- * @example
27
- * ```typescript
28
- * const controller = new Controller({
29
- * five: fiveInstance,
30
- * container: document.getElementById('container'),
31
- * configs: playerConfigs
32
- * })
33
- *
34
- * // 设置播放状态
35
- * controller.setPlaying(true)
36
- *
37
- * // 打开弹窗
38
- * controller.openPopUp('弹窗内容')
39
- *
40
- * // 打开抽屉
41
- * controller.openDrawer({ content: '抽屉内容', height: 300 })
42
- * ```
43
- */
44
- export var Controller = /*#__PURE__*/function (_Subscribe) {
45
- function Controller(_ref) {
46
- var _this;
47
- var five = _ref.five,
48
- container = _ref.container,
49
- configs = _ref.configs;
50
- _classCallCheck(this, Controller);
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", {
57
- width: 0,
58
- height: 0
59
- });
60
- _defineProperty(_this, "waveAppearance", null);
61
- _defineProperty(_this, "appearance", {
62
- waveStyle: 'wave'
63
- });
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
- });
90
- _this.configs = configs;
91
- _this.container = container;
92
- _this.five = five;
93
- _this.appSize = configs.appSize;
94
- _this.appearance = _objectSpread(_objectSpread({}, _this.appearance), configs.appearance);
95
- makeObservable(_this, {
96
- visible: observable,
97
- setVisible: action,
98
- playing: observable,
99
- setPlaying: action,
100
- loading: observable,
101
- // videoAgentScene: observable.ref,
102
- setLoading: action,
103
- popUp: observable.ref,
104
- openPopUp: action,
105
- drawerConfig: observable.ref,
106
- openDrawer: action,
107
- ended: observable,
108
- waveAppearance: observable,
109
- avatar: observable,
110
- containerSize: observable,
111
- setContainerSize: action,
112
- appearance: observable,
113
- setAppearance: action,
114
- configs: observable.ref,
115
- setEnded: action,
116
- setAvatar: action,
117
- waitingForBgMusic: observable,
118
- setWaitingForBgMusic: action
119
- });
120
- _this.disposers.push(reaction(function () {
121
- return [_this.appearance.waveStyle, _this.loading];
122
- }, function (_ref2) {
123
- var _ref3 = _slicedToArray(_ref2, 2),
124
- waveStyle = _ref3[0],
125
- loading = _ref3[1];
126
- if (loading === null) {
127
- _this.waveAppearance = null;
128
- return;
129
- }
130
- if (waveStyle === 'wave') {
131
- switch (loading) {
132
- case true:
133
- _this.waveAppearance = 'double';
134
- break;
135
- case false:
136
- _this.waveAppearance = 'solid';
137
- break;
138
- }
139
- } else if (waveStyle === 'solid') {
140
- switch (loading) {
141
- case true:
142
- _this.waveAppearance = 'swap';
143
- break;
144
- case false:
145
- _this.waveAppearance = 'expand';
146
- break;
147
- }
148
- }
149
- }, {
150
- fireImmediately: true
151
- }));
152
- if (!_this.appSize) {
153
- _this.disposers.push(reaction(function () {
154
- return _this.containerSize;
155
- }, function (containerSize) {
156
- if (!(containerSize !== null && containerSize !== void 0 && containerSize.width)) return;
157
- var width = containerSize.width;
158
- var height = containerSize.height;
159
- var size = function () {
160
- if (width <= 500) return 'S';
161
- if (width <= 1024) return 'M';
162
- if (width <= 2048) return 'L';
163
- return 'XL';
164
- }();
165
- var orientation = function () {
166
- if (height > width) return 'portrait';
167
- return 'landscape';
168
- }();
169
- setElementDataset(_this.container, {
170
- size: size
171
- });
172
- setElementDataset(_this.container, {
173
- orientation: orientation
174
- });
175
- }, {
176
- fireImmediately: true
177
- }));
178
- } else {
179
- setElementDataset(_this.container, {
180
- size: _this.appSize
181
- });
182
- }
183
-
184
- // 监听播放情况:抛出触发时机
185
- _this.disposers.push(reaction(function () {
186
- return _this.ended;
187
- }, function (ended) {
188
- if (ended) {
189
- _this.emit('paused', true);
190
- }
191
- }));
192
- _this.disposers.push(reaction(function () {
193
- return _this.playing;
194
- }, function (playing) {
195
- if (!_this.ended) {
196
- _this.emit(playing ? 'playing' : 'paused');
197
- }
198
- }));
199
- return _this;
200
- }
201
-
202
- /**
203
- * 获取播放器是否准备就绪
204
- * @returns 是否有可用的视频代理场景
205
- */
206
- _inherits(Controller, _Subscribe);
207
- return _createClass(Controller, [{
208
- key: "agentType",
209
- get:
210
- /**
211
- * 获取当前播放媒体的类型
212
- * @returns 'video' | 'avatar' | 'none' - 媒体类型
213
- */
214
- function get() {
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);
217
- if ((_this$avatar = this.avatar) !== null && _this$avatar !== void 0 && _this$avatar.force) return 'avatar';
218
- if (type === 'video') return 'video';
219
- return 'none';
220
- }
221
- }, {
222
- key: "openPopUp",
223
- value:
224
- /**
225
- * 打开或关闭弹窗
226
- * @param popUp - 弹窗内容,可以是字符串、JSX元素或false(关闭弹窗)
227
- */
228
- function openPopUp(popUp) {
229
- if (!popUp) {
230
- this.popUp = null;
231
- return;
232
- }
233
- this.popUp = popUp;
234
- }
235
-
236
- /**
237
- * 设置加载状态
238
- * @param loading - 加载状态:true(加载中)、false(加载完成)、null(加载失败)
239
- */
240
- }, {
241
- key: "setLoading",
242
- value: function setLoading(loading) {
243
- this.loading = loading;
244
- }
245
- }, {
246
- key: "setAvatar",
247
- value:
248
- /**
249
- * 设置虚拟形象配置
250
- * @param avatar - 虚拟形象配置对象
251
- */
252
- function setAvatar(avatar) {
253
- this.avatar = avatar;
254
- }
255
-
256
- /**
257
- * 设置容器尺寸
258
- * @param width - 容器宽度
259
- * @param height - 容器高度
260
- */
261
- }, {
262
- key: "setContainerSize",
263
- value: function setContainerSize(width, height) {
264
- this.containerSize = {
265
- width: width,
266
- height: height
267
- };
268
- }
269
-
270
- /**
271
- * 设置播放器可见性
272
- * @param v - 是否可见
273
- */
274
- }, {
275
- key: "setVisible",
276
- value: function setVisible(v) {
277
- this.visible = v;
278
- }
279
-
280
- /**
281
- * 设置播放状态
282
- * @param playing - 是否正在播放
283
- */
284
- }, {
285
- key: "setPlaying",
286
- value: function setPlaying(playing) {
287
- if (playing && !this.playback.active) return;
288
- this.playing = playing;
289
- if (playing) this.resumeMedia();
290
- }
291
-
292
- /**
293
- * 设置结束状态
294
- * @param ended - 是否已结束
295
- */
296
- }, {
297
- key: "setEnded",
298
- value: function setEnded(ended) {
299
- this.ended = ended;
300
- }
301
-
302
- /**
303
- * 设置是否正在等待背景音乐加载
304
- * @param waiting - 是否正在等待
305
- */
306
- }, {
307
- key: "setWaitingForBgMusic",
308
- value: function setWaitingForBgMusic(waiting) {
309
- this.waitingForBgMusic = waiting;
310
- }
311
-
312
- /**
313
- * 设置播放器外观
314
- * @param appearance - 外观配置对象
315
- */
316
- }, {
317
- key: "setAppearance",
318
- value: function setAppearance(appearance) {
319
- this.appearance = _objectSpread(_objectSpread({}, this.appearance), appearance);
320
- }
321
-
322
- /**
323
- * 打开或关闭抽屉
324
- * @param drawerConfig - 抽屉配置对象,false表示关闭抽屉
325
- */
326
- }, {
327
- key: "openDrawer",
328
- value: function openDrawer(drawerConfig) {
329
- if (!drawerConfig) {
330
- var _this$drawerConfig;
331
- this.drawerConfig = {
332
- content: '',
333
- height: (_this$drawerConfig = this.drawerConfig) === null || _this$drawerConfig === void 0 ? void 0 : _this$drawerConfig.height
334
- };
335
- return;
336
- }
337
- this.drawerConfig = drawerConfig;
338
- }
339
- }, {
340
- key: "ready",
341
- get: function get() {
342
- return !!this.videoAgentScene;
343
- }
344
-
345
- /**
346
- * 获取当前播放时间(毫秒)
347
- * @returns 当前播放时间戳
348
- */
349
- }, {
350
- key: "currentTime",
351
- get: function get() {
352
- var _this$videoAgentScene3;
353
- return ((_this$videoAgentScene3 = this.videoAgentScene) === null || _this$videoAgentScene3 === void 0 ? void 0 : _this$videoAgentScene3.videoAgentMesh.currentTime) || 0;
354
- }
355
-
356
- /**
357
- * 获取当前时间点应该触发的关键帧
358
- * @returns 当前应该执行的关键帧数组
359
- */
360
- }, {
361
- key: "currentKeyframes",
362
- get: function get() {
363
- var _this2 = this;
364
- if (!this.vreoUnit) return [];
365
- var keyframes = this.vreoUnit.keyframes;
366
- // 没有被解析过且开始时间低于当前时间戳 100ms
367
- return keyframes.filter(function (keyframe) {
368
- if (keyframe.parsed) return false;
369
- // 检测结束时间
370
- if (keyframe.end < _this2.currentTime) return false;
371
- // 检测开始时间
372
- if (keyframe.start > _this2.currentTime) return false;
373
- if (keyframe.type === VreoKeyframeEnum.BgMusic) return true;
374
- // 开始时间低于当前时间戳 100ms
375
- var dur = _this2.currentTime - keyframe.start;
376
- return dur <= 100 && dur >= 0;
377
- });
378
- }
379
-
380
- /**
381
- * 获取当前媒体实例(音频或视频元素)
382
- * @returns HTML媒体元素实例
383
- */
384
- }, {
385
- key: "mediaInstance",
386
- get: function get() {
387
- var _this$videoAgentScene4;
388
- return (_this$videoAgentScene4 = this.videoAgentScene) === null || _this$videoAgentScene4 === void 0 ? void 0 : _this$videoAgentScene4.videoAgentMesh.mediaInstance;
389
- }
390
-
391
- /**
392
- * 逐帧任务循环处理
393
- *
394
- * 在每个动画帧中检查播放状态、处理关键帧触发等
395
- * @param callback - 关键帧触发时的回调函数
396
- */
397
- }, {
398
- key: "requestAnimationFrameLoop",
399
- value: function requestAnimationFrameLoop(callback) {
400
- var _this$mediaInstance2,
401
- _this3 = this;
402
- // 如果正在等待背景音乐加载,暂停整个播放流程
403
- if (this.waitingForBgMusic) {
404
- var _this$mediaInstance;
405
- if (!((_this$mediaInstance = this.mediaInstance) !== null && _this$mediaInstance !== void 0 && _this$mediaInstance.paused)) {
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();
408
- }
409
- return;
410
- }
411
- if ((_this$mediaInstance2 = this.mediaInstance) !== null && _this$mediaInstance2 !== void 0 && _this$mediaInstance2.ended && this.mediaInstance.currentTime !== 0) {
412
- var _this$vreoUnit, _this$videoAgentScene6;
413
- if (this.ended) return;
414
- (_this$vreoUnit = this.vreoUnit) === null || _this$vreoUnit === void 0 || _this$vreoUnit.keyframes.forEach(function (keyframe) {
415
- return keyframe.parsed = false;
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();
421
- this.setEnded(true);
422
- this.setPlaying(false);
423
- return;
424
- }
425
- if (!this.playing) {
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();
430
- }
431
- return;
432
- }
433
- this.resumeMedia();
434
- var currentKeyframes = this.currentKeyframes;
435
- var run = this.playback.capture();
436
- currentKeyframes.forEach(function (keyframe) {
437
- if (!(run !== null && run !== void 0 && run.valid()) || keyframe.parsed) return;
438
- keyframe.parsed = true;
439
- _this3.emit(keyframe.type, keyframe, _this3.currentTime);
440
- if (callback && run.valid()) {
441
- callback(keyframe.type, keyframe, _this3.currentTime);
442
- }
443
- });
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
- }
469
-
470
- /**
471
- * 开始运行播放器逻辑循环
472
- *
473
- * 启动帧循环,持续监听并处理关键帧事件
474
- * @param callback - 关键帧触发时的回调函数
475
- */
476
- }, {
477
- key: "run",
478
- value: function run(callback) {
479
- var _this5 = this;
480
- if (this.stopInterval) return;
481
- this.stopInterval = requestAnimationFrameInterval(function () {
482
- return _this5.requestAnimationFrameLoop(callback);
483
- });
484
- }
485
-
486
- /**
487
- * 清理播放器状态
488
- *
489
- * 停止播放、重置关键帧状态、清理数据和定时器
490
- */
491
- }, {
492
- key: "clear",
493
- value: function clear() {
494
- var _this$vreoUnit2, _this$stopInterval;
495
- this.setPlaying(false);
496
- (_this$vreoUnit2 = this.vreoUnit) === null || _this$vreoUnit2 === void 0 || _this$vreoUnit2.keyframes.forEach(function (keyframe) {
497
- return keyframe.parsed = false;
498
- });
499
-
500
- /**
501
- * 清理掉数据
502
- */
503
- this.vreoUnit = undefined;
504
- if (this.mediaInstance) {
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;
508
- }
509
- (_this$stopInterval = this.stopInterval) === null || _this$stopInterval === void 0 || _this$stopInterval.call(this);
510
- this.stopInterval = undefined;
511
- }
512
-
513
- /**
514
- * 销毁控制器实例
515
- *
516
- * 清理所有状态和资源,释放内存
517
- */
518
- }, {
519
- key: "dispose",
520
- value: function dispose() {
521
- this.disposers.splice(0).forEach(function (dispose) {
522
- return dispose();
523
- });
524
- this.playback.dispose();
525
- this.clear();
526
- }
527
- }]);
528
- }(Subscribe);
529
- var ControllerContext = /*#__PURE__*/React.createContext(null);
530
- export { ControllerContext };
@@ -1,117 +0,0 @@
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
- }();