@realsee/live 0.5.2-dev.5 → 0.5.2-dev.7

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.
@@ -265,7 +265,7 @@ class BrowserRTC extends CoreRTC {
265
265
  userId: options.userId,
266
266
  });
267
267
  // 1. 创建client
268
- this._trtc.client = TRTC__default["default"].createClient(Object.assign({ mode: 'rtc' }, createClientOptions));
268
+ this._trtc.client = TRTC__default["default"].createClient(Object.assign(Object.assign({ mode: 'rtc' }, createClientOptions), { enableAutoPlayDialog: typeof this._autoPlayConfirm === 'function' ? false : true }));
269
269
  (_a = this._trtc.client) === null || _a === void 0 ? void 0 : _a.enableAudioVolumeEvaluation();
270
270
  // 2. 订阅事件
271
271
  this._registerRtcEvent();
@@ -314,9 +314,24 @@ class BrowserRTC extends CoreRTC {
314
314
  dom.id = domId;
315
315
  this.$dom.appendChild(dom);
316
316
  // 播放远端流
317
- remoteStream.play(domId);
317
+ if (typeof this._autoPlayConfirm === 'function') {
318
+ remoteStream.play(domId).catch((error) => { });
319
+ remoteStream.on('error', (error) => {
320
+ const errorCode = error.getCode();
321
+ if (errorCode === 0x4043) {
322
+ // PLAY_NOT_ALLOWED,引导用户手势操作并调用 stream.resume 恢复音视频播放
323
+ const onConfirm = () => remoteStream.resume();
324
+ this._autoPlayConfirm({ onConfirm });
325
+ }
326
+ });
327
+ }
328
+ else {
329
+ remoteStream.play(domId);
330
+ }
318
331
  };
319
332
  this._getVoiceSign = options.getVoiceSign;
333
+ // @ts-ignore
334
+ this._autoPlayConfirm = options.autoPlayConfirm;
320
335
  this._initParentDom();
321
336
  }
322
337
  _initParentDom() {
@@ -3751,6 +3766,7 @@ class Live extends Subscribe$1 {
3751
3766
  })();
3752
3767
  // 第二步检查getVoiceSign
3753
3768
  this._options.getVoiceSign = (_a = opts.getVoiceSign) !== null && _a !== void 0 ? _a : unimplementedGetVoiceSign;
3769
+ this._options.autoPlayConfirm = opts.autoPlayConfirm;
3754
3770
  // 第二步检查rtc
3755
3771
  this._options.rtc = (() => {
3756
3772
  // 优先取rtc实例
@@ -3784,8 +3800,12 @@ class Live extends Subscribe$1 {
3784
3800
  }
3785
3801
  case exports.RTCType.RealseeBrowserRTC: {
3786
3802
  // 内置的 RealseeBrowserRTC
3803
+ if (!this._options.autoPlayConfirm) {
3804
+ logger$1.error('autoPlayConfirm method must be passed when using built-in RealseeBrowserRTC instances');
3805
+ }
3787
3806
  return new BrowserRTC({
3788
3807
  getVoiceSign: this._options.getVoiceSign,
3808
+ autoPlayConfirm: this._options.autoPlayConfirm,
3789
3809
  });
3790
3810
  }
3791
3811
  default: {
@@ -3812,7 +3832,10 @@ class Live extends Subscribe$1 {
3812
3832
  ? new BrowserRTC4Chime({
3813
3833
  getVoiceSign: this._options.getVoiceSign,
3814
3834
  })
3815
- : new BrowserRTC({ getVoiceSign: this._options.getVoiceSign });
3835
+ : new BrowserRTC({
3836
+ getVoiceSign: this._options.getVoiceSign,
3837
+ autoPlayConfirm: this._options.autoPlayConfirm,
3838
+ });
3816
3839
  }
3817
3840
  }
3818
3841
  else {