@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.
@@ -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() {
@@ -3643,6 +3658,8 @@ class Live extends Subscribe$1 {
3643
3658
  this.exit = () => __awaiter$1(this, void 0, void 0, function* () {
3644
3659
  var _l;
3645
3660
  this._clearLiveData();
3661
+ if (this.state !== exports.LiveState.OPEN)
3662
+ return true;
3646
3663
  try {
3647
3664
  /** 退出强制关闭语音 */
3648
3665
  (_l = this.$RTC) === null || _l === void 0 ? void 0 : _l.quit();
@@ -3782,8 +3799,10 @@ class Live extends Subscribe$1 {
3782
3799
  }
3783
3800
  case exports.RTCType.RealseeBrowserRTC: {
3784
3801
  // 内置的 RealseeBrowserRTC
3802
+ logger$1.error('autoPlayConfirm method must be passed when using built-in RTC instances');
3785
3803
  return new BrowserRTC({
3786
3804
  getVoiceSign: this._options.getVoiceSign,
3805
+ autoPlayConfirm: this._options.autoPlayConfirm,
3787
3806
  });
3788
3807
  }
3789
3808
  default: {
@@ -3810,7 +3829,10 @@ class Live extends Subscribe$1 {
3810
3829
  ? new BrowserRTC4Chime({
3811
3830
  getVoiceSign: this._options.getVoiceSign,
3812
3831
  })
3813
- : new BrowserRTC({ getVoiceSign: this._options.getVoiceSign });
3832
+ : new BrowserRTC({
3833
+ getVoiceSign: this._options.getVoiceSign,
3834
+ autoPlayConfirm: this._options.autoPlayConfirm,
3835
+ });
3814
3836
  }
3815
3837
  }
3816
3838
  else {