@realsee/vreo 1.0.0-alpha.9 → 1.1.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/README.md +46 -36
- package/lib/PlayController/index.js +1 -1
- package/lib/Player/App.js +12 -5
- package/lib/Player/Controller.d.ts +3 -2
- package/lib/Player/Controller.js +31 -14
- package/lib/Player/index.js +31 -16
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +2 -2
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +7 -12
- package/lib/Player/modules/VideoAgent/index.js +1 -1
- package/lib/Player/modules/Wave/index.d.ts +1 -0
- package/lib/Player/modules/Wave/index.js +161 -25
- package/lib/Player/modules/keyframes/BgMusic/index.js +48 -40
- package/lib/Player/modules/keyframes/PanoTag/index.js +1 -0
- package/lib/Player/typings.d.ts +2 -0
- package/lib/fivePlugins/CameraMovementPlugin/index.js +3 -2
- package/lib/shared-utils/Audio.d.ts +14 -0
- package/lib/shared-utils/Audio.js +158 -0
- package/lib/shared-utils/{AduioLike.d.ts → AudioLike.d.ts} +0 -0
- package/lib/shared-utils/{AduioLike.js → AudioLike.js} +4 -6
- package/lib/shared-utils/animationFrame/tween.d.ts +3 -58
- package/lib/shared-utils/animationFrame/tween.js +3 -9
- package/lib/typings/VreoUnit.d.ts +8 -5
- package/package.json +8 -6
- package/stylesheets/default.css +7 -2
- package/docs/.nojekyll +0 -1
- package/docs/assets/custom.css +0 -78
- package/docs/assets/highlight.css +0 -127
- package/docs/assets/icons.css +0 -1043
- package/docs/assets/icons.png +0 -0
- package/docs/assets/icons@2x.png +0 -0
- package/docs/assets/main.js +0 -52
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1414
- package/docs/assets/widgets.png +0 -0
- package/docs/assets/widgets@2x.png +0 -0
- package/docs/classes/Player.AudioLike.html +0 -52
- package/docs/classes/Player.Controller.html +0 -54
- package/docs/classes/Player.Player-1.html +0 -50
- package/docs/classes/Player.VideoAgentMesh.html +0 -142
- package/docs/classes/Player.VideoAgentScene.html +0 -1
- package/docs/demo/assets/AppReact.6ca5d1d2.js +0 -1
- package/docs/demo/assets/default.5a762ce2.js +0 -3988
- package/docs/demo/assets/default.bc4c715d.css +0 -1
- package/docs/demo/assets/dynamic.efc5200d.js +0 -1
- package/docs/demo/assets/examples.80a27156.js +0 -25
- package/docs/demo/assets/examples.dac4a6fe.css +0 -1
- package/docs/demo/assets/index.9331038f.css +0 -1
- package/docs/demo/assets/index.ca7c5881.js +0 -1
- package/docs/demo/assets/main.c164d1d2.js +0 -1
- package/docs/demo/assets/react.2ee8565f.css +0 -1
- package/docs/demo/assets/react.a4774aef.js +0 -25
- package/docs/demo/assets/znRoyv06SZQeqA7m.0057e8ae.js +0 -1
- package/docs/demo/examples.html +0 -17
- package/docs/demo/index-react-dynamic.html +0 -20
- package/docs/demo/index-react.html +0 -20
- package/docs/demo/index.html +0 -19
- package/docs/enums/Player.InfoPanelStyleEnum.html +0 -1
- package/docs/enums/Player.InfoPanelTypeEnum.html +0 -3
- package/docs/enums/Player.PanoEffectEnum.html +0 -5
- package/docs/enums/Player.PanoTagEnum.html +0 -3
- package/docs/enums/Player.PanoTagStyleEnum.html +0 -7
- package/docs/enums/Player.VreoKeyframeEnum.html +0 -25
- package/docs/enums/fivePlugins.CameraMovementEffect.html +0 -1
- package/docs/enums/fivePlugins.Rotation.html +0 -1
- package/docs/index.html +0 -245
- package/docs/interfaces/Player.CustomVreoKeyframeProps.html +0 -1
- package/docs/interfaces/Player.PlayerConfigs.html +0 -7
- package/docs/interfaces/Player.Vertex.html +0 -3
- package/docs/interfaces/Player.VideoAgentMeshOptions.html +0 -8
- package/docs/interfaces/Player.VreoKeyframe.html +0 -3
- package/docs/interfaces/Player.VreoUnit.html +0 -3
- package/docs/interfaces/Player.VreoVideo.html +0 -3
- package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +0 -4
- package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +0 -1
- package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +0 -7
- package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +0 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +0 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +0 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +0 -1
- package/docs/interfaces/fivePlugins.Vector3Position.html +0 -3
- package/docs/interfaces/react.VreoActionCallbacks.html +0 -23
- package/docs/interfaces/react.VreoProviderProps.html +0 -1
- package/docs/modules/Player.html +0 -37
- package/docs/modules/custom.html +0 -3
- package/docs/modules/fivePlugins.html +0 -6
- package/docs/modules/react.html +0 -1
- package/docs/modules.html +0 -1
- package/resources/PlayController/createHTMLAudioElement.ts +0 -53
- package/resources/PlayController/index.ts +0 -154
- package/resources/Player/App.tsx +0 -66
- package/resources/Player/Controller.ts +0 -294
- package/resources/Player/custom/SpatialScenePanel/index.tsx +0 -264
- package/resources/Player/hooks.ts +0 -26
- package/resources/Player/index.tsx +0 -227
- package/resources/Player/modules/Drawer/index.tsx +0 -40
- package/resources/Player/modules/PopUp/index.tsx +0 -26
- package/resources/Player/modules/ResizeObserver/index.tsx +0 -23
- package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +0 -302
- package/resources/Player/modules/VideoAgent/VideoAgentScene.ts +0 -56
- package/resources/Player/modules/VideoAgent/index.tsx +0 -53
- package/resources/Player/modules/Wave/index.tsx +0 -18
- package/resources/Player/modules/keyframes/BgMusic/index.tsx +0 -66
- package/resources/Player/modules/keyframes/CameraMovement/index.tsx +0 -37
- package/resources/Player/modules/keyframes/InfoPanel/index.tsx +0 -165
- package/resources/Player/modules/keyframes/ModelVideo/index.tsx +0 -77
- package/resources/Player/modules/keyframes/PanoEffect/index.tsx +0 -99
- package/resources/Player/modules/keyframes/PanoEffect/lineAnime.ts +0 -31
- package/resources/Player/modules/keyframes/PanoTag/index.tsx +0 -82
- package/resources/Player/modules/keyframes/PanoTextLabel/index.tsx +0 -117
- package/resources/Player/modules/keyframes/Prompter/index.tsx +0 -56
- package/resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx +0 -99
- package/resources/Player/modules/keyframes/VideoEffect/index.tsx +0 -115
- package/resources/Player/typings.ts +0 -49
- package/resources/fivePlugins/CSS3DRenderPlugin/centerPoint.ts +0 -5
- package/resources/fivePlugins/CSS3DRenderPlugin/createResizeObserver.ts +0 -17
- package/resources/fivePlugins/CSS3DRenderPlugin/evenNumber.ts +0 -4
- package/resources/fivePlugins/CSS3DRenderPlugin/index.ts +0 -254
- package/resources/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.ts +0 -5
- package/resources/fivePlugins/CameraMovementPlugin/index.ts +0 -226
- package/resources/fivePlugins/CameraMovementPlugin/typings.ts +0 -59
- package/resources/fivePlugins/ModelTVVideoPlugin/index.ts +0 -278
- package/resources/index.ts +0 -1
- package/resources/react/index.tsx +0 -121
- package/resources/shared-utils/AduioLike.ts +0 -109
- package/resources/shared-utils/Preloader.ts +0 -35
- package/resources/shared-utils/addResizeListener.ts +0 -46
- package/resources/shared-utils/animationFrame/BetterTween.ts +0 -33
- package/resources/shared-utils/animationFrame/index.ts +0 -48
- package/resources/shared-utils/animationFrame/tween.ts +0 -51
- package/resources/shared-utils/createTransMatrix.ts +0 -12
- package/resources/shared-utils/getFileExpandedName.ts +0 -6
- package/resources/shared-utils/getMediaInfo.ts +0 -52
- package/resources/shared-utils/setElementDataset.ts +0 -18
- package/resources/typings/VreoUnit.ts +0 -314
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
|
+
#1.0.0-alpha.21
|
|
3
|
+
- fix: 多段BgMusic播放问题
|
|
4
|
+
|
|
5
|
+
#1.0.0-alpha.19
|
|
6
|
+
- fix: 多段BgMusic可以重复播放
|
|
7
|
+
|
|
8
|
+
#1.0.0-alpha.18
|
|
9
|
+
- fix: 修复无音频版本中途播放会从头开始的问题
|
|
10
|
+
|
|
2
11
|
#1.0.0-alpha.1
|
|
3
12
|
- feat: css样式适配: 手机横竖屏, pad, pc
|
|
4
13
|
- feat: 新增两种波浪风格: 'wave' | 'solid'
|
|
5
14
|
- feat: 标签调用dna插件
|
|
6
|
-
- fix: 修复无音频版本中途播放会从头开始的问题
|
|
7
15
|
- fix: 图片/视频 弹窗UI问题
|
|
8
16
|
|
|
9
17
|
#0.2.0-alpha.25
|
package/README.md
CHANGED
|
@@ -15,20 +15,36 @@
|
|
|
15
15
|
|
|
16
16
|
## 安装说明
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
- 由于 `@realsee/vreo` 依赖 [Five](https://unpkg.com/@realsee/five/docs/index.html) 和 [React](https://reactjs.org/) ,请务必同时安装相关依赖
|
|
19
|
+
- 根据项目的包管理器来安装:
|
|
20
|
+
``` bash
|
|
21
|
+
# pnpm
|
|
22
|
+
pnpm install @realsee/vreo @realsee/five react react-dom --save
|
|
23
|
+
# npm
|
|
24
|
+
npm install @realsee/vreo @realsee/five react react-dom --save
|
|
25
|
+
# yarn
|
|
26
|
+
yarn add @realsee/vreo @realsee/five react react-dom
|
|
27
|
+
```
|
|
25
28
|
|
|
26
29
|
## 快速上手
|
|
30
|
+
引入样式:
|
|
27
31
|
|
|
32
|
+
```css
|
|
33
|
+
/* @file xxx.css */
|
|
34
|
+
@import '@realsee/vreo/stylesheets/default.css';
|
|
35
|
+
```
|
|
36
|
+
或
|
|
28
37
|
```jsx
|
|
38
|
+
/* @file xxx.tsx | xxx.jsx */
|
|
39
|
+
import '@realsee/vreo/stylesheets/default.css';
|
|
40
|
+
```
|
|
41
|
+
examples:
|
|
42
|
+
```tsx
|
|
43
|
+
/* @file index.tsx | index.jsx */
|
|
29
44
|
import * as React from 'react'
|
|
30
45
|
import { Five } from '@realsee/five'
|
|
31
46
|
import { Player } from '@realsee/vreo'
|
|
47
|
+
import '@realsee/vreo/stylesheets/default.css';
|
|
32
48
|
|
|
33
49
|
// 创建 Five 实例
|
|
34
50
|
const five = new Five({
|
|
@@ -36,32 +52,28 @@ const five = new Five({
|
|
|
36
52
|
})
|
|
37
53
|
|
|
38
54
|
// 创建 Player 实例
|
|
39
|
-
const
|
|
55
|
+
const vreoPlayer = new Player(five)
|
|
40
56
|
|
|
41
57
|
// 异步请求剧本数据
|
|
42
58
|
const vreoUnit = await fetch('api/**/**')
|
|
43
59
|
|
|
44
60
|
// 加载剧本数据(剧本数据见下文)
|
|
45
|
-
|
|
61
|
+
vreoPlayer.load(vreoUnit)
|
|
46
62
|
|
|
47
63
|
// 播放
|
|
48
|
-
|
|
64
|
+
vreoPlayer.play()
|
|
49
65
|
|
|
50
66
|
// 暂停
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
引入样式:
|
|
55
|
-
|
|
56
|
-
```css
|
|
57
|
-
@import '@realsee/vreo/stylesheets/default.css';
|
|
67
|
+
vreoPlayer.pause()
|
|
58
68
|
```
|
|
59
69
|
|
|
60
70
|
## React Context & Hooks 模式使用
|
|
61
71
|
|
|
62
72
|
**Vreo** 支持 [React Context](https://reactjs.org/docs/context.html) 与 [Hooks](https://reactjs.org/docs/hooks-intro.html) 相配合的模式使用,简单样例如下:
|
|
63
73
|
|
|
64
|
-
```
|
|
74
|
+
```tsx
|
|
75
|
+
/* @file App.tsx */
|
|
76
|
+
|
|
65
77
|
import * as React from 'react'
|
|
66
78
|
import * as ReactDOM from 'react-dom'
|
|
67
79
|
import { Five, Work, parseWork } from '@realsee/five'
|
|
@@ -78,20 +90,21 @@ const PlayButton: React.FC = () => {
|
|
|
78
90
|
const { load, play, pause } = useVreoAction()
|
|
79
91
|
|
|
80
92
|
return (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
<>
|
|
94
|
+
<button
|
|
95
|
+
onClick={async () => {
|
|
96
|
+
// 获取讲房数据
|
|
97
|
+
const vreoUnit = await fetch('api/**/**')
|
|
98
|
+
// 载入数据
|
|
99
|
+
await load(vreoUnit)
|
|
100
|
+
// 播放
|
|
101
|
+
play()
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
讲解
|
|
105
|
+
</button>
|
|
106
|
+
<button onClick={() => pause()}>暂停</button>
|
|
107
|
+
</>
|
|
95
108
|
)
|
|
96
109
|
}
|
|
97
110
|
|
|
@@ -559,7 +572,4 @@ vreoplayer.load(vreoUnit, 0, true)
|
|
|
559
572
|
|
|
560
573
|
```
|
|
561
574
|
|
|
562
|
-
|
|
563
|
-
## API 文档
|
|
564
|
-
|
|
565
|
-
详细的 API 文档请参考:[Vreo API](https://realsee.js.org/vreo/index.html) 。
|
|
575
|
+
Enjoy it!
|
|
@@ -66,7 +66,7 @@ var PlayController = /*#__PURE__*/function (_Subscribe) {
|
|
|
66
66
|
currentKeyframes.forEach(function (keyframe) {
|
|
67
67
|
if (keyframe.parsed) return;
|
|
68
68
|
keyframe.parsed = true;
|
|
69
|
-
_this.emit(keyframe.type, keyframe);
|
|
69
|
+
_this.emit(keyframe.type, keyframe, _this.currentTime);
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
72
|
return _this;
|
package/lib/Player/App.js
CHANGED
|
@@ -26,7 +26,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
26
26
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
27
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
28
28
|
var AppView = (0, _mobxReact.observer)(function (_ref) {
|
|
29
|
-
var _controller$configs, _controller$
|
|
29
|
+
var _controller$configs, _controller$waveAppea, _controller$configs3, _controller$configs4;
|
|
30
30
|
var controller = _ref.controller;
|
|
31
31
|
return /*#__PURE__*/React.createElement("div", {
|
|
32
32
|
className: (0, _classnames["default"])('vreo-panel', {
|
|
@@ -34,18 +34,25 @@ var AppView = (0, _mobxReact.observer)(function (_ref) {
|
|
|
34
34
|
})
|
|
35
35
|
}, /*#__PURE__*/React.createElement("div", {
|
|
36
36
|
className: "vreo-panel-inner"
|
|
37
|
-
},
|
|
38
|
-
|
|
37
|
+
}, /*#__PURE__*/React.createElement(_Wave.Wave, {
|
|
38
|
+
onClick: (_controller$configs = controller.configs) === null || _controller$configs === void 0 ? void 0 : _controller$configs.onWaveClick,
|
|
39
|
+
appearance: (_controller$waveAppea = controller.waveAppearance) !== null && _controller$waveAppea !== void 0 ? _controller$waveAppea : 'single'
|
|
39
40
|
}), /*#__PURE__*/React.createElement(_VideoAgent.VideoAgent, {
|
|
40
41
|
onClick: function onClick() {
|
|
42
|
+
var _controller$configs2;
|
|
43
|
+
if ((_controller$configs2 = controller.configs) !== null && _controller$configs2 !== void 0 && _controller$configs2.onAvatarClick) {
|
|
44
|
+
controller.configs.onAvatarClick();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// 默认点击逻辑
|
|
41
48
|
if (controller.playing) {
|
|
42
49
|
controller.setPlaying(false);
|
|
43
50
|
} else {
|
|
44
51
|
controller.setPlaying(true);
|
|
45
52
|
}
|
|
46
53
|
},
|
|
47
|
-
options: ((_controller$
|
|
48
|
-
}), /*#__PURE__*/React.createElement(_Prompter.Prompter, null), (_controller$
|
|
54
|
+
options: ((_controller$configs3 = controller.configs) === null || _controller$configs3 === void 0 ? void 0 : _controller$configs3.videoAgentMeshOptions) || {}
|
|
55
|
+
}), /*#__PURE__*/React.createElement(_Prompter.Prompter, null), (_controller$configs4 = controller.configs) === null || _controller$configs4 === void 0 ? void 0 : _controller$configs4.customPanelChildren));
|
|
49
56
|
});
|
|
50
57
|
function App() {
|
|
51
58
|
var controller = (0, _hooks.useController)();
|
|
@@ -51,12 +51,13 @@ export declare class Controller extends Subscribe<VreoKeyframeEvent> {
|
|
|
51
51
|
get ready(): boolean;
|
|
52
52
|
get currentTime(): number;
|
|
53
53
|
get currentKeyframes(): VreoKeyframe[];
|
|
54
|
-
get mediaInstance(): HTMLVideoElement | HTMLAudioElement | import("../shared-utils/
|
|
54
|
+
get mediaInstance(): HTMLVideoElement | HTMLAudioElement | import("../shared-utils/AudioLike").AudioLike | undefined;
|
|
55
55
|
/**
|
|
56
56
|
* 逐帧任务
|
|
57
57
|
*/
|
|
58
|
-
requestAnimationFrameLoop(callback: (type: VreoKeyframeEnum, keyframe: VreoKeyframe) => void): void;
|
|
58
|
+
requestAnimationFrameLoop(callback: (type: VreoKeyframeEnum, keyframe: VreoKeyframe, currentTime: number) => void): void;
|
|
59
59
|
run(callback: (type: VreoKeyframeEnum, keyframe: VreoKeyframe) => void): void;
|
|
60
|
+
clear(): void;
|
|
60
61
|
dispose(): void;
|
|
61
62
|
}
|
|
62
63
|
declare const ControllerContext: React.Context<Controller | null>;
|
package/lib/Player/Controller.js
CHANGED
|
@@ -9,6 +9,7 @@ var _five = require("@realsee/five");
|
|
|
9
9
|
var _mobx = require("mobx");
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _animationFrame = require("../shared-utils/animationFrame");
|
|
12
|
+
var _VreoUnit = require("../typings/VreoUnit");
|
|
12
13
|
var _setElementDataset = _interopRequireDefault(require("../shared-utils/setElementDataset"));
|
|
13
14
|
var _getMediaInfo = require("../shared-utils/getMediaInfo");
|
|
14
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -72,6 +73,7 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
72
73
|
playing: _mobx.observable,
|
|
73
74
|
setPlaying: _mobx.action,
|
|
74
75
|
loading: _mobx.observable,
|
|
76
|
+
// videoAgentScene: observable.ref,
|
|
75
77
|
setLoading: _mobx.action,
|
|
76
78
|
popUp: _mobx.observable.ref,
|
|
77
79
|
openPopUp: _mobx.action,
|
|
@@ -261,6 +263,12 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
261
263
|
// 没有被解析过且开始时间低于当前时间戳 100ms
|
|
262
264
|
return keyframes.filter(function (keyframe) {
|
|
263
265
|
if (keyframe.parsed) return false;
|
|
266
|
+
// 检测结束时间
|
|
267
|
+
if (keyframe.end < _this2.currentTime) return false;
|
|
268
|
+
// 检测开始时间
|
|
269
|
+
if (keyframe.start > _this2.currentTime) return false;
|
|
270
|
+
if (keyframe.type === _VreoUnit.VreoKeyframeEnum.BgMusic) return true;
|
|
271
|
+
// 开始时间低于当前时间戳 100ms
|
|
264
272
|
var dur = _this2.currentTime - keyframe.start;
|
|
265
273
|
return dur <= 100 && dur >= 0;
|
|
266
274
|
});
|
|
@@ -281,10 +289,16 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
281
289
|
var _this$mediaInstance,
|
|
282
290
|
_this$mediaInstance4,
|
|
283
291
|
_this3 = this;
|
|
284
|
-
if ((_this$mediaInstance = this.mediaInstance) !== null && _this$mediaInstance !== void 0 && _this$mediaInstance.ended) {
|
|
292
|
+
if ((_this$mediaInstance = this.mediaInstance) !== null && _this$mediaInstance !== void 0 && _this$mediaInstance.ended && this.mediaInstance.currentTime !== 0) {
|
|
293
|
+
var _this$vreoUnit;
|
|
294
|
+
if (this.ended) return;
|
|
295
|
+
(_this$vreoUnit = this.vreoUnit) === null || _this$vreoUnit === void 0 ? void 0 : _this$vreoUnit.keyframes.forEach(function (keyframe) {
|
|
296
|
+
return keyframe.parsed = false;
|
|
297
|
+
});
|
|
285
298
|
this.setEnded(true);
|
|
286
299
|
this.setPlaying(false);
|
|
287
300
|
this.mediaInstance.pause();
|
|
301
|
+
this.mediaInstance.currentTime = 0;
|
|
288
302
|
return;
|
|
289
303
|
}
|
|
290
304
|
if (!this.playing) {
|
|
@@ -302,9 +316,9 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
302
316
|
currentKeyframes.forEach(function (keyframe) {
|
|
303
317
|
if (keyframe.parsed) return;
|
|
304
318
|
keyframe.parsed = true;
|
|
305
|
-
_this3.emit(keyframe.type, keyframe);
|
|
319
|
+
_this3.emit(keyframe.type, keyframe, _this3.currentTime);
|
|
306
320
|
if (callback) {
|
|
307
|
-
callback(keyframe.type, keyframe);
|
|
321
|
+
callback(keyframe.type, keyframe, _this3.currentTime);
|
|
308
322
|
}
|
|
309
323
|
});
|
|
310
324
|
}
|
|
@@ -318,26 +332,29 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
318
332
|
});
|
|
319
333
|
}
|
|
320
334
|
}, {
|
|
321
|
-
key: "
|
|
322
|
-
value: function
|
|
335
|
+
key: "clear",
|
|
336
|
+
value: function clear() {
|
|
337
|
+
var _this$vreoUnit2, _this$stopInterval;
|
|
323
338
|
this.setPlaying(false);
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
});
|
|
328
|
-
}
|
|
339
|
+
(_this$vreoUnit2 = this.vreoUnit) === null || _this$vreoUnit2 === void 0 ? void 0 : _this$vreoUnit2.keyframes.forEach(function (keyframe) {
|
|
340
|
+
return keyframe.parsed = false;
|
|
341
|
+
});
|
|
329
342
|
|
|
330
343
|
/**
|
|
331
344
|
* 清理掉数据
|
|
332
345
|
*/
|
|
333
346
|
this.vreoUnit = undefined;
|
|
334
347
|
if (this.mediaInstance) {
|
|
348
|
+
this.mediaInstance.pause();
|
|
335
349
|
this.mediaInstance.currentTime = 0;
|
|
336
350
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
351
|
+
(_this$stopInterval = this.stopInterval) === null || _this$stopInterval === void 0 ? void 0 : _this$stopInterval.call(this);
|
|
352
|
+
this.stopInterval = undefined;
|
|
353
|
+
}
|
|
354
|
+
}, {
|
|
355
|
+
key: "dispose",
|
|
356
|
+
value: function dispose() {
|
|
357
|
+
this.clear();
|
|
341
358
|
}
|
|
342
359
|
}]);
|
|
343
360
|
return Controller;
|
package/lib/Player/index.js
CHANGED
|
@@ -14,6 +14,8 @@ var _VreoUnit = require("../typings/VreoUnit");
|
|
|
14
14
|
var _mobx = require("mobx");
|
|
15
15
|
var _Drawer = require("./modules/Drawer");
|
|
16
16
|
var _PopUp = require("./modules/PopUp");
|
|
17
|
+
var _Audio = require("../shared-utils/Audio");
|
|
18
|
+
var _location$search$matc, _location$search$matc2;
|
|
17
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
21
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
@@ -29,6 +31,8 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
29
31
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
30
32
|
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; } }
|
|
31
33
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
34
|
+
var DefaultAudioCacheLength = 3;
|
|
35
|
+
var audioCacheLength = Number((_location$search$matc = (_location$search$matc2 = location.search.match(/audio_cache=(\d+)/)) === null || _location$search$matc2 === void 0 ? void 0 : _location$search$matc2[1]) !== null && _location$search$matc !== void 0 ? _location$search$matc : DefaultAudioCacheLength);
|
|
32
36
|
var Player = /*#__PURE__*/function (_Subscribe) {
|
|
33
37
|
_inherits(Player, _Subscribe);
|
|
34
38
|
var _super = _createSuper(Player);
|
|
@@ -38,6 +42,7 @@ var Player = /*#__PURE__*/function (_Subscribe) {
|
|
|
38
42
|
_classCallCheck(this, Player);
|
|
39
43
|
_this = _super.call(this);
|
|
40
44
|
_this.$five = five;
|
|
45
|
+
(0, _Audio.generateBlankAudio)(audioCacheLength);
|
|
41
46
|
if (!configs.container) {
|
|
42
47
|
configs.container = configs.containter;
|
|
43
48
|
}
|
|
@@ -123,23 +128,24 @@ var Player = /*#__PURE__*/function (_Subscribe) {
|
|
|
123
128
|
currentTime = _args.length > 1 && _args[1] !== undefined ? _args[1] : 0;
|
|
124
129
|
preload = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
|
|
125
130
|
force = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
|
|
131
|
+
this.controller.clear();
|
|
126
132
|
this.controller.setLoading(true);
|
|
127
133
|
if (force) {
|
|
128
134
|
vreoUnit = JSON.parse(JSON.stringify(vreoUnit));
|
|
129
135
|
}
|
|
130
136
|
if (this.controller.visible) {
|
|
131
|
-
_context.next =
|
|
137
|
+
_context.next = 10;
|
|
132
138
|
break;
|
|
133
139
|
}
|
|
134
140
|
this.controller.setVisible(true);
|
|
135
141
|
// 延迟 500ms 规避跟 DOM 动画冲突
|
|
136
|
-
_context.next =
|
|
142
|
+
_context.next = 10;
|
|
137
143
|
return new Promise(function (resolve) {
|
|
138
144
|
setTimeout(function () {
|
|
139
145
|
return resolve(true);
|
|
140
146
|
}, 500);
|
|
141
147
|
});
|
|
142
|
-
case
|
|
148
|
+
case 10:
|
|
143
149
|
if (this.controller.stopInterval) {
|
|
144
150
|
this.controller.stopInterval();
|
|
145
151
|
this.controller.stopInterval = undefined;
|
|
@@ -155,7 +161,7 @@ var Player = /*#__PURE__*/function (_Subscribe) {
|
|
|
155
161
|
|
|
156
162
|
// 预载数据中的点位
|
|
157
163
|
if (!(preload || preload === undefined && this.configs.autoPreload)) {
|
|
158
|
-
_context.next =
|
|
164
|
+
_context.next = 24;
|
|
159
165
|
break;
|
|
160
166
|
}
|
|
161
167
|
panoIndexMap = vreoUnit.keyframes.filter(function (vreoKeyframe) {
|
|
@@ -176,18 +182,18 @@ var Player = /*#__PURE__*/function (_Subscribe) {
|
|
|
176
182
|
}, {});
|
|
177
183
|
panoIndexes = Object.keys(panoIndexMap);
|
|
178
184
|
i = 0;
|
|
179
|
-
case
|
|
185
|
+
case 18:
|
|
180
186
|
if (!(i < panoIndexes.length)) {
|
|
181
|
-
_context.next =
|
|
187
|
+
_context.next = 24;
|
|
182
188
|
break;
|
|
183
189
|
}
|
|
184
|
-
_context.next =
|
|
190
|
+
_context.next = 21;
|
|
185
191
|
return this.$five.preloadPano(Number(panoIndexes[i]));
|
|
186
|
-
case
|
|
192
|
+
case 21:
|
|
187
193
|
i++;
|
|
188
|
-
_context.next =
|
|
194
|
+
_context.next = 18;
|
|
189
195
|
break;
|
|
190
|
-
case
|
|
196
|
+
case 24:
|
|
191
197
|
// 新数据载入就绪
|
|
192
198
|
this.emit('loaded', vreoUnit);
|
|
193
199
|
this.controller.emit('loaded', vreoUnit);
|
|
@@ -195,17 +201,20 @@ var Player = /*#__PURE__*/function (_Subscribe) {
|
|
|
195
201
|
this.controller.videoAgentScene.videoAgentMesh.mediaInstance.currentTime = currentTime / 1000;
|
|
196
202
|
}
|
|
197
203
|
this.controller.setAvatar(vreoUnit.video.avatar);
|
|
198
|
-
_context.next =
|
|
204
|
+
_context.next = 30;
|
|
205
|
+
return (0, _Audio.waitForBlankAudioGenerated)();
|
|
206
|
+
case 30:
|
|
207
|
+
_context.next = 32;
|
|
199
208
|
return (_this$controller$vide2 = this.controller.videoAgentScene) === null || _this$controller$vide2 === void 0 ? void 0 : _this$controller$vide2.videoAgentMesh.play(vreoUnit.video.url, currentTime / 1000, vreoUnit.video.duration);
|
|
200
|
-
case
|
|
209
|
+
case 32:
|
|
201
210
|
this.controller.setEnded(false);
|
|
202
211
|
this.play();
|
|
203
212
|
this.controller.run(function (type, keyframe) {
|
|
204
|
-
return _this2.emit(type, keyframe);
|
|
213
|
+
return _this2.emit(type, keyframe, _this2.controller.currentTime);
|
|
205
214
|
});
|
|
206
215
|
this.controller.setLoading(false);
|
|
207
216
|
return _context.abrupt("return", true);
|
|
208
|
-
case
|
|
217
|
+
case 37:
|
|
209
218
|
case "end":
|
|
210
219
|
return _context.stop();
|
|
211
220
|
}
|
|
@@ -225,6 +234,7 @@ var Player = /*#__PURE__*/function (_Subscribe) {
|
|
|
225
234
|
}, {
|
|
226
235
|
key: "play",
|
|
227
236
|
value: function play(currentTime) {
|
|
237
|
+
var _this$controller$vreo;
|
|
228
238
|
if (this.controller.playing) return true;
|
|
229
239
|
if (currentTime && this.controller.mediaInstance) {
|
|
230
240
|
this.controller.mediaInstance.currentTime = currentTime / 1000;
|
|
@@ -232,7 +242,13 @@ var Player = /*#__PURE__*/function (_Subscribe) {
|
|
|
232
242
|
Object.assign(window, {
|
|
233
243
|
$vreoController: this.controller
|
|
234
244
|
});
|
|
245
|
+
this.controller.setEnded(false);
|
|
235
246
|
this.controller.setPlaying(true);
|
|
247
|
+
(_this$controller$vreo = this.controller.vreoUnit) === null || _this$controller$vreo === void 0 ? void 0 : _this$controller$vreo.keyframes.forEach(function (keyframe) {
|
|
248
|
+
if (keyframe.type === _VreoUnit.VreoKeyframeEnum.BgMusic) {
|
|
249
|
+
keyframe.parsed = false;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
236
252
|
return true;
|
|
237
253
|
}
|
|
238
254
|
}, {
|
|
@@ -263,7 +279,6 @@ var Player = /*#__PURE__*/function (_Subscribe) {
|
|
|
263
279
|
}, {
|
|
264
280
|
key: "dispose",
|
|
265
281
|
value: function dispose() {
|
|
266
|
-
this.pause();
|
|
267
282
|
this.controller.dispose();
|
|
268
283
|
if (this.configs.container) {
|
|
269
284
|
ReactDOM.unmountComponentAtNode(this.configs.container);
|
|
@@ -273,4 +288,4 @@ var Player = /*#__PURE__*/function (_Subscribe) {
|
|
|
273
288
|
return Player;
|
|
274
289
|
}(_five.Subscribe);
|
|
275
290
|
exports.Player = Player;
|
|
276
|
-
console.log("\n\
|
|
291
|
+
console.log("\n \u250F\u2501\u2501\u2501\u2513\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u250F\u2513\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n \u2503\u250F\u2501\u2513\u2503\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2503\u2503\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n \u2503\u2517\u2501\u251B\u2503\u250F\u2501\u2501\u2513\u250F\u2501\u2501\u2513\u2501\u2503\u2503\u2501\u250F\u2501\u2501\u2513\u250F\u2501\u2501\u2513\u250F\u2501\u2501\u2513\n \u2503\u250F\u2513\u250F\u251B\u2503\u250F\u2513\u2503\u2517\u2501\u2513\u2503\u2501\u2503\u2503\u2501\u2503\u2501\u2501\u252B\u2503\u250F\u2513\u2503\u2503\u250F\u2513\u2503\n \u2503\u2503\u2503\u2517\u2513\u2503\u2503\u2501\u252B\u2503\u2517\u251B\u2517\u2513\u2503\u2517\u2513\u2523\u2501\u2501\u2503\u2503\u2503\u2501\u252B\u2503\u2503\u2501\u252B\n \u2517\u251B\u2517\u2501\u251B\u2517\u2501\u2501\u251B\u2517\u2501\u2501\u2501\u251B\u2517\u2501\u251B\u2517\u2501\u2501\u251B\u2517\u2501\u2501\u251B\u2517\u2501\u2501\u251B\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import AudioLike from '../../../shared-utils/
|
|
2
|
+
import AudioLike from '../../../shared-utils/AudioLike';
|
|
3
3
|
export interface VideoAgentMeshOptions {
|
|
4
4
|
/**
|
|
5
5
|
* 自定义视频实例。
|
|
@@ -40,7 +40,7 @@ export declare class VideoAgentMesh extends THREE.Mesh {
|
|
|
40
40
|
private update;
|
|
41
41
|
play(videoUrl?: string, currentTime?: number, duration?: number): Promise<unknown>;
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
43
|
+
* 秒转成毫秒,保障精准度
|
|
44
44
|
*/
|
|
45
45
|
get currentTime(): number;
|
|
46
46
|
dispose(): void;
|
|
@@ -8,7 +8,7 @@ exports.VideoAgentMesh = void 0;
|
|
|
8
8
|
var THREE = _interopRequireWildcard(require("three"));
|
|
9
9
|
var _Preloader = require("../../../shared-utils/Preloader");
|
|
10
10
|
var _mobx = require("mobx");
|
|
11
|
-
var
|
|
11
|
+
var _AudioLike = _interopRequireDefault(require("../../../shared-utils/AudioLike"));
|
|
12
12
|
var _getMediaInfo = require("../../../shared-utils/getMediaInfo");
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
14
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -46,7 +46,7 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
46
46
|
* @param options
|
|
47
47
|
*/
|
|
48
48
|
function VideoAgentMesh(width, height, widthSegments, heightSegments) {
|
|
49
|
-
var _this$options$videoIn, _this$options$videoIn2
|
|
49
|
+
var _this$options$videoIn, _this$options$videoIn2;
|
|
50
50
|
var _this;
|
|
51
51
|
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
|
52
52
|
preload: true
|
|
@@ -103,7 +103,7 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
103
103
|
} else {
|
|
104
104
|
_this.audioInstance = options.audioInstance;
|
|
105
105
|
}
|
|
106
|
-
_this.audioLikeInstance = new
|
|
106
|
+
_this.audioLikeInstance = new _AudioLike["default"]();
|
|
107
107
|
(0, _mobx.makeObservable)(_assertThisInitialized(_this), {
|
|
108
108
|
paused: _mobx.observable
|
|
109
109
|
});
|
|
@@ -118,25 +118,20 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
118
118
|
var onPlay = function onPlay() {
|
|
119
119
|
return updatePaused(false);
|
|
120
120
|
};
|
|
121
|
-
var onEnded = function onEnded() {
|
|
122
|
-
return console.log('vreo: video 播放结束');
|
|
123
|
-
};
|
|
124
121
|
_this.audioInstance.addEventListener('pause', onPause);
|
|
125
122
|
_this.audioInstance.addEventListener('play', onPlay);
|
|
126
123
|
(_this$options$videoIn = _this.options.videoInstance) === null || _this$options$videoIn === void 0 ? void 0 : _this$options$videoIn.addEventListener('pause', onPause);
|
|
127
124
|
(_this$options$videoIn2 = _this.options.videoInstance) === null || _this$options$videoIn2 === void 0 ? void 0 : _this$options$videoIn2.addEventListener('play', onPlay);
|
|
128
125
|
_this.audioLikeInstance.addEventListener('pause', onPause);
|
|
129
126
|
_this.audioLikeInstance.addEventListener('play', onPlay);
|
|
130
|
-
(_this$options$videoIn3 = _this.options.videoInstance) === null || _this$options$videoIn3 === void 0 ? void 0 : _this$options$videoIn3.addEventListener('ended', onEnded);
|
|
131
127
|
_this.$removeEventListener = function () {
|
|
132
|
-
var _this$options$
|
|
128
|
+
var _this$options$videoIn3, _this$options$videoIn4;
|
|
133
129
|
_this.audioInstance.removeEventListener('pause', onPause);
|
|
134
130
|
_this.audioInstance.removeEventListener('play', onPlay);
|
|
135
|
-
(_this$options$
|
|
136
|
-
(_this$options$
|
|
131
|
+
(_this$options$videoIn3 = _this.options.videoInstance) === null || _this$options$videoIn3 === void 0 ? void 0 : _this$options$videoIn3.removeEventListener('pause', onPause);
|
|
132
|
+
(_this$options$videoIn4 = _this.options.videoInstance) === null || _this$options$videoIn4 === void 0 ? void 0 : _this$options$videoIn4.removeEventListener('play', onPlay);
|
|
137
133
|
_this.audioLikeInstance.removeEventListener('pause', onPause);
|
|
138
134
|
_this.audioLikeInstance.removeEventListener('play', onPlay);
|
|
139
|
-
(_this$options$videoIn6 = _this.options.videoInstance) === null || _this$options$videoIn6 === void 0 ? void 0 : _this$options$videoIn6.removeEventListener('ended', onEnded);
|
|
140
135
|
};
|
|
141
136
|
return _this;
|
|
142
137
|
}
|
|
@@ -320,7 +315,7 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
|
320
315
|
return play;
|
|
321
316
|
}()
|
|
322
317
|
/**
|
|
323
|
-
*
|
|
318
|
+
* 秒转成毫秒,保障精准度
|
|
324
319
|
*/
|
|
325
320
|
}, {
|
|
326
321
|
key: "currentTime",
|
|
@@ -24,7 +24,7 @@ function VideoAgent(props) {
|
|
|
24
24
|
var _controller$videoAgen;
|
|
25
25
|
if (showAvatar) return false;
|
|
26
26
|
return ((_controller$videoAgen = controller.videoAgentScene) === null || _controller$videoAgen === void 0 ? void 0 : _controller$videoAgen.videoAgentMesh.mediaInstance) instanceof HTMLVideoElement;
|
|
27
|
-
}, [controller.videoAgentScene]);
|
|
27
|
+
}, [controller.videoAgentScene, showAvatar]);
|
|
28
28
|
React.useEffect(function () {
|
|
29
29
|
if (!ref.current) throw new Error('React 渲染异常,请稍后重试 ...');
|
|
30
30
|
if (controller.videoAgentScene) {
|