@realsee/vreo 1.0.0-alpha.8 → 1.1.0-dev.0

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 (132) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/README.md +46 -36
  3. package/lib/PlayController/index.js +1 -1
  4. package/lib/Player/Controller.d.ts +3 -2
  5. package/lib/Player/Controller.js +31 -14
  6. package/lib/Player/index.js +27 -16
  7. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +2 -2
  8. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +7 -12
  9. package/lib/Player/modules/VideoAgent/index.js +1 -1
  10. package/lib/Player/modules/Wave/index.js +160 -25
  11. package/lib/Player/modules/keyframes/BgMusic/index.js +52 -40
  12. package/lib/Player/modules/keyframes/PanoTag/index.js +1 -0
  13. package/lib/fivePlugins/CameraMovementPlugin/index.js +3 -2
  14. package/lib/shared-utils/Audio.d.ts +14 -0
  15. package/lib/shared-utils/Audio.js +158 -0
  16. package/lib/shared-utils/{AduioLike.d.ts → AudioLike.d.ts} +0 -0
  17. package/lib/shared-utils/{AduioLike.js → AudioLike.js} +4 -6
  18. package/lib/shared-utils/animationFrame/tween.d.ts +3 -58
  19. package/lib/shared-utils/animationFrame/tween.js +3 -9
  20. package/lib/typings/VreoUnit.d.ts +8 -5
  21. package/package.json +8 -6
  22. package/stylesheets/default.css +9 -2
  23. package/docs/.nojekyll +0 -1
  24. package/docs/assets/custom.css +0 -78
  25. package/docs/assets/highlight.css +0 -127
  26. package/docs/assets/icons.css +0 -1043
  27. package/docs/assets/icons.png +0 -0
  28. package/docs/assets/icons@2x.png +0 -0
  29. package/docs/assets/main.js +0 -52
  30. package/docs/assets/search.js +0 -1
  31. package/docs/assets/style.css +0 -1414
  32. package/docs/assets/widgets.png +0 -0
  33. package/docs/assets/widgets@2x.png +0 -0
  34. package/docs/classes/Player.AudioLike.html +0 -52
  35. package/docs/classes/Player.Controller.html +0 -54
  36. package/docs/classes/Player.Player-1.html +0 -50
  37. package/docs/classes/Player.VideoAgentMesh.html +0 -142
  38. package/docs/classes/Player.VideoAgentScene.html +0 -1
  39. package/docs/demo/assets/AppReact.6a524c19.js +0 -1
  40. package/docs/demo/assets/default.361f7c9c.js +0 -3988
  41. package/docs/demo/assets/default.63ebc790.css +0 -1
  42. package/docs/demo/assets/dynamic.dc5a9120.js +0 -1
  43. package/docs/demo/assets/examples.a3b2ec8a.js +0 -25
  44. package/docs/demo/assets/examples.dac4a6fe.css +0 -1
  45. package/docs/demo/assets/index.12496cce.js +0 -1
  46. package/docs/demo/assets/index.9331038f.css +0 -1
  47. package/docs/demo/assets/main.b05c3bb6.js +0 -1
  48. package/docs/demo/assets/react.2ee8565f.css +0 -1
  49. package/docs/demo/assets/react.61c6e2de.js +0 -25
  50. package/docs/demo/assets/znRoyv06SZQeqA7m.0057e8ae.js +0 -1
  51. package/docs/demo/examples.html +0 -17
  52. package/docs/demo/index-react-dynamic.html +0 -20
  53. package/docs/demo/index-react.html +0 -20
  54. package/docs/demo/index.html +0 -19
  55. package/docs/enums/Player.InfoPanelStyleEnum.html +0 -1
  56. package/docs/enums/Player.InfoPanelTypeEnum.html +0 -3
  57. package/docs/enums/Player.PanoEffectEnum.html +0 -5
  58. package/docs/enums/Player.PanoTagEnum.html +0 -3
  59. package/docs/enums/Player.PanoTagStyleEnum.html +0 -7
  60. package/docs/enums/Player.VreoKeyframeEnum.html +0 -25
  61. package/docs/enums/fivePlugins.CameraMovementEffect.html +0 -1
  62. package/docs/enums/fivePlugins.Rotation.html +0 -1
  63. package/docs/index.html +0 -245
  64. package/docs/interfaces/Player.CustomVreoKeyframeProps.html +0 -1
  65. package/docs/interfaces/Player.PlayerConfigs.html +0 -7
  66. package/docs/interfaces/Player.Vertex.html +0 -3
  67. package/docs/interfaces/Player.VideoAgentMeshOptions.html +0 -8
  68. package/docs/interfaces/Player.VreoKeyframe.html +0 -3
  69. package/docs/interfaces/Player.VreoUnit.html +0 -3
  70. package/docs/interfaces/Player.VreoVideo.html +0 -3
  71. package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +0 -4
  72. package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +0 -1
  73. package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +0 -7
  74. package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +0 -1
  75. package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +0 -1
  76. package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +0 -1
  77. package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +0 -1
  78. package/docs/interfaces/fivePlugins.Vector3Position.html +0 -3
  79. package/docs/interfaces/react.VreoActionCallbacks.html +0 -23
  80. package/docs/interfaces/react.VreoProviderProps.html +0 -1
  81. package/docs/modules/Player.html +0 -37
  82. package/docs/modules/custom.html +0 -3
  83. package/docs/modules/fivePlugins.html +0 -6
  84. package/docs/modules/react.html +0 -1
  85. package/docs/modules.html +0 -1
  86. package/resources/PlayController/createHTMLAudioElement.ts +0 -53
  87. package/resources/PlayController/index.ts +0 -154
  88. package/resources/Player/App.tsx +0 -66
  89. package/resources/Player/Controller.ts +0 -294
  90. package/resources/Player/custom/SpatialScenePanel/index.tsx +0 -264
  91. package/resources/Player/hooks.ts +0 -26
  92. package/resources/Player/index.tsx +0 -227
  93. package/resources/Player/modules/Drawer/index.tsx +0 -40
  94. package/resources/Player/modules/PopUp/index.tsx +0 -26
  95. package/resources/Player/modules/ResizeObserver/index.tsx +0 -23
  96. package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +0 -302
  97. package/resources/Player/modules/VideoAgent/VideoAgentScene.ts +0 -56
  98. package/resources/Player/modules/VideoAgent/index.tsx +0 -53
  99. package/resources/Player/modules/Wave/index.tsx +0 -18
  100. package/resources/Player/modules/keyframes/BgMusic/index.tsx +0 -66
  101. package/resources/Player/modules/keyframes/CameraMovement/index.tsx +0 -37
  102. package/resources/Player/modules/keyframes/InfoPanel/index.tsx +0 -165
  103. package/resources/Player/modules/keyframes/ModelVideo/index.tsx +0 -77
  104. package/resources/Player/modules/keyframes/PanoEffect/index.tsx +0 -99
  105. package/resources/Player/modules/keyframes/PanoEffect/lineAnime.ts +0 -31
  106. package/resources/Player/modules/keyframes/PanoTag/index.tsx +0 -82
  107. package/resources/Player/modules/keyframes/PanoTextLabel/index.tsx +0 -117
  108. package/resources/Player/modules/keyframes/Prompter/index.tsx +0 -56
  109. package/resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx +0 -99
  110. package/resources/Player/modules/keyframes/VideoEffect/index.tsx +0 -115
  111. package/resources/Player/typings.ts +0 -49
  112. package/resources/fivePlugins/CSS3DRenderPlugin/centerPoint.ts +0 -5
  113. package/resources/fivePlugins/CSS3DRenderPlugin/createResizeObserver.ts +0 -17
  114. package/resources/fivePlugins/CSS3DRenderPlugin/evenNumber.ts +0 -4
  115. package/resources/fivePlugins/CSS3DRenderPlugin/index.ts +0 -254
  116. package/resources/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.ts +0 -5
  117. package/resources/fivePlugins/CameraMovementPlugin/index.ts +0 -226
  118. package/resources/fivePlugins/CameraMovementPlugin/typings.ts +0 -59
  119. package/resources/fivePlugins/ModelTVVideoPlugin/index.ts +0 -278
  120. package/resources/index.ts +0 -1
  121. package/resources/react/index.tsx +0 -121
  122. package/resources/shared-utils/AduioLike.ts +0 -109
  123. package/resources/shared-utils/Preloader.ts +0 -35
  124. package/resources/shared-utils/addResizeListener.ts +0 -46
  125. package/resources/shared-utils/animationFrame/BetterTween.ts +0 -33
  126. package/resources/shared-utils/animationFrame/index.ts +0 -48
  127. package/resources/shared-utils/animationFrame/tween.ts +0 -51
  128. package/resources/shared-utils/createTransMatrix.ts +0 -12
  129. package/resources/shared-utils/getFileExpandedName.ts +0 -6
  130. package/resources/shared-utils/getMediaInfo.ts +0 -52
  131. package/resources/shared-utils/setElementDataset.ts +0 -18
  132. package/resources/typings/VreoUnit.ts +0 -314
@@ -1,154 +0,0 @@
1
- import { Subscribe } from '@realsee/five'
2
- import { requestAnimationFrameInterval } from '../shared-utils/animationFrame'
3
- import { VreoKeyframe, VreoKeyframeEvent, VreoUnit } from '../typings/VreoUnit'
4
- import { createHTMLAudioElement } from './createHTMLAudioElement'
5
-
6
- export interface PlayControllerConfig {
7
- audio?: HTMLAudioElement
8
- }
9
-
10
- const closures: Record<string, any> = {}
11
-
12
- export class PlayController extends Subscribe<VreoKeyframeEvent> {
13
-
14
- vreoUnit?: VreoUnit
15
-
16
- config: PlayControllerConfig = {}
17
- stopInterval: () => void
18
-
19
- get paused() {
20
- return this.audioInstance.paused
21
- }
22
-
23
- get audioInstance() {
24
- return this.config.audio!
25
- }
26
-
27
- get currentTime() {
28
- return this.audioInstance.currentTime * 1000
29
- }
30
-
31
- get currentKeyframes() {
32
- if (!this.vreoUnit) return []
33
- const keyframes = this.vreoUnit.keyframes
34
- // 没有被解析过且开始时间低于当前时间戳 100ms
35
- return keyframes.filter((keyframe: VreoKeyframe) => {
36
- if (keyframe.parsed) return false
37
- const dur = this.currentTime - keyframe.start
38
- return dur <= 100 && dur >= 0
39
- })
40
- }
41
-
42
- /**
43
- * 音频时长 不一定能获取得到,建议以 VreoUnit 配置的时长为准。
44
- */
45
- get duration() {
46
- return this.audioInstance.duration * 1000
47
- }
48
-
49
- constructor(config: PlayControllerConfig = {}) {
50
- super()
51
-
52
- if (!config.audio) {
53
- config.audio = createHTMLAudioElement()
54
- }
55
-
56
- this.config = Object.assign(this.config, config)
57
-
58
- closures.onPlaying = () => this.emit('playing')
59
- closures.onPaused = () => this.emit('paused')
60
- closures.onEnded = () => this.emit('paused', true)
61
-
62
- this.audioInstance.addEventListener('play', closures.onPlaying)
63
- this.audioInstance.addEventListener('pause', closures.onPaused)
64
- this.audioInstance.addEventListener('ended', closures.onEnded)
65
-
66
- this.stopInterval = requestAnimationFrameInterval(() => {
67
- if (this.audioInstance.paused) {
68
- return
69
- }
70
-
71
- if (!this.vreoUnit) {
72
- return
73
- }
74
-
75
- const keyframes = this.vreoUnit.keyframes
76
- const currentTime = this.currentTime
77
- // 没有被解析过且开始时间低于当前时间戳 100ms
78
- const currentKeyframes = keyframes.filter((keyframe: VreoKeyframe) => {
79
- if (keyframe.parsed) return false
80
-
81
- const dur = currentTime - keyframe.start
82
- return dur <= 60 && dur >= 0
83
- })
84
-
85
- currentKeyframes.forEach((keyframe) => {
86
- if (keyframe.parsed) return
87
- keyframe.parsed = true
88
- this.emit(keyframe.type, keyframe)
89
- })
90
- })
91
-
92
- }
93
-
94
-
95
-
96
- /**
97
- * 载入数据
98
- */
99
- async load(vreoUnit: VreoUnit): Promise<boolean> {
100
- this.vreoUnit = vreoUnit
101
-
102
- await this.pause()
103
- return await new Promise((resolve, reject) => {
104
- if (vreoUnit.video.url === this.audioInstance.src) {
105
- return resolve(true)
106
- }
107
-
108
- this.audioInstance.src = vreoUnit.video.url
109
- const canplaythrough = () => {
110
- resolve(true)
111
- this.audioInstance.removeEventListener('canplaythrough', canplaythrough)
112
- }
113
- const error = (err: any) => {
114
- reject(err)
115
- this.audioInstance.removeEventListener('error', error)
116
- }
117
- this.audioInstance.addEventListener('canplaythrough', canplaythrough)
118
- this.audioInstance.addEventListener('error', error)
119
- })
120
- }
121
-
122
- /**
123
- * 播放
124
- */
125
- async play() {
126
- closures.playPromise = this.audioInstance.play()
127
- }
128
-
129
- /**
130
- * 暂停
131
- */
132
- async pause() {
133
- if (closures.playPromise) {
134
- await closures.playPromise
135
- }
136
- this.audioInstance.pause()
137
- }
138
-
139
- /**
140
- * 销毁资源
141
- * @notice 一旦销毁,创建的实例将不可用:需重新创建实例。
142
- *
143
- * @deprecated **慎重执行**
144
- */
145
- dispose() {
146
- // 清理事件监听
147
- this.audioInstance.removeEventListener('play', closures.onPlaying)
148
- this.audioInstance.removeEventListener('pasue', closures.onPaused)
149
- this.audioInstance.removeEventListener('ended', closures.onEnded)
150
- if (this.stopInterval) {
151
- this.stopInterval()
152
- }
153
- }
154
- }
@@ -1,66 +0,0 @@
1
- import * as React from 'react'
2
- import classNames from 'classnames'
3
- import { observer } from 'mobx-react'
4
- import { Controller } from './Controller'
5
- import { useController } from './hooks'
6
- import { CameraMovement } from './modules/keyframes/CameraMovement'
7
- import { ResizeObserver } from './modules/ResizeObserver'
8
- import { InfoPanel } from './modules/keyframes/InfoPanel'
9
- import { ModelVideo } from './modules/keyframes/ModelVideo'
10
- import { PanoEffect } from './modules/keyframes/PanoEffect'
11
- import { PanoTag } from './modules/keyframes/PanoTag'
12
- import { PanoTextLabel } from './modules/keyframes/PanoTextLabel'
13
- import { Prompter } from './modules/keyframes/Prompter'
14
- import { UpdateVRPanorama } from './modules/keyframes/UpdateVRPanorama'
15
- import { VideoEffect } from './modules/keyframes/VideoEffect'
16
- import { VideoAgent } from './modules/VideoAgent'
17
- import { BgMusic } from './modules/keyframes/BgMusic'
18
- import { Wave } from './modules/Wave'
19
-
20
- const AppView = observer(({ controller }: { controller: Controller }) => {
21
-
22
- return (
23
- <div
24
- className={classNames('vreo-panel', {
25
- 'vreo-panel--hidden': !controller.visible,
26
- })}
27
- >
28
- <div className="vreo-panel-inner">
29
- {controller.waveAppearance && <Wave appearance={controller.waveAppearance}/>}
30
- <VideoAgent
31
- onClick={() => {
32
- if (controller.playing) {
33
- controller.setPlaying(false)
34
- } else {
35
- controller.setPlaying(true)
36
- }
37
- }}
38
- options={controller.configs?.videoAgentMeshOptions || {}}
39
- />
40
- <Prompter />
41
- {controller.configs?.customPanelChildren}
42
- </div>
43
- </div>
44
- )
45
- })
46
-
47
- export function App() {
48
- const controller = useController()
49
- return (
50
- <>
51
- <>
52
- <ResizeObserver />
53
- <CameraMovement />
54
- <ModelVideo />
55
- <UpdateVRPanorama />
56
- <VideoEffect />
57
- <PanoTag />
58
- <PanoTextLabel />
59
- <InfoPanel />
60
- <PanoEffect />
61
- <BgMusic />
62
- </>
63
- <AppView controller={controller} />
64
- </>
65
- )
66
- }
@@ -1,294 +0,0 @@
1
- import { Five, Subscribe } from '@realsee/five'
2
- import { action, computed, makeObservable, observable, reaction } from 'mobx'
3
- import * as React from 'react'
4
- import { requestAnimationFrameInterval } from '../shared-utils/animationFrame'
5
- import { VreoKeyframe, VreoKeyframeEnum, VreoKeyframeEvent, VreoUnit, VreoVideo } from '../typings/VreoUnit'
6
- import { VideoAgentScene } from './modules/VideoAgent/VideoAgentScene'
7
- import { Appearance, PlayerConfigs, WaveAppearance } from './typings'
8
- import setElementDataset from '../shared-utils/setElementDataset'
9
- import { getMediaType } from '../shared-utils/getMediaInfo'
10
-
11
- /**
12
- * 逻辑控制器:内部状态。
13
- */
14
- export class Controller extends Subscribe<VreoKeyframeEvent> {
15
-
16
- five: Five
17
- configs: PlayerConfigs
18
- videoAgentScene?: VideoAgentScene
19
- vreoUnit?: VreoUnit
20
- stopInterval?: () => void
21
- playing = false
22
- ended = false
23
- loading: boolean | null = false // null 表示加载失败
24
- containerSize: { width: number, height: number } = { width: 0, height: 0 }
25
- appSize?: 'S' | 'M' | 'L' | 'XL'
26
- container: Element
27
- waveAppearance: WaveAppearance | null = null
28
- appearance: Appearance = {
29
- waveStyle: 'wave',
30
- }
31
- avatar: VreoVideo['avatar'] = {}
32
-
33
-
34
- visible = false
35
-
36
- get agentType() {
37
- const type = getMediaType(this.videoAgentScene?.videoAgentMesh.videoUrl)
38
- if (this.avatar?.force) return 'avatar'
39
- if (type === 'video') return 'video'
40
- return 'none'
41
- }
42
-
43
- popUp: string | JSX.Element | null = null
44
-
45
- openPopUp(popUp: string | JSX.Element | false) {
46
- if (!popUp) {
47
- this.popUp = null
48
- return
49
- }
50
- this.popUp = popUp
51
- }
52
-
53
- setLoading(loading: boolean | null) {
54
- this.loading = loading
55
- }
56
-
57
- drawerConfig: {
58
- content: string | JSX.Element
59
- height?: number | string
60
- } | null = null
61
-
62
- setAvatar(avatar: VreoVideo['avatar']) {
63
- this.avatar = avatar
64
- }
65
-
66
- setContainerSize(width: number, height: number) {
67
- this.containerSize = { width, height }
68
- }
69
-
70
- setVisible(v: boolean) {
71
- this.visible = v
72
- }
73
-
74
- setPlaying(playing: boolean) {
75
- this.playing = playing
76
- }
77
-
78
- setEnded(ended: boolean) {
79
- this.ended = ended
80
- }
81
-
82
- setAppearance(appearance: Appearance) {
83
- this.appearance = { ...this.appearance, ...appearance }
84
- }
85
-
86
- openDrawer(drawerConfig?: false | { content: string | JSX.Element; height?: number | string }) {
87
- if (!drawerConfig) {
88
- this.drawerConfig = {
89
- content: '',
90
- height: this.drawerConfig?.height
91
- }
92
- return
93
- }
94
-
95
- this.drawerConfig = drawerConfig
96
- }
97
-
98
- constructor({five, container, configs}: { five: Five, container: Element, configs: PlayerConfigs }) {
99
- super()
100
-
101
- this.configs = configs
102
- this.container = container
103
- this.five = five
104
- this.appSize = configs.appSize
105
- this.appearance = { ...this.appearance, ...configs.appearance }
106
-
107
- makeObservable(this, {
108
- visible: observable,
109
- setVisible: action,
110
- playing: observable,
111
- setPlaying: action,
112
- loading: observable,
113
- setLoading: action,
114
- popUp: observable.ref,
115
- openPopUp: action,
116
- drawerConfig: observable.ref,
117
- openDrawer: action,
118
- ended: observable,
119
- waveAppearance: observable,
120
- avatar: observable,
121
- containerSize: observable,
122
- setContainerSize: action,
123
- appearance: observable,
124
- setAppearance: action,
125
- configs: observable.ref,
126
- setEnded: action,
127
- setAvatar: action,
128
- })
129
-
130
- reaction<[typeof this.appearance.waveStyle, boolean | null], boolean>(
131
- () => [this.appearance.waveStyle, this.loading],
132
- ([waveStyle, loading]) => {
133
- if (loading === null) {
134
- this.waveAppearance = null
135
- return
136
- }
137
- if (waveStyle === 'wave') {
138
- switch (loading) {
139
- case true:
140
- this.waveAppearance = 'double'
141
- break
142
- case false:
143
- this.waveAppearance = 'solid'
144
- break
145
- }
146
- } else if (waveStyle === 'solid') {
147
- switch (loading) {
148
- case true:
149
- this.waveAppearance = 'swap'
150
- break
151
- case false:
152
- this.waveAppearance = 'expand'
153
- break
154
- }
155
- }
156
- },
157
- { fireImmediately: true }
158
- )
159
-
160
- if (!this.appSize) {
161
- reaction(
162
- () => this.containerSize,
163
- (containerSize) => {
164
- if (!containerSize?.width) return
165
- const width = containerSize.width
166
- const height = containerSize.height
167
- const size = (() => {
168
- if (width <= 500) return 'S'
169
- if (width <= 1024) return 'M'
170
- if (width <= 2048) return 'L'
171
- return 'XL'
172
- })()
173
- const orientation = (() => {
174
- if (height > width) return 'portrait'
175
- return 'landscape'
176
- })()
177
- setElementDataset(this.container, { size })
178
- setElementDataset(this.container, { orientation })
179
- },
180
- { fireImmediately: true }
181
- )
182
- } else {
183
- setElementDataset(this.container, { size: this.appSize })
184
- }
185
-
186
- // 监听播放情况:抛出触发时机
187
- reaction(
188
- () => this.ended,
189
- (ended) => {
190
- if (ended) {
191
- this.emit('paused', true)
192
- }
193
- }
194
- )
195
-
196
- reaction(
197
- () => this.playing,
198
- (playing) => {
199
- if (!this.ended) {
200
- this.emit(playing ? 'playing' : 'paused')
201
- }
202
- }
203
- )
204
-
205
- }
206
-
207
- get ready() {
208
- return !!this.videoAgentScene
209
- }
210
-
211
- get currentTime() {
212
- return this.videoAgentScene?.videoAgentMesh.currentTime || 0
213
- }
214
-
215
- get currentKeyframes() {
216
- if (!this.vreoUnit) return []
217
- const keyframes = this.vreoUnit.keyframes
218
- // 没有被解析过且开始时间低于当前时间戳 100ms
219
- return keyframes.filter((keyframe: VreoKeyframe) => {
220
- if (keyframe.parsed) return false
221
- const dur = this.currentTime - keyframe.start
222
- return dur <= 100 && dur >= 0
223
- })
224
- }
225
-
226
- get mediaInstance() {
227
- return this.videoAgentScene?.videoAgentMesh.mediaInstance
228
- }
229
-
230
- /**
231
- * 逐帧任务
232
- */
233
- requestAnimationFrameLoop(callback: (type: VreoKeyframeEnum, keyframe: VreoKeyframe) => void) {
234
- if (this.mediaInstance?.ended) {
235
- this.setEnded(true)
236
- this.setPlaying(false)
237
- this.mediaInstance.pause()
238
- return
239
- }
240
-
241
- if (!this.playing) {
242
- if (!this.mediaInstance?.paused) {
243
- this.mediaInstance?.pause()
244
- }
245
- return
246
- }
247
-
248
- if (this.mediaInstance?.paused && this.playing) {
249
- this.mediaInstance.play()
250
- }
251
-
252
- const currentKeyframes = this.currentKeyframes
253
-
254
- currentKeyframes.forEach((keyframe) => {
255
- if (keyframe.parsed) return
256
- keyframe.parsed = true
257
- this.emit(keyframe.type, keyframe)
258
- if (callback) {
259
- callback(keyframe.type, keyframe)
260
- }
261
- })
262
- }
263
-
264
- run(callback: (type: VreoKeyframeEnum, keyframe: VreoKeyframe) => void) {
265
- if (this.stopInterval) return
266
- this.stopInterval = requestAnimationFrameInterval(() => this.requestAnimationFrameLoop(callback))
267
- }
268
-
269
- dispose() {
270
- this.setPlaying(false)
271
-
272
- if (this.currentKeyframes) {
273
- this.currentKeyframes.forEach((keyframe) => (keyframe.parsed = false))
274
- }
275
-
276
- /**
277
- * 清理掉数据
278
- */
279
- this.vreoUnit = undefined
280
- if (this.mediaInstance) {
281
- this.mediaInstance.currentTime = 0
282
- }
283
-
284
- if (this.stopInterval) {
285
- this.stopInterval()
286
- this.stopInterval = undefined
287
- }
288
- }
289
- }
290
-
291
- const ControllerContext = React.createContext<Controller | null>(null)
292
-
293
- export { ControllerContext }
294
-