@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.
@@ -256,7 +256,7 @@ class BrowserRTC extends CoreRTC {
256
256
  userId: options.userId,
257
257
  });
258
258
  // 1. 创建client
259
- this._trtc.client = TRTC.createClient(Object.assign({ mode: 'rtc' }, createClientOptions));
259
+ this._trtc.client = TRTC.createClient(Object.assign(Object.assign({ mode: 'rtc' }, createClientOptions), { enableAutoPlayDialog: typeof this._autoPlayConfirm === 'function' ? false : true }));
260
260
  (_a = this._trtc.client) === null || _a === void 0 ? void 0 : _a.enableAudioVolumeEvaluation();
261
261
  // 2. 订阅事件
262
262
  this._registerRtcEvent();
@@ -305,9 +305,24 @@ class BrowserRTC extends CoreRTC {
305
305
  dom.id = domId;
306
306
  this.$dom.appendChild(dom);
307
307
  // 播放远端流
308
- remoteStream.play(domId);
308
+ if (typeof this._autoPlayConfirm === 'function') {
309
+ remoteStream.play(domId).catch((error) => { });
310
+ remoteStream.on('error', (error) => {
311
+ const errorCode = error.getCode();
312
+ if (errorCode === 0x4043) {
313
+ // PLAY_NOT_ALLOWED,引导用户手势操作并调用 stream.resume 恢复音视频播放
314
+ const onConfirm = () => remoteStream.resume();
315
+ this._autoPlayConfirm({ onConfirm });
316
+ }
317
+ });
318
+ }
319
+ else {
320
+ remoteStream.play(domId);
321
+ }
309
322
  };
310
323
  this._getVoiceSign = options.getVoiceSign;
324
+ // @ts-ignore
325
+ this._autoPlayConfirm = options.autoPlayConfirm;
311
326
  this._initParentDom();
312
327
  }
313
328
  _initParentDom() {
@@ -3742,6 +3757,7 @@ class Live extends Subscribe$1 {
3742
3757
  })();
3743
3758
  // 第二步检查getVoiceSign
3744
3759
  this._options.getVoiceSign = (_a = opts.getVoiceSign) !== null && _a !== void 0 ? _a : unimplementedGetVoiceSign;
3760
+ this._options.autoPlayConfirm = opts.autoPlayConfirm;
3745
3761
  // 第二步检查rtc
3746
3762
  this._options.rtc = (() => {
3747
3763
  // 优先取rtc实例
@@ -3775,8 +3791,12 @@ class Live extends Subscribe$1 {
3775
3791
  }
3776
3792
  case RTCType.RealseeBrowserRTC: {
3777
3793
  // 内置的 RealseeBrowserRTC
3794
+ if (!this._options.autoPlayConfirm) {
3795
+ logger$1.error('autoPlayConfirm method must be passed when using built-in RealseeBrowserRTC instances');
3796
+ }
3778
3797
  return new BrowserRTC({
3779
3798
  getVoiceSign: this._options.getVoiceSign,
3799
+ autoPlayConfirm: this._options.autoPlayConfirm,
3780
3800
  });
3781
3801
  }
3782
3802
  default: {
@@ -3803,7 +3823,10 @@ class Live extends Subscribe$1 {
3803
3823
  ? new BrowserRTC4Chime({
3804
3824
  getVoiceSign: this._options.getVoiceSign,
3805
3825
  })
3806
- : new BrowserRTC({ getVoiceSign: this._options.getVoiceSign });
3826
+ : new BrowserRTC({
3827
+ getVoiceSign: this._options.getVoiceSign,
3828
+ autoPlayConfirm: this._options.autoPlayConfirm,
3829
+ });
3807
3830
  }
3808
3831
  }
3809
3832
  else {