@realsee/live 0.5.2-dev.4 → 0.5.2-dev.6

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() {
@@ -3634,6 +3649,8 @@ class Live extends Subscribe$1 {
3634
3649
  this.exit = () => __awaiter$1(this, void 0, void 0, function* () {
3635
3650
  var _l;
3636
3651
  this._clearLiveData();
3652
+ if (this.state !== LiveState.OPEN)
3653
+ return true;
3637
3654
  try {
3638
3655
  /** 退出强制关闭语音 */
3639
3656
  (_l = this.$RTC) === null || _l === void 0 ? void 0 : _l.quit();
@@ -3773,8 +3790,10 @@ class Live extends Subscribe$1 {
3773
3790
  }
3774
3791
  case RTCType.RealseeBrowserRTC: {
3775
3792
  // 内置的 RealseeBrowserRTC
3793
+ logger$1.error('autoPlayConfirm method must be passed when using built-in RTC instances');
3776
3794
  return new BrowserRTC({
3777
3795
  getVoiceSign: this._options.getVoiceSign,
3796
+ autoPlayConfirm: this._options.autoPlayConfirm,
3778
3797
  });
3779
3798
  }
3780
3799
  default: {
@@ -3801,7 +3820,10 @@ class Live extends Subscribe$1 {
3801
3820
  ? new BrowserRTC4Chime({
3802
3821
  getVoiceSign: this._options.getVoiceSign,
3803
3822
  })
3804
- : new BrowserRTC({ getVoiceSign: this._options.getVoiceSign });
3823
+ : new BrowserRTC({
3824
+ getVoiceSign: this._options.getVoiceSign,
3825
+ autoPlayConfirm: this._options.autoPlayConfirm,
3826
+ });
3805
3827
  }
3806
3828
  }
3807
3829
  else {