@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,9 +1,20 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
- import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+ 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 }; })(); }
4
+ 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); }
4
5
  import * as THREE from 'three';
5
6
  export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
6
- var videoElement = _ref.videoElement;
7
+ var videoElement = _ref.videoElement,
8
+ mediaManager = _ref.mediaManager;
9
+ var listeners = [];
10
+ var on = function on(name, callback) {
11
+ listeners.push(function () {
12
+ five.off(name, callback);
13
+ });
14
+ return five.on(name, callback);
15
+ };
16
+ var generation = 0;
17
+ var disposed = false;
7
18
  var state = {
8
19
  videoMeshes: [],
9
20
  videoTextureEnabled: false,
@@ -12,57 +23,115 @@ export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
12
23
  enabled: false,
13
24
  videoElement: videoElement
14
25
  };
26
+ var session;
27
+ var output;
28
+ var removeReady;
29
+ var stop = function stop() {
30
+ var _removeReady;
31
+ ++generation;
32
+ (_removeReady = removeReady) === null || _removeReady === void 0 || _removeReady();
33
+ removeReady = undefined;
34
+ if (output) {
35
+ output.muted = true;
36
+ output.pause();
37
+ }
38
+ output = undefined;
39
+ session = undefined;
40
+ state.enabled = false;
41
+ state.videoMeshes.forEach(function (mesh) {
42
+ mesh.geometry.dispose();
43
+ mesh.material.dispose();
44
+ five.scene.remove(mesh);
45
+ });
46
+ state.videoMeshes = [];
47
+ five.needsRender = true;
48
+ };
49
+ var controller = mediaManager === null || mediaManager === void 0 ? void 0 : mediaManager.createController({
50
+ label: 'vreo-model-video',
51
+ onCancel: stop
52
+ });
53
+ var bind = function bind(userAction, audible) {
54
+ var _state$videoTexture, _controller$begin;
55
+ var element = (_state$videoTexture = state.videoTexture) === null || _state$videoTexture === void 0 ? void 0 : _state$videoTexture.image;
56
+ if (!element) return undefined;
57
+ var next = (_controller$begin = controller === null || controller === void 0 ? void 0 : controller.begin({
58
+ userAction: userAction,
59
+ audible: audible
60
+ })) !== null && _controller$begin !== void 0 ? _controller$begin : undefined;
61
+ if (controller && !next) return undefined;
62
+ session = next;
63
+ return output = next ? next.bind(element) : element;
64
+ };
15
65
  var setMuted = function setMuted(muted) {
16
- if (state.videoTexture) {
17
- state.videoTexture.image.muted = muted;
18
- state.videoTexture.image.play();
66
+ var userAction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
67
+ var wasEnabled = state.enabled;
68
+ var media = !muted ? bind(userAction, true) : output;
69
+ if (!media) return;
70
+ media.muted = muted;
71
+ if (wasEnabled && !state.enabled) {
72
+ state.enabled = true;
73
+ state.videoMeshes = createPanoVideoMeshes();
74
+ state.videoMeshes.forEach(function (mesh) {
75
+ return five.scene.add(mesh);
76
+ });
19
77
  }
78
+ var run = session;
79
+ var current = generation;
80
+ if (state.enabled) void media.play().catch(function (error) {
81
+ if (current === generation && !(run !== null && run !== void 0 && run.signal.aborted)) {
82
+ disable();
83
+ console.error(error);
84
+ }
85
+ });
20
86
  };
21
87
  var getMuted = function getMuted() {
22
- if (state.videoTexture) return state.videoTexture.image.muted;else return true;
88
+ var _output$muted, _output;
89
+ return (_output$muted = (_output = output) === null || _output === void 0 ? void 0 : _output.muted) !== null && _output$muted !== void 0 ? _output$muted : true;
23
90
  };
24
91
  var enable = function enable() {
25
- if (state.enabled) return;
26
- if (!state.videoTexture) return;
92
+ if (disposed || state.enabled || !state.videoTexture) return;
93
+ var media = bind(false, false);
94
+ if (!media) return;
95
+ var current = generation;
96
+ var run = session;
97
+ var element = state.videoTexture.image;
98
+ var valid = function valid() {
99
+ return current === generation && !disposed && state.enabled && !(run !== null && run !== void 0 && run.signal.aborted);
100
+ };
27
101
  state.enabled = true;
28
102
  state.videoMeshes = createPanoVideoMeshes();
29
103
  state.videoMeshes.forEach(function (mesh) {
30
104
  return five.scene.add(mesh);
31
105
  });
32
- var play = function play() {
33
- if (!state.videoTexture) return;
34
- var timeupdate = function timeupdate() {
35
- var _state$videoTexture;
36
- if (!state.videoTexture) return;
37
- (_state$videoTexture = state.videoTexture) === null || _state$videoTexture === void 0 ? void 0 : _state$videoTexture.image.removeEventListener('timeupdate', timeupdate);
38
- state.videoTextureEnabled = true;
39
- state.videoMeshes.forEach(function (mesh) {
40
- if (mesh.material.map !== state.videoTexture) mesh.material.map = state.videoTexture;
41
- });
42
- five.needsRender = true;
43
- };
44
- state.videoTexture.image.addEventListener('timeupdate', timeupdate);
45
- if (state.videoTexture && state.videoMeshes.length) {
46
- state.videoTexture.image.play();
47
- }
106
+ var _timeupdate = function timeupdate() {
107
+ element.removeEventListener('timeupdate', _timeupdate);
108
+ if (!valid()) return;
109
+ state.videoTextureEnabled = true;
110
+ state.videoMeshes.forEach(function (mesh) {
111
+ mesh.material.map = state.videoTexture;
112
+ });
113
+ five.needsRender = true;
48
114
  };
49
- if (five.model.loaded) play();else {
50
- return five.once('modelLoaded', function () {
51
- return play();
115
+ var _play = function play() {
116
+ five.off('modelLoaded', _play);
117
+ if (!valid()) return;
118
+ element.addEventListener('timeupdate', _timeupdate);
119
+ void media.play().catch(function (error) {
120
+ if (valid()) {
121
+ disable();
122
+ console.error(error);
123
+ }
52
124
  });
53
- }
125
+ };
126
+ removeReady = function removeReady() {
127
+ five.off('modelLoaded', _play);
128
+ element.removeEventListener('timeupdate', _timeupdate);
129
+ };
130
+ if (five.model.loaded) _play();else five.on('modelLoaded', _play);
54
131
  };
55
132
  var disable = function disable() {
56
- if (!state.enabled) return;
57
- state.enabled = false;
58
- state.videoMeshes.forEach(function (mesh) {
59
- mesh.geometry.dispose();
60
- mesh.material.dispose();
61
- five.scene.remove(mesh);
62
- if (state.videoTexture) state.videoTexture.image.pause();
63
- });
64
- state.videoMeshes = [];
65
- five.needsRender = true;
133
+ controller === null || controller === void 0 || controller.cancel();
134
+ stop();
66
135
  };
67
136
  var createPanoVideoMeshes = function createPanoVideoMeshes() {
68
137
  return state.rectPoints.map(function (points, index) {
@@ -115,15 +184,22 @@ export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
115
184
  return texture;
116
185
  };
117
186
  var getVideoTexture = function getVideoTexture(source, video) {
187
+ var valid = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
188
+ return true;
189
+ };
118
190
  return new Promise(function (resolve, reject) {
119
191
  var xhr = new XMLHttpRequest();
120
192
  xhr.onreadystatechange = function () {
121
193
  if (xhr.readyState == 4) {
194
+ if (!valid()) {
195
+ reject(new DOMException('Playback cancelled', 'AbortError'));
196
+ return;
197
+ }
122
198
  if (xhr.status == 200) {
123
199
  var url = window.URL || window.webkitURL;
124
200
  video = video || document.createElement('video');
125
201
  video.crossOrigin = 'anonymous';
126
- video.autoplay = true;
202
+ video.autoplay = false;
127
203
  video.muted = true;
128
204
  video.loop = true;
129
205
  video.playsInline = true;
@@ -149,36 +225,51 @@ export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
149
225
  });
150
226
  };
151
227
  var load = /*#__PURE__*/function () {
152
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(data, videoElement) {
153
- var video_src, video_poster_src, points;
154
- return _regeneratorRuntime.wrap(function _callee$(_context) {
155
- while (1) {
156
- switch (_context.prev = _context.next) {
157
- case 0:
158
- video_src = data.video_src, video_poster_src = data.video_poster_src, points = data.points;
159
- state.videoSource = video_src;
160
- state.rectPoints = points.map(function (items) {
161
- return items.map(function (_ref3) {
162
- var x = _ref3.x,
163
- y = _ref3.y,
164
- z = _ref3.z;
165
- return new THREE.Vector3(x, y, z);
166
- });
228
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(data, videoElement) {
229
+ var current, video_src, video_poster_src, points, texture;
230
+ return _regenerator().w(function (_context) {
231
+ while (1) switch (_context.n) {
232
+ case 0:
233
+ current = ++generation;
234
+ video_src = data.video_src, video_poster_src = data.video_poster_src, points = data.points;
235
+ state.videoSource = video_src;
236
+ state.rectPoints = points.map(function (items) {
237
+ return items.map(function (_ref3) {
238
+ var x = _ref3.x,
239
+ y = _ref3.y,
240
+ z = _ref3.z;
241
+ return new THREE.Vector3(x, y, z);
167
242
  });
168
- state.imageTexture = getImageTexture(video_poster_src);
169
- if (videoElement) {
170
- state.videoElement = videoElement;
171
- }
172
- _context.next = 7;
173
- return getVideoTexture(state.videoSource, state.videoElement);
174
- case 7:
175
- state.videoTexture = _context.sent;
176
- state.enabled = !!data.enable;
177
- if (state.enabled) enable();
178
- case 10:
179
- case "end":
180
- return _context.stop();
181
- }
243
+ });
244
+ state.imageTexture = getImageTexture(video_poster_src);
245
+ if (videoElement) {
246
+ state.videoElement = videoElement;
247
+ }
248
+ _context.n = 1;
249
+ return getVideoTexture(state.videoSource, state.videoElement, function () {
250
+ return !disposed && current === generation;
251
+ });
252
+ case 1:
253
+ texture = _context.v;
254
+ if (!(disposed || current !== generation)) {
255
+ _context.n = 2;
256
+ break;
257
+ }
258
+ texture.image.muted = true;
259
+ texture.image.pause();
260
+ URL.revokeObjectURL(texture.image.src);
261
+ texture.dispose();
262
+ return _context.a(2);
263
+ case 2:
264
+ if (state.videoTexture) {
265
+ state.videoTexture.image.pause();
266
+ URL.revokeObjectURL(state.videoTexture.image.src);
267
+ state.videoTexture.dispose();
268
+ }
269
+ state.videoTexture = texture;
270
+ if (data.enable) enable();
271
+ case 3:
272
+ return _context.a(2);
182
273
  }
183
274
  }, _callee);
184
275
  }));
@@ -186,20 +277,20 @@ export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
186
277
  return _ref2.apply(this, arguments);
187
278
  };
188
279
  }();
189
- five.on('modeChange', function () {
280
+ on('modeChange', function () {
190
281
  return setMuted(true);
191
282
  });
192
- five.on('wantsTapGesture', function (raycaster) {
283
+ on('wantsTapGesture', function (raycaster) {
193
284
  if (!state.enabled) return;
194
285
  var _raycaster$intersectO = raycaster.intersectObjects(five.scene.children, true),
195
286
  _raycaster$intersectO2 = _slicedToArray(_raycaster$intersectO, 1),
196
287
  intersect = _raycaster$intersectO2[0];
197
288
  if (!!intersect && /^video/.test(intersect.object.name)) {
198
- if (state.videoTexture) setMuted(!state.videoTexture.image.muted);
289
+ if (state.videoTexture) setMuted(!state.videoTexture.image.muted, true);
199
290
  return false;
200
291
  }
201
292
  });
202
- five.on('panoArrived', function () {
293
+ on('panoArrived', function () {
203
294
  if (!state.enabled) return;
204
295
  if (getMuted()) return;
205
296
  var cameraPosition = five.camera.position;
@@ -220,21 +311,37 @@ export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
220
311
  });
221
312
  if (!visible) setMuted(true);
222
313
  });
223
- five.on('renderFrame', function () {
314
+ on('renderFrame', function () {
224
315
  state.videoMeshes.forEach(function (meshes) {
225
316
  if (meshes)
226
317
  //@ts-ignore
227
318
  meshes.needsRender = true;
228
319
  });
229
320
  });
230
- five.on('load', function (input) {
321
+ on('load', function (input) {
231
322
  if (input.modelTVVideoData) {
232
323
  load(input.modelTVVideoData);
233
324
  }
234
325
  });
326
+ var dispose = function dispose() {
327
+ var _state$imageTexture;
328
+ disposed = true;
329
+ ++generation;
330
+ disable();
331
+ controller === null || controller === void 0 || controller.dispose();
332
+ listeners.splice(0).forEach(function (remove) {
333
+ return remove();
334
+ });
335
+ (_state$imageTexture = state.imageTexture) === null || _state$imageTexture === void 0 || _state$imageTexture.dispose();
336
+ if (state.videoTexture) {
337
+ URL.revokeObjectURL(state.videoTexture.image.src);
338
+ state.videoTexture.dispose();
339
+ }
340
+ };
235
341
  return {
236
342
  enable: enable,
237
343
  disable: disable,
238
- load: load
344
+ load: load,
345
+ dispose: dispose
239
346
  };
240
347
  };
package/lib/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export { Player } from './Player';
2
+ export type { PlaybackManager, PlaybackController, PlaybackSession, MediaOperations } from './Player/playback-types';
@@ -38,7 +38,7 @@ export var VreoProvider = function VreoProvider(props) {
38
38
  setPlayer(playerRef.current);
39
39
  return function () {
40
40
  var _playerRef$current;
41
- (_playerRef$current = playerRef.current) === null || _playerRef$current === void 0 ? void 0 : _playerRef$current.dispose();
41
+ (_playerRef$current = playerRef.current) === null || _playerRef$current === void 0 || _playerRef$current.dispose();
42
42
  };
43
43
  }, []);
44
44
  if (!player) return /*#__PURE__*/React.createElement(React.Fragment, null);
@@ -1,16 +1,17 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/esm/inherits";
5
3
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
- import _get from "@babel/runtime/helpers/esm/get";
4
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
7
5
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
6
+ import _get from "@babel/runtime/helpers/esm/get";
8
7
  import _wrapNativeSuper from "@babel/runtime/helpers/esm/wrapNativeSuper";
9
8
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
10
9
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
11
- import _regeneratorRuntime from "@babel/runtime/regenerator";
12
- 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); }; }
13
- 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; } }
10
+ 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 }; })(); }
11
+ 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); }
12
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
13
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
14
+ function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
14
15
  var blankAudioSrc = 'data:audio/mpeg;base64,//uQxAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAA8AAAADAAAGhgBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVWqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr///////////////////////////////////////////8AAAA5TEFNRTMuOThyAc0AAAAAAAAAABSAJAiqQgAAgAAABobxtI73AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//uQxAACFEII9ACZ/sJZwWEoEb8w/////N//////JcxjHjf+7/v/H2PzCCFAiDtGeyBCIx7bJJ1mmEEMy6g8mm2c8nrGABB4h2Mkmn//4z/73u773R5qHHu/j/w7Kxkzh5lWRWdsifCkNAnY9Zc1HvDAhjhSHdFkHFzLmabt/AQxSg2wwzLhHIJOBnAWwVY4zrhIYhhc2kvhYDfQ4hDi2Gmh5KyFn8EcGIrHAngNgIwVIEMf5bzbAiTRoAD///8z/KVhkkWEle6IX+d/z4fvH3BShK1e5kmjkCMoxVmXhd4ROlTKo3iipasvTilY21q19ta30/v/0/idPX1v8PNxJL6ramnOVsdvMv2akO0iSYIzdJFirtzWXCZicS9vHqvSKyqm5XJBdqBwPxyfJdykhWTZ0G0ZyTZGpLKxsNwwoRhsx3tZfhwmeOBVISm3impAC/IT/8hP/EKEM1KMdVdVKM2rHV4x7HVXZvbVVKN/qq8CiV9VL9jjH/6l6qf7MBCjZmOqsAibjcP+qqqv0oxqpa/NVW286hPo1nz2L/h8+jXt//uSxCmDU2IK/ECN98KKtE5IYzNoCfbw+u9i5r8PoadUMFPKqWL4LK3T/LCraMSHGkW4bpLXR/E6LlHOVQxmslKVJ8IULktMN06N0FKCpHCoYsjC4F+Z0NVqdNFoGSTjSiyjzLdnZ2fNqTi2eHKONONKLMPMKLONKLMPQRJGlFxZRoKcJFAYEeIFiRQkUWUeYfef//Ko04soswso40UJAgMw8wosososy0EalnZyjQUGBRQGIFggOWUacWUeYmuadrZziQKKEgQsQLAhQkUJAgMQDghltLO1onp0cpkNInSFMqlYeSEJ5AHsqFdOwy1DA2sRmRJKxdKRfLhfLw5BzUxBTUUzLjk4LjJVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjk4LjJVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7ksRRA8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVU=';
15
16
  // 下面这段空音频居然在11pro和xr上播不出来
16
17
  // const blankAudioSrc = 'data:audio/mpeg;base64,//AAAAHGZ0eXBNNEEgAAAAAE00QSBpc29tbXA0MgAAAAFtZGF0AAAAAAAAABwA0AAHANAABwDQAAcAAAM+bW9vdgAAAGxtdmhkAAAAAN+jti7fo7YuAACsRAAADAAAAQAAAQAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAdB0cmFrAAAAXHRraGQAAAAB36O2Lt+jti4AAAABAAAAAAAADAAAAAAAAAAAAAAAAAABAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAFsbWRpYQAAACBtZGhkAAAAAN+jti7fo7YuAACsRAAADABVxAAAAAAAMWhkbHIAAAAAAAAAAHNvdW4AAAAAAAAAAAAAAABDb3JlIE1lZGlhIEF1ZGlvAAAAARNtaW5mAAAAEHNtaGQAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAANdzdGJsAAAAZ3N0c2QAAAAAAAAAAQAAAFdtcDRhAAAAAAAAAAEAAAAAAAAAAAACABAAAAAArEQAAAAAADNlc2RzAAAAAAOAgIAiAAAABICAgBRAFAAYAAAA+gAAAPoABYCAgAISCAaAgIABAgAAABhzdHRzAAAAAAAAAAEAAAADAAAEAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAwAAAAEAAAAgc3RzegAAAAAAAAAAAAAAAwAAAAQAAAAEAAAABAAAABRzdGNvAAAAAAAAAAEAAAAsAAAA+nVkdGEAAADybWV0YQAAAAAAAAAiaGRscgAAAAAAAAAAbWRpcgAAAAAAAAAAAAAAAAAAAAAAxGlsc3QAAAC8LS0tLQAAABxtZWFuAAAAAGNvbS5hcHBsZS5pVHVuZXMAAAAUbmFtZQAAAABpVHVuU01QQgAAAIRkYXRhAAAAAQAAAAAgMDAwMDAwMDAgMDAwMDA4NDAgMDAwMDAzQzAgMDAwMDAwMDAwMDAwMDAwMCAwMDAwMDAwMCAwMDAwMDAwMCAwMDAwMDAwMCAwMDAwMDAwMCAwMDAwMDAwMCAwMDAwMDAwMCAwMDAwMDAwMA=='
@@ -34,49 +35,46 @@ export function waitForBlankAudioGenerated() {
34
35
  return _waitForBlankAudioGenerated.apply(this, arguments);
35
36
  }
36
37
  function _waitForBlankAudioGenerated() {
37
- _waitForBlankAudioGenerated = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
38
+ _waitForBlankAudioGenerated = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
38
39
  var checkInterval,
39
40
  timeout,
40
41
  startTime,
41
42
  isTimedOut,
42
43
  _args = arguments;
43
- return _regeneratorRuntime.wrap(function _callee$(_context) {
44
- while (1) {
45
- switch (_context.prev = _context.next) {
46
- case 0:
47
- checkInterval = _args.length > 0 && _args[0] !== undefined ? _args[0] : 100;
48
- timeout = _args.length > 1 && _args[1] !== undefined ? _args[1] : 2000;
49
- console.log('waitForBlankAudioGenerated, needGenerate: ', audioList.some(function (audio) {
50
- return !audio.ended && audio.src === blankAudioSrc;
51
- }));
52
- // while any audioList not ended
53
- startTime = Date.now();
54
- isTimedOut = false;
55
- case 5:
56
- if (!(audioList.some(function (audio) {
57
- return !audio.ended && audio.src === blankAudioSrc;
58
- }) && !isTimedOut)) {
59
- _context.next = 13;
60
- break;
61
- }
62
- if (!(Date.now() - startTime > timeout)) {
63
- _context.next = 9;
64
- break;
65
- }
66
- isTimedOut = true;
67
- return _context.abrupt("return", Promise.resolve());
68
- case 9:
69
- _context.next = 11;
70
- return new Promise(function (resolve) {
71
- return setTimeout(resolve, checkInterval);
72
- });
73
- case 11:
74
- _context.next = 5;
44
+ return _regenerator().w(function (_context) {
45
+ while (1) switch (_context.n) {
46
+ case 0:
47
+ checkInterval = _args.length > 0 && _args[0] !== undefined ? _args[0] : 100;
48
+ timeout = _args.length > 1 && _args[1] !== undefined ? _args[1] : 2000;
49
+ console.log('waitForBlankAudioGenerated, needGenerate: ', audioList.some(function (audio) {
50
+ return !audio.ended && audio.src === blankAudioSrc;
51
+ }));
52
+ // while any audioList not ended
53
+ startTime = Date.now();
54
+ isTimedOut = false;
55
+ case 1:
56
+ if (!(audioList.some(function (audio) {
57
+ return !audio.ended && audio.src === blankAudioSrc;
58
+ }) && !isTimedOut)) {
59
+ _context.n = 4;
75
60
  break;
76
- case 13:
77
- case "end":
78
- return _context.stop();
79
- }
61
+ }
62
+ if (!(Date.now() - startTime > timeout)) {
63
+ _context.n = 2;
64
+ break;
65
+ }
66
+ isTimedOut = true;
67
+ return _context.a(2, Promise.resolve());
68
+ case 2:
69
+ _context.n = 3;
70
+ return new Promise(function (resolve) {
71
+ return setTimeout(resolve, checkInterval);
72
+ });
73
+ case 3:
74
+ _context.n = 1;
75
+ break;
76
+ case 4:
77
+ return _context.a(2);
80
78
  }
81
79
  }, _callee);
82
80
  }));
@@ -101,21 +99,20 @@ function initAudio(audio) {
101
99
  }
102
100
  }
103
101
  var IAudio = /*#__PURE__*/function (_Audio) {
104
- _inherits(IAudio, _Audio);
105
- var _super = _createSuper(IAudio);
106
102
  function IAudio(src) {
107
- var _thisSuper, _this;
103
+ var _this;
108
104
  _classCallCheck(this, IAudio);
109
- _this = _super.call(this, src);
110
- _defineProperty(_assertThisInitialized(_this), "preload", 'auto');
111
- _defineProperty(_assertThisInitialized(_this), "realSrc", '');
112
- _defineProperty(_assertThisInitialized(_this), "inited", false);
105
+ _this = _callSuper(this, IAudio, [src]);
106
+ _defineProperty(_this, "preload", 'auto');
107
+ _defineProperty(_this, "realSrc", '');
108
+ _defineProperty(_this, "inited", false);
113
109
  _this.realSrc = src !== null && src !== void 0 ? src : '';
114
- _get((_thisSuper = _assertThisInitialized(_this), _getPrototypeOf(IAudio.prototype)), "addEventListener", _thisSuper).call(_thisSuper, 'ended', function () {
115
- _this.src = '';
116
- });
110
+ _this.muted = true;
111
+ _superPropGet((_this, IAudio), "addEventListener", _this, 3)(['ended', function () {
112
+ if (_this.src === blankAudioSrc) _this.src = '';
113
+ }]);
117
114
  var init = function init() {
118
- return initAudio(_assertThisInitialized(_this));
115
+ return initAudio(_this);
119
116
  };
120
117
  document.addEventListener('click', init);
121
118
  document.addEventListener('touchend', init);
@@ -125,7 +122,8 @@ var IAudio = /*#__PURE__*/function (_Audio) {
125
122
  };
126
123
  return _this;
127
124
  }
128
- _createClass(IAudio, [{
125
+ _inherits(IAudio, _Audio);
126
+ return _createClass(IAudio, [{
129
127
  key: "src",
130
128
  get:
131
129
  /**
@@ -141,9 +139,9 @@ var IAudio = /*#__PURE__*/function (_Audio) {
141
139
  * @param paramsSrc - 音频源 URL
142
140
  */,
143
141
  set: function set(paramsSrc) {
142
+ this.muted = true;
144
143
  this.setAttribute('src', paramsSrc);
145
144
  this.realSrc = paramsSrc;
146
145
  }
147
146
  }]);
148
- return IAudio;
149
- }( /*#__PURE__*/_wrapNativeSuper(Audio));
147
+ }(/*#__PURE__*/_wrapNativeSuper(Audio));
@@ -1,12 +1,11 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/esm/inherits";
5
3
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
4
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
5
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
7
6
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
8
- 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); }; }
9
- 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; } }
7
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
8
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
9
  import { Subscribe } from '@realsee/five';
11
10
  import { requestAnimationFrameInterval } from "./animationFrame/index.js";
12
11
  /**
@@ -16,25 +15,24 @@ import { requestAnimationFrameInterval } from "./animationFrame/index.js";
16
15
  * 模拟 `<Audio>` 功能:没有音频,但执行逻辑跟 `<Audio>` 相似。
17
16
  */
18
17
  export var AudioLike = /*#__PURE__*/function (_Subscribe) {
19
- _inherits(AudioLike, _Subscribe);
20
- var _super = _createSuper(AudioLike);
21
18
  function AudioLike() {
22
19
  var _this;
23
20
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
24
21
  duration = _ref.duration;
25
22
  _classCallCheck(this, AudioLike);
26
- _this = _super.call(this);
27
- _defineProperty(_assertThisInitialized(_this), "$timestamp", null);
28
- _defineProperty(_assertThisInitialized(_this), "$currentTime", 0);
29
- _defineProperty(_assertThisInitialized(_this), "$duration", 0);
30
- _defineProperty(_assertThisInitialized(_this), "muted", false);
31
- _defineProperty(_assertThisInitialized(_this), "src", '');
23
+ _this = _callSuper(this, AudioLike);
24
+ _defineProperty(_this, "$timestamp", null);
25
+ _defineProperty(_this, "$currentTime", 0);
26
+ _defineProperty(_this, "$duration", 0);
27
+ _defineProperty(_this, "muted", false);
28
+ _defineProperty(_this, "src", '');
32
29
  if (duration) {
33
30
  _this.$duration = duration;
34
31
  }
35
32
  return _this;
36
33
  }
37
- _createClass(AudioLike, [{
34
+ _inherits(AudioLike, _Subscribe);
35
+ return _createClass(AudioLike, [{
38
36
  key: "setAttribute",
39
37
  value: function setAttribute(name, value) {
40
38
  // nothing todo
@@ -43,6 +41,7 @@ export var AudioLike = /*#__PURE__*/function (_Subscribe) {
43
41
  key: "play",
44
42
  value: function play() {
45
43
  var _this2 = this;
44
+ if (this.stopInterval) return;
46
45
  if (this.$currentTime === this.$duration) {
47
46
  this.$currentTime = 0;
48
47
  }
@@ -117,6 +116,5 @@ export var AudioLike = /*#__PURE__*/function (_Subscribe) {
117
116
  this.off(evtName, callback);
118
117
  }
119
118
  }]);
120
- return AudioLike;
121
119
  }(Subscribe);
122
120
  export default AudioLike;