@realsee/vreo 2.6.4-alpha.2 → 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.
package/lib/Player/App.js CHANGED
@@ -36,9 +36,9 @@ var AppView = observer(function (_ref) {
36
36
  return;
37
37
  }
38
38
  if (controller.playing) {
39
- controller.audioFocus.cancel('paused');
39
+ controller.playback.cancel();
40
40
  } else {
41
- if (controller.audioFocus.acquire('user')) controller.setPlaying(true);
41
+ if (controller.playback.begin(true)) controller.setPlaying(true);
42
42
  }
43
43
  },
44
44
  options: ((_controller$configs3 = controller.configs) === null || _controller$configs3 === void 0 ? void 0 : _controller$configs3.videoAgentMeshOptions) || {}
@@ -1,4 +1,4 @@
1
- import { NarrationAudioFocus } from './AudioFocus';
1
+ import { PlaybackLifecycle } from './PlaybackLifecycle';
2
2
  import { Five, Subscribe } from '@realsee/five';
3
3
  import * as React from 'react';
4
4
  import { VreoKeyframe, VreoKeyframeEnum, VreoKeyframeEvent, VreoUnit, VreoVideo } from '../typings/VreoUnit';
@@ -56,7 +56,7 @@ export declare class Controller extends Subscribe<VreoKeyframeEvent> {
56
56
  * 获取当前播放媒体的类型
57
57
  * @returns 'video' | 'avatar' | 'none' - 媒体类型
58
58
  */
59
- get agentType(): "video" | "none" | "avatar";
59
+ get agentType(): "none" | "video" | "avatar";
60
60
  popUp: string | JSX.Element | null;
61
61
  /**
62
62
  * 打开或关闭弹窗
@@ -126,7 +126,7 @@ export declare class Controller extends Subscribe<VreoKeyframeEvent> {
126
126
  private resumeGeneration;
127
127
  private resuming;
128
128
  private disposers;
129
- readonly audioFocus: NarrationAudioFocus;
129
+ readonly playback: PlaybackLifecycle;
130
130
  constructor({ five, container, configs }: {
131
131
  five: Five;
132
132
  container: Element;
@@ -9,7 +9,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
9
9
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
12
- import { NarrationAudioFocus } from "./AudioFocus.js";
12
+ import { PlaybackLifecycle } from "./PlaybackLifecycle.js";
13
13
  import { Subscribe } from '@realsee/five';
14
14
  import { action, makeObservable, observable, reaction } from 'mobx';
15
15
  import * as React from 'react';
@@ -79,7 +79,7 @@ export var Controller = /*#__PURE__*/function (_Subscribe) {
79
79
  */
80
80
  _defineProperty(_this, "resumeGeneration", 0);
81
81
  _defineProperty(_this, "disposers", []);
82
- _this.audioFocus = new NarrationAudioFocus(configs.audioFocus, function () {
82
+ _this.playback = new PlaybackLifecycle(configs.mediaManager, function () {
83
83
  var _this$videoAgentScene;
84
84
  _this.resuming = undefined;
85
85
  ++_this.resumeGeneration;
@@ -284,7 +284,7 @@ export var Controller = /*#__PURE__*/function (_Subscribe) {
284
284
  }, {
285
285
  key: "setPlaying",
286
286
  value: function setPlaying(playing) {
287
- if (playing && !this.audioFocus.active) return;
287
+ if (playing && !this.playback.active) return;
288
288
  this.playing = playing;
289
289
  if (playing) this.resumeMedia();
290
290
  }
@@ -397,45 +397,47 @@ export var Controller = /*#__PURE__*/function (_Subscribe) {
397
397
  }, {
398
398
  key: "requestAnimationFrameLoop",
399
399
  value: function requestAnimationFrameLoop(callback) {
400
- var _this$mediaInstance3,
400
+ var _this$mediaInstance2,
401
401
  _this3 = this;
402
402
  // 如果正在等待背景音乐加载,暂停整个播放流程
403
403
  if (this.waitingForBgMusic) {
404
404
  var _this$mediaInstance;
405
405
  if (!((_this$mediaInstance = this.mediaInstance) !== null && _this$mediaInstance !== void 0 && _this$mediaInstance.paused)) {
406
- var _this$mediaInstance2;
407
- (_this$mediaInstance2 = this.mediaInstance) === null || _this$mediaInstance2 === void 0 || _this$mediaInstance2.pause();
406
+ var _this$videoAgentScene5;
407
+ (_this$videoAgentScene5 = this.videoAgentScene) === null || _this$videoAgentScene5 === void 0 || (_this$videoAgentScene5 = _this$videoAgentScene5.videoAgentMesh.mediaOperations) === null || _this$videoAgentScene5 === void 0 || _this$videoAgentScene5.pause();
408
408
  }
409
409
  return;
410
410
  }
411
- if ((_this$mediaInstance3 = this.mediaInstance) !== null && _this$mediaInstance3 !== void 0 && _this$mediaInstance3.ended && this.mediaInstance.currentTime !== 0) {
412
- var _this$vreoUnit;
411
+ if ((_this$mediaInstance2 = this.mediaInstance) !== null && _this$mediaInstance2 !== void 0 && _this$mediaInstance2.ended && this.mediaInstance.currentTime !== 0) {
412
+ var _this$vreoUnit, _this$videoAgentScene6;
413
413
  if (this.ended) return;
414
414
  (_this$vreoUnit = this.vreoUnit) === null || _this$vreoUnit === void 0 || _this$vreoUnit.keyframes.forEach(function (keyframe) {
415
415
  return keyframe.parsed = false;
416
416
  });
417
- this.audioFocus.cancel('paused');
417
+ var media = (_this$videoAgentScene6 = this.videoAgentScene) === null || _this$videoAgentScene6 === void 0 ? void 0 : _this$videoAgentScene6.videoAgentMesh.mediaOperations;
418
+ media === null || media === void 0 || media.pause();
419
+ if (media) media.currentTime = 0;
420
+ this.playback.finish();
418
421
  this.setEnded(true);
419
422
  this.setPlaying(false);
420
- this.mediaInstance.pause();
421
- this.mediaInstance.currentTime = 0;
422
423
  return;
423
424
  }
424
425
  if (!this.playing) {
425
- var _this$mediaInstance4;
426
- if (!((_this$mediaInstance4 = this.mediaInstance) !== null && _this$mediaInstance4 !== void 0 && _this$mediaInstance4.paused)) {
427
- var _this$mediaInstance5;
428
- (_this$mediaInstance5 = this.mediaInstance) === null || _this$mediaInstance5 === void 0 || _this$mediaInstance5.pause();
426
+ var _this$mediaInstance3;
427
+ if (!((_this$mediaInstance3 = this.mediaInstance) !== null && _this$mediaInstance3 !== void 0 && _this$mediaInstance3.paused)) {
428
+ var _this$videoAgentScene7;
429
+ (_this$videoAgentScene7 = this.videoAgentScene) === null || _this$videoAgentScene7 === void 0 || (_this$videoAgentScene7 = _this$videoAgentScene7.videoAgentMesh.mediaOperations) === null || _this$videoAgentScene7 === void 0 || _this$videoAgentScene7.pause();
429
430
  }
430
431
  return;
431
432
  }
432
433
  this.resumeMedia();
433
434
  var currentKeyframes = this.currentKeyframes;
435
+ var run = this.playback.capture();
434
436
  currentKeyframes.forEach(function (keyframe) {
435
- if (keyframe.parsed) return;
437
+ if (!(run !== null && run !== void 0 && run.valid()) || keyframe.parsed) return;
436
438
  keyframe.parsed = true;
437
439
  _this3.emit(keyframe.type, keyframe, _this3.currentTime);
438
- if (callback) {
440
+ if (callback && run.valid()) {
439
441
  callback(keyframe.type, keyframe, _this3.currentTime);
440
442
  }
441
443
  });
@@ -443,17 +445,20 @@ export var Controller = /*#__PURE__*/function (_Subscribe) {
443
445
  }, {
444
446
  key: "resumeMedia",
445
447
  value: function resumeMedia() {
446
- var _this$mediaInstance6,
448
+ var _this$mediaInstance4,
447
449
  _this4 = this;
448
450
  if (this.waitingForBgMusic) return;
449
- if ((_this$mediaInstance6 = this.mediaInstance) !== null && _this$mediaInstance6 !== void 0 && _this$mediaInstance6.paused && this.playing && !this.resuming) {
450
- var _this$videoAgentScene5;
451
+ if ((_this$mediaInstance4 = this.mediaInstance) !== null && _this$mediaInstance4 !== void 0 && _this$mediaInstance4.paused && this.playing && !this.resuming) {
452
+ var _this$videoAgentScene8;
451
453
  var attempt = ++this.resumeGeneration;
452
454
  this.resuming = attempt;
453
- var valid = this.audioFocus.capture();
454
- void ((_this$videoAgentScene5 = this.videoAgentScene) === null || _this$videoAgentScene5 === void 0 ? void 0 : _this$videoAgentScene5.videoAgentMesh.play().catch(function (error) {
455
+ var run = this.playback.capture();
456
+ var valid = function valid() {
457
+ return !!(run !== null && run !== void 0 && run.valid());
458
+ };
459
+ void ((_this$videoAgentScene8 = this.videoAgentScene) === null || _this$videoAgentScene8 === void 0 ? void 0 : _this$videoAgentScene8.videoAgentMesh.play().catch(function (error) {
455
460
  if (valid()) {
456
- _this4.audioFocus.cancel('paused');
461
+ _this4.playback.cancel();
457
462
  console.error(error);
458
463
  }
459
464
  }).finally(function () {
@@ -497,8 +502,9 @@ export var Controller = /*#__PURE__*/function (_Subscribe) {
497
502
  */
498
503
  this.vreoUnit = undefined;
499
504
  if (this.mediaInstance) {
500
- this.mediaInstance.pause();
501
- this.mediaInstance.currentTime = 0;
505
+ var _this$videoAgentScene9, _this$videoAgentScene0;
506
+ (_this$videoAgentScene9 = this.videoAgentScene) === null || _this$videoAgentScene9 === void 0 || (_this$videoAgentScene9 = _this$videoAgentScene9.videoAgentMesh.mediaOperations) === null || _this$videoAgentScene9 === void 0 || _this$videoAgentScene9.pause();
507
+ if ((_this$videoAgentScene0 = this.videoAgentScene) !== null && _this$videoAgentScene0 !== void 0 && _this$videoAgentScene0.videoAgentMesh.mediaOperations) this.videoAgentScene.videoAgentMesh.mediaOperations.currentTime = 0;
502
508
  }
503
509
  (_this$stopInterval = this.stopInterval) === null || _this$stopInterval === void 0 || _this$stopInterval.call(this);
504
510
  this.stopInterval = undefined;
@@ -515,7 +521,7 @@ export var Controller = /*#__PURE__*/function (_Subscribe) {
515
521
  this.disposers.splice(0).forEach(function (dispose) {
516
522
  return dispose();
517
523
  });
518
- this.audioFocus.dispose();
524
+ this.playback.dispose();
519
525
  this.clear();
520
526
  }
521
527
  }]);
@@ -0,0 +1,25 @@
1
+ import type { MediaOperations, PlaybackManager, PlaybackSession } from './playback-types';
2
+ export interface PlaybackRun {
3
+ readonly session?: PlaybackSession;
4
+ readonly mediaManager?: PlaybackManager;
5
+ valid(): boolean;
6
+ bind(element: HTMLMediaElement): MediaOperations;
7
+ }
8
+ /** Local timeline lifetime only. Playback permission is owned by the injected manager. */
9
+ export declare class PlaybackLifecycle {
10
+ private onStop;
11
+ private controller?;
12
+ private run?;
13
+ private generation;
14
+ private disposed;
15
+ private members;
16
+ constructor(manager: PlaybackManager | undefined, onStop: () => void);
17
+ get active(): boolean;
18
+ capture(): PlaybackRun | undefined;
19
+ begin(userAction: boolean): boolean;
20
+ add(stop: () => void): () => void;
21
+ private stop;
22
+ cancel(): void;
23
+ finish(): void;
24
+ dispose(): void;
25
+ }
@@ -0,0 +1,117 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
5
+ /** Local timeline lifetime only. Playback permission is owned by the injected manager. */
6
+ export var PlaybackLifecycle = /*#__PURE__*/function () {
7
+ function PlaybackLifecycle(manager, onStop) {
8
+ var _this = this;
9
+ _classCallCheck(this, PlaybackLifecycle);
10
+ _defineProperty(this, "generation", 0);
11
+ _defineProperty(this, "disposed", false);
12
+ _defineProperty(this, "members", new Set());
13
+ this.onStop = onStop;
14
+ this.controller = manager === null || manager === void 0 ? void 0 : manager.createController({
15
+ label: 'vreo',
16
+ onCancel: function onCancel() {
17
+ return _this.stop();
18
+ }
19
+ });
20
+ }
21
+ return _createClass(PlaybackLifecycle, [{
22
+ key: "active",
23
+ get: function get() {
24
+ var _this$run;
25
+ return !!((_this$run = this.run) !== null && _this$run !== void 0 && _this$run.valid());
26
+ }
27
+ }, {
28
+ key: "capture",
29
+ value: function capture() {
30
+ return this.run;
31
+ }
32
+ }, {
33
+ key: "begin",
34
+ value: function begin(userAction) {
35
+ var _this$controller$begi,
36
+ _this$controller,
37
+ _this2 = this;
38
+ if (this.disposed) return false;
39
+ if (this.active) return true;
40
+ var session = (_this$controller$begi = (_this$controller = this.controller) === null || _this$controller === void 0 ? void 0 : _this$controller.begin({
41
+ userAction: userAction,
42
+ audible: true
43
+ })) !== null && _this$controller$begi !== void 0 ? _this$controller$begi : undefined;
44
+ if (this.controller && !session) return false;
45
+ var generation = ++this.generation;
46
+ var mediaManager = session === null || session === void 0 ? void 0 : session.mediaManager;
47
+ this.run = {
48
+ session: session,
49
+ mediaManager: mediaManager,
50
+ valid: function valid() {
51
+ return generation === _this2.generation && !_this2.disposed && !(session !== null && session !== void 0 && session.signal.aborted);
52
+ },
53
+ bind: function bind(element) {
54
+ return session ? session.bind(element) : element;
55
+ }
56
+ };
57
+ return true;
58
+ }
59
+ }, {
60
+ key: "add",
61
+ value: function add(stop) {
62
+ var _this3 = this;
63
+ this.members.add(stop);
64
+ return function () {
65
+ _this3.members.delete(stop);
66
+ };
67
+ }
68
+ }, {
69
+ key: "stop",
70
+ value: function stop() {
71
+ ++this.generation;
72
+ this.run = undefined;
73
+ var errors = [];
74
+ try {
75
+ this.onStop();
76
+ } catch (error) {
77
+ errors.push(error);
78
+ }
79
+ for (var _i = 0, _arr = _toConsumableArray(this.members); _i < _arr.length; _i++) {
80
+ var _stop = _arr[_i];
81
+ try {
82
+ _stop();
83
+ } catch (error) {
84
+ errors.push(error);
85
+ }
86
+ }
87
+ if (errors.length) throw errors[0];
88
+ }
89
+ }, {
90
+ key: "cancel",
91
+ value: function cancel() {
92
+ var _this$controller2;
93
+ var generation = this.generation;
94
+ (_this$controller2 = this.controller) === null || _this$controller2 === void 0 || _this$controller2.cancel();
95
+ if (generation === this.generation) this.stop();
96
+ }
97
+ }, {
98
+ key: "finish",
99
+ value: function finish() {
100
+ var _this$run2;
101
+ var session = (_this$run2 = this.run) === null || _this$run2 === void 0 ? void 0 : _this$run2.session;
102
+ this.stop();
103
+ session === null || session === void 0 || session.finish();
104
+ }
105
+ }, {
106
+ key: "dispose",
107
+ value: function dispose() {
108
+ var _this$controller3;
109
+ if (this.disposed) return;
110
+ this.disposed = true;
111
+ var generation = this.generation;
112
+ (_this$controller3 = this.controller) === null || _this$controller3 === void 0 || _this$controller3.dispose();
113
+ if (generation === this.generation) this.stop();
114
+ this.members.clear();
115
+ }
116
+ }]);
117
+ }();
@@ -1,4 +1,3 @@
1
- import type { AudioIntent } from './AudioFocus';
2
1
  import { Five, Subscribe } from '@realsee/five';
3
2
  import { VreoKeyframeEvent, VreoUnit } from '../typings/VreoUnit';
4
3
  import { Appearance, PlayerConfigs } from './typings';
@@ -34,7 +33,7 @@ export declare class Player extends Subscribe<VreoKeyframeEvent> {
34
33
  private disposers;
35
34
  private loadGeneration;
36
35
  private disposed;
37
- get audioFocus(): import("./AudioFocus").AudioFocusHost;
36
+ getMediaManager(): import("./playback-types").PlaybackManager | undefined;
38
37
  /** 播放器配置(只读) */
39
38
  configs: Readonly<PlayerConfigs>;
40
39
  /**
@@ -67,7 +66,7 @@ export declare class Player extends Subscribe<VreoKeyframeEvent> {
67
66
  * await player.load(vreoUnit, 0, false, true)
68
67
  * ```
69
68
  */
70
- load(vreoUnit: VreoUnit, currentTime?: number, preload?: boolean, force?: boolean, intent?: AudioIntent): Promise<boolean>;
69
+ load(vreoUnit: VreoUnit, currentTime?: number, preload?: boolean, force?: boolean, userAction?: boolean): Promise<boolean>;
71
70
  /**
72
71
  * 获取播放器是否处于暂停状态
73
72
  * @returns 是否暂停中
@@ -88,7 +87,7 @@ export declare class Player extends Subscribe<VreoKeyframeEvent> {
88
87
  * player.play(10000) // 从10秒处开始
89
88
  * ```
90
89
  */
91
- play(currentTime?: number, intent?: AudioIntent): boolean;
90
+ play(currentTime?: number, userAction?: boolean): boolean;
92
91
  /**
93
92
  * 设置播放器外观
94
93
  * @param appearance - 外观配置对象
@@ -113,7 +113,9 @@ export var Player = /*#__PURE__*/function (_Subscribe) {
113
113
  }
114
114
  },
115
115
  five: five,
116
- audioFocus: _this.audioFocus
116
+ getMediaManager: function getMediaManager() {
117
+ return _this.getMediaManager();
118
+ }
117
119
  });
118
120
  })));
119
121
 
@@ -160,9 +162,10 @@ export var Player = /*#__PURE__*/function (_Subscribe) {
160
162
  */
161
163
  _inherits(Player, _Subscribe);
162
164
  return _createClass(Player, [{
163
- key: "audioFocus",
164
- get: function get() {
165
- return this.controller.audioFocus.host;
165
+ key: "getMediaManager",
166
+ value: function getMediaManager() {
167
+ var _this$controller$play;
168
+ return (_this$controller$play = this.controller.playback.capture()) === null || _this$controller$play === void 0 ? void 0 : _this$controller$play.mediaManager;
166
169
  }
167
170
  /** 播放器配置(只读) */
168
171
  }, {
@@ -173,13 +176,14 @@ export var Player = /*#__PURE__*/function (_Subscribe) {
173
176
  var currentTime,
174
177
  preload,
175
178
  force,
176
- intent,
179
+ userAction,
177
180
  generation,
181
+ run,
178
182
  valid,
179
- _this$controller$medi,
180
- _this$configs$imageOp,
181
183
  _this$controller$vide,
184
+ _this$configs$imageOp,
182
185
  _this$controller$vide2,
186
+ _this$controller$vide3,
183
187
  panoIndexMap,
184
188
  panoIndexes,
185
189
  i,
@@ -191,16 +195,19 @@ export var Player = /*#__PURE__*/function (_Subscribe) {
191
195
  currentTime = _args.length > 1 && _args[1] !== undefined ? _args[1] : 0;
192
196
  preload = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
193
197
  force = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
194
- intent = _args.length > 4 && _args[4] !== undefined ? _args[4] : 'auto';
198
+ userAction = _args.length > 4 && _args[4] !== undefined ? _args[4] : false;
195
199
  generation = ++this.loadGeneration;
196
- this.controller.audioFocus.cancel('replaced');
197
- if (!(this.disposed || !this.controller.audioFocus.acquire(intent))) {
200
+ this.controller.playback.cancel();
201
+ if (!(this.disposed || !this.controller.playback.begin(userAction))) {
198
202
  _context.n = 1;
199
203
  break;
200
204
  }
201
205
  return _context.a(2, false);
202
206
  case 1:
203
- valid = this.controller.audioFocus.capture();
207
+ run = this.controller.playback.capture();
208
+ valid = function valid() {
209
+ return run.valid();
210
+ };
204
211
  _context.p = 2;
205
212
  this.controller.clear();
206
213
  this.controller.setLoading(true);
@@ -220,7 +227,7 @@ export var Player = /*#__PURE__*/function (_Subscribe) {
220
227
  this.controller.stopInterval = undefined;
221
228
  }
222
229
  this.controller.vreoUnit = vreoUnit;
223
- (_this$controller$medi = this.controller.mediaInstance) === null || _this$controller$medi === void 0 || _this$controller$medi.pause();
230
+ (_this$controller$vide = this.controller.videoAgentScene) === null || _this$controller$vide === void 0 || (_this$controller$vide = _this$controller$vide.videoAgentMesh.mediaOperations) === null || _this$controller$vide === void 0 || _this$controller$vide.pause();
224
231
 
225
232
  // 预载逻辑
226
233
  // 是否降低图片分辨率
@@ -272,54 +279,60 @@ export var Player = /*#__PURE__*/function (_Subscribe) {
272
279
  // 新数据载入就绪
273
280
  this.emit('loaded', vreoUnit);
274
281
  this.controller.emit('loaded', vreoUnit);
275
- if ((_this$controller$vide = this.controller.videoAgentScene) !== null && _this$controller$vide !== void 0 && _this$controller$vide.videoAgentMesh.mediaInstance) {
276
- this.controller.videoAgentScene.videoAgentMesh.mediaInstance.currentTime = currentTime / 1000;
282
+ if (!(!valid() || generation !== this.loadGeneration)) {
283
+ _context.n = 7;
284
+ break;
285
+ }
286
+ return _context.a(2, false);
287
+ case 7:
288
+ if ((_this$controller$vide2 = this.controller.videoAgentScene) !== null && _this$controller$vide2 !== void 0 && _this$controller$vide2.videoAgentMesh.mediaOperations) {
289
+ this.controller.videoAgentScene.videoAgentMesh.mediaOperations.currentTime = currentTime / 1000;
277
290
  }
278
291
  this.controller.setAvatar(vreoUnit.video.avatar);
279
- _context.n = 7;
292
+ _context.n = 8;
280
293
  return waitForBlankAudioGenerated();
281
- case 7:
294
+ case 8:
282
295
  if (!(!valid() || generation !== this.loadGeneration)) {
283
- _context.n = 8;
296
+ _context.n = 9;
284
297
  break;
285
298
  }
286
299
  return _context.a(2, false);
287
- case 8:
288
- _context.n = 9;
289
- 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);
290
300
  case 9:
301
+ _context.n = 10;
302
+ return (_this$controller$vide3 = this.controller.videoAgentScene) === null || _this$controller$vide3 === void 0 ? void 0 : _this$controller$vide3.videoAgentMesh.play(vreoUnit.video.url, currentTime / 1000, vreoUnit.video.duration);
303
+ case 10:
291
304
  if (!(!valid() || generation !== this.loadGeneration)) {
292
- _context.n = 10;
305
+ _context.n = 11;
293
306
  break;
294
307
  }
295
308
  return _context.a(2, false);
296
- case 10:
309
+ case 11:
297
310
  this.controller.setEnded(false);
298
- this.play(undefined, intent);
311
+ this.play(undefined, userAction);
299
312
  this.controller.run(function (type, keyframe) {
300
313
  return _this2.emit(type, keyframe, _this2.controller.currentTime);
301
314
  });
302
315
  this.controller.setLoading(false);
303
316
  return _context.a(2, true);
304
- case 11:
305
- _context.p = 11;
317
+ case 12:
318
+ _context.p = 12;
306
319
  _t = _context.v;
307
320
  if (valid()) {
308
- _context.n = 12;
321
+ _context.n = 13;
309
322
  break;
310
323
  }
311
324
  return _context.a(2, false);
312
- case 12:
313
- this.controller.audioFocus.cancel('paused');
314
- throw _t;
315
325
  case 13:
316
- _context.p = 13;
317
- if (generation === this.loadGeneration) this.controller.setLoading(false);
318
- return _context.f(13);
326
+ this.controller.playback.cancel();
327
+ throw _t;
319
328
  case 14:
329
+ _context.p = 14;
330
+ if (generation === this.loadGeneration) this.controller.setLoading(false);
331
+ return _context.f(14);
332
+ case 15:
320
333
  return _context.a(2);
321
334
  }
322
- }, _callee, this, [[2, 11, 13, 14]]);
335
+ }, _callee, this, [[2, 12, 14, 15]]);
323
336
  }));
324
337
  function load(_x) {
325
338
  return _load.apply(this, arguments);
@@ -355,12 +368,12 @@ export var Player = /*#__PURE__*/function (_Subscribe) {
355
368
  }, {
356
369
  key: "play",
357
370
  value: function play(currentTime) {
358
- var _this$controller$vreo;
359
- var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'auto';
360
- if (this.disposed || !this.controller.audioFocus.acquire(intent)) return false;
371
+ var _this$controller$vide4, _this$controller$vreo;
372
+ var userAction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
373
+ if (this.disposed || !this.controller.playback.begin(userAction)) return false;
361
374
  if (this.controller.playing) return true;
362
- if (currentTime && this.controller.mediaInstance) {
363
- this.controller.mediaInstance.currentTime = currentTime / 1000;
375
+ if (currentTime && (_this$controller$vide4 = this.controller.videoAgentScene) !== null && _this$controller$vide4 !== void 0 && _this$controller$vide4.videoAgentMesh.mediaOperations) {
376
+ this.controller.videoAgentScene.videoAgentMesh.mediaOperations.currentTime = currentTime / 1000;
364
377
  }
365
378
  Object.assign(window, {
366
379
  $vreoController: this.controller
@@ -399,7 +412,7 @@ export var Player = /*#__PURE__*/function (_Subscribe) {
399
412
  key: "pause",
400
413
  value: function pause() {
401
414
  ++this.loadGeneration;
402
- this.controller.audioFocus.cancel('paused');
415
+ this.controller.playback.cancel();
403
416
  this.controller.setLoading(false);
404
417
  }
405
418
 
@@ -1,10 +1,12 @@
1
+ import type { PlaybackRun } from '../../PlaybackLifecycle';
2
+ import type { MediaOperations } from '../../playback-types';
1
3
  import * as THREE from 'three';
2
4
  import AudioLike from '../../../shared-utils/AudioLike';
3
5
  /**
4
6
  * 视频经纪人贴片的配置选项
5
7
  */
6
8
  export interface VideoAgentMeshOptions {
7
- canPlay?: () => boolean;
9
+ getPlayback?: () => PlaybackRun | undefined;
8
10
  /**
9
11
  * 自定义视频实例。
10
12
  */
@@ -59,6 +61,8 @@ export declare class VideoAgentMesh extends THREE.Mesh {
59
61
  /** 是否暂停状态 */
60
62
  paused: boolean;
61
63
  /** 音频实例 */
64
+ private outputs;
65
+ private operations;
62
66
  private ownsVideo;
63
67
  private ownsAudio;
64
68
  private generation;
@@ -132,6 +136,7 @@ export declare class VideoAgentMesh extends THREE.Mesh {
132
136
  * ```
133
137
  */
134
138
  play(videoUrl?: string, currentTime?: number, duration?: number): Promise<boolean>;
139
+ get mediaOperations(): MediaOperations | AudioLike | undefined;
135
140
  stop(): void;
136
141
  /**
137
142
  * 获取当前播放时间(毫秒)