@volcengine/veplayer-plugin 2.4.1-rc.0 → 2.4.2-rc.1

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.
@@ -342,13 +342,13 @@ function _regeneratorRuntime$a() {
342
342
  }
343
343
  }, exports;
344
344
  }
345
- function _typeof$a(obj) {
345
+ function _typeof$b(obj) {
346
346
  "@babel/helpers - typeof";
347
- return _typeof$a = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
347
+ return _typeof$b = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
348
348
  return typeof obj2;
349
349
  } : function(obj2) {
350
350
  return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
351
- }, _typeof$a(obj);
351
+ }, _typeof$b(obj);
352
352
  }
353
353
  function asyncGeneratorStep$a(gen, resolve3, reject3, _next, _throw, key2, arg) {
354
354
  try {
@@ -527,13 +527,13 @@ function _objectSpread2$9(target) {
527
527
  }
528
528
  return target;
529
529
  }
530
- function _typeof$9(obj) {
530
+ function _typeof$a(obj) {
531
531
  "@babel/helpers - typeof";
532
- return _typeof$9 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
532
+ return _typeof$a = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
533
533
  return typeof obj2;
534
534
  } : function(obj2) {
535
535
  return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
536
- }, _typeof$9(obj);
536
+ }, _typeof$a(obj);
537
537
  }
538
538
  function _classCallCheck$i(instance, Constructor2) {
539
539
  if (!(instance instanceof Constructor2)) {
@@ -922,7 +922,7 @@ util$2.hasClass = function(el, className) {
922
922
  return item === className;
923
923
  });
924
924
  } catch (e) {
925
- var orgClassName = el.className && _typeof$9(el.className) === "object" ? el.getAttribute("class") : el.className;
925
+ var orgClassName = el.className && _typeof$a(el.className) === "object" ? el.getAttribute("class") : el.className;
926
926
  return orgClassName && !!orgClassName.match(new RegExp("(\\s|^)" + className + "(\\s|$)"));
927
927
  }
928
928
  };
@@ -936,7 +936,7 @@ util$2.addClass = function(el, className) {
936
936
  });
937
937
  } catch (e) {
938
938
  if (!util$2.hasClass(el, className)) {
939
- if (el.className && _typeof$9(el.className) === "object") {
939
+ if (el.className && _typeof$a(el.className) === "object") {
940
940
  el.setAttribute("class", el.getAttribute("class") + " " + className);
941
941
  } else {
942
942
  el.className += " " + className;
@@ -956,7 +956,7 @@ util$2.removeClass = function(el, className) {
956
956
  if (util$2.hasClass(el, className)) {
957
957
  className.split(/\s+/g).forEach(function(item) {
958
958
  var reg = new RegExp("(\\s|^)" + item + "(\\s|$)");
959
- if (el.className && _typeof$9(el.className) === "object") {
959
+ if (el.className && _typeof$a(el.className) === "object") {
960
960
  el.setAttribute("class", el.getAttribute("class").replace(reg, " "));
961
961
  } else {
962
962
  el.className = el.className.replace(reg, " ");
@@ -1197,7 +1197,7 @@ util$2.checkIsFunction = function(fun) {
1197
1197
  return fun && typeof fun === "function";
1198
1198
  };
1199
1199
  util$2.checkIsObject = function(obj) {
1200
- return obj !== null && _typeof$9(obj) === "object";
1200
+ return obj !== null && _typeof$a(obj) === "object";
1201
1201
  };
1202
1202
  util$2.hide = function(dom) {
1203
1203
  dom.style.display = "none";
@@ -1759,6 +1759,8 @@ var Errors = /* @__PURE__ */ _createClass$i(
1759
1759
  }
1760
1760
  }
1761
1761
  );
1762
+ var PLAY = "play";
1763
+ var PAUSE = "pause";
1762
1764
  var ERROR = "error";
1763
1765
  var TIME_UPDATE = "timeupdate";
1764
1766
  var WAITING = "waiting";
@@ -2463,13 +2465,13 @@ function _regeneratorRuntime$9() {
2463
2465
  }
2464
2466
  }, exports;
2465
2467
  }
2466
- function _typeof$8(obj) {
2468
+ function _typeof$9(obj) {
2467
2469
  "@babel/helpers - typeof";
2468
- return _typeof$8 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
2470
+ return _typeof$9 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
2469
2471
  return typeof obj2;
2470
2472
  } : function(obj2) {
2471
2473
  return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
2472
- }, _typeof$8(obj);
2474
+ }, _typeof$9(obj);
2473
2475
  }
2474
2476
  function asyncGeneratorStep$9(gen, resolve3, reject3, _next, _throw, key2, arg) {
2475
2477
  try {
@@ -2923,21 +2925,6 @@ var Buffer$6 = /* @__PURE__ */ function() {
2923
2925
  length: Buffer22.totalLength && Buffer22.totalLength(buffers)
2924
2926
  };
2925
2927
  }
2926
- }, {
2927
- key: "isBuffered",
2928
- value: function isBuffered(media, pos) {
2929
- if (media) {
2930
- var buffered = Buffer22.get(media);
2931
- if (buffered !== null && buffered !== void 0 && buffered.length) {
2932
- for (var i = 0; i < buffered.length; i++) {
2933
- if (pos >= buffered.start(i) && pos <= buffered.end(i)) {
2934
- return true;
2935
- }
2936
- }
2937
- }
2938
- }
2939
- return false;
2940
- }
2941
2928
  }]);
2942
2929
  return Buffer22;
2943
2930
  }();
@@ -3200,7 +3187,7 @@ function nowTime$7() {
3200
3187
  return (/* @__PURE__ */ new Date()).toLocaleString();
3201
3188
  }
3202
3189
  function reduceDepth$2(val) {
3203
- if (_typeof$8(val) !== "object") {
3190
+ if (_typeof$9(val) !== "object") {
3204
3191
  return val;
3205
3192
  }
3206
3193
  var objType = Object.prototype.toString.call(val).slice(8, -1);
@@ -3221,7 +3208,7 @@ function logable$2(obj, maxDepth, depth) {
3221
3208
  if (!maxDepth)
3222
3209
  maxDepth = 2;
3223
3210
  var result = {};
3224
- if (!obj || _typeof$8(obj) !== "object") {
3211
+ if (!obj || _typeof$9(obj) !== "object") {
3225
3212
  return obj;
3226
3213
  }
3227
3214
  var objType = Object.prototype.toString.call(obj).slice(8, -1);
@@ -3235,7 +3222,7 @@ function logable$2(obj, maxDepth, depth) {
3235
3222
  if (Object.prototype.hasOwnProperty.call(obj, key2)) {
3236
3223
  if (depth === maxDepth) {
3237
3224
  result[key2] = reduceDepth$2(obj[key2]);
3238
- } else if (_typeof$8(obj[key2]) === "object") {
3225
+ } else if (_typeof$9(obj[key2]) === "object") {
3239
3226
  result[key2] = logable$2(obj[key2], maxDepth, depth + 1);
3240
3227
  } else {
3241
3228
  result[key2] = obj[key2];
@@ -3875,7 +3862,7 @@ var MSE$3 = /* @__PURE__ */ function() {
3875
3862
  } catch (error) {
3876
3863
  if (error && error.message && error.message.indexOf("SourceBuffer is full") >= 0) {
3877
3864
  this._mseFullFlag[type] = true;
3878
- if (op.context && _typeof$8(op.context) === "object") {
3865
+ if (op.context && _typeof$9(op.context) === "object") {
3879
3866
  op.context.isFull = true;
3880
3867
  }
3881
3868
  this._logger.error("[MSE error], context,", op.context, " ,name,", op.opName, ",err,SourceBuffer is full");
@@ -3977,7 +3964,7 @@ var NetError$3 = /* @__PURE__ */ function(_Error) {
3977
3964
  }(/* @__PURE__ */ _wrapNativeSuper$4(Error));
3978
3965
  var toString$z = Object.prototype.toString;
3979
3966
  function isObject$N(a) {
3980
- return a !== null && _typeof$8(a) === "object";
3967
+ return a !== null && _typeof$9(a) === "object";
3981
3968
  }
3982
3969
  function isPlainObject$3(val) {
3983
3970
  if (toString$z.call(val) !== "[object Object]") {
@@ -6067,7 +6054,7 @@ var AAC$2 = /* @__PURE__ */ function() {
6067
6054
  continue;
6068
6055
  }
6069
6056
  frameLength = (data2[i + 3] & 3) << 11 | data2[i + 4] << 3 | (data2[i + 5] & 224) >> 5;
6070
- if (!frameLength || len - i < frameLength)
6057
+ if (len - i < frameLength)
6071
6058
  break;
6072
6059
  protectionSkipBytes = (~data2[i + 1] & 1) * 2;
6073
6060
  frames.push({
@@ -12153,7 +12140,7 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
12153
12140
  }
12154
12141
  return;
12155
12142
  }
12156
- if (opts.isLive && media.readyState === 4 && bufferEnd - media.currentTime > opts.disconnectTime) {
12143
+ if (opts.isLive && media.readyState === 4 && bufferEnd > opts.disconnectTime) {
12157
12144
  _this.disconnect();
12158
12145
  }
12159
12146
  }
@@ -12325,7 +12312,7 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
12325
12312
  _createClass$j(Flv2, [{
12326
12313
  key: "version",
12327
12314
  get: function get3() {
12328
- return "3.0.19-rc.10";
12315
+ return "3.0.19-rc.0";
12329
12316
  }
12330
12317
  }, {
12331
12318
  key: "isLive",
@@ -12832,7 +12819,7 @@ var FlvPlugin = /* @__PURE__ */ function(_BasePlugin) {
12832
12819
  if (_this.flv) {
12833
12820
  var _this$player$config, _this$player$config$f;
12834
12821
  _this.player.config.url = url;
12835
- if (_typeof$a(seamless) === "object") {
12822
+ if (_typeof$b(seamless) === "object") {
12836
12823
  seamless = seamless.seamless;
12837
12824
  }
12838
12825
  _this.flv.switchURL(url, seamless);
@@ -13029,13 +13016,13 @@ function _toPropertyKey$5(t) {
13029
13016
  var i = _toPrimitive$5(t, "string");
13030
13017
  return "symbol" == typeof i ? i : String(i);
13031
13018
  }
13032
- function _typeof$7(o) {
13019
+ function _typeof$8(o) {
13033
13020
  "@babel/helpers - typeof";
13034
- return _typeof$7 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
13021
+ return _typeof$8 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
13035
13022
  return typeof o2;
13036
13023
  } : function(o2) {
13037
13024
  return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
13038
- }, _typeof$7(o);
13025
+ }, _typeof$8(o);
13039
13026
  }
13040
13027
  function _classCallCheck$f(instance, Constructor2) {
13041
13028
  if (!(instance instanceof Constructor2)) {
@@ -13402,7 +13389,7 @@ var abrAlgo = function() {
13402
13389
  } else {
13403
13390
  scriptDirectory = "";
13404
13391
  }
13405
- if (!((typeof window === "undefined" ? "undefined" : _typeof$7(window)) === "object" || typeof importScripts === "function"))
13392
+ if (!((typeof window === "undefined" ? "undefined" : _typeof$8(window)) === "object" || typeof importScripts === "function"))
13406
13393
  throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");
13407
13394
  }
13408
13395
  var out = Module["print"] || console.log.bind(console);
@@ -24133,7 +24120,7 @@ var abrAlgo = function() {
24133
24120
  RuntimeError: Error
24134
24121
  };
24135
24122
  wasmBinary = [];
24136
- if (_typeof$7(WebAssembly2) !== "object") {
24123
+ if (_typeof$8(WebAssembly2) !== "object") {
24137
24124
  abort("no native wasm support detected");
24138
24125
  }
24139
24126
  var wasmMemory;
@@ -25943,7 +25930,7 @@ var Algo = /* @__PURE__ */ function() {
25943
25930
  }, {
25944
25931
  key: "updateDeviceInfo",
25945
25932
  value: function updateDeviceInfo() {
25946
- var devicePixelRatio = (typeof window === "undefined" ? "undefined" : _typeof$7(window)) === "object" ? window.devicePixelRatio || 1 : 1;
25933
+ var devicePixelRatio = (typeof window === "undefined" ? "undefined" : _typeof$8(window)) === "object" ? window.devicePixelRatio || 1 : 1;
25947
25934
  var _this$player$video$ge = this.player.video.getBoundingClientRect(), width = _this$player$video$ge.width, height = _this$player$video$ge.height;
25948
25935
  this.module._updateDeviceInfo(Math.floor(width), Math.floor(height), devicePixelRatio, 30);
25949
25936
  }
@@ -27178,6 +27165,14 @@ function _regeneratorRuntime$8() {
27178
27165
  }
27179
27166
  }, exports;
27180
27167
  }
27168
+ function _typeof$7(obj) {
27169
+ "@babel/helpers - typeof";
27170
+ return _typeof$7 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
27171
+ return typeof obj2;
27172
+ } : function(obj2) {
27173
+ return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
27174
+ }, _typeof$7(obj);
27175
+ }
27181
27176
  function asyncGeneratorStep$8(gen, resolve3, reject3, _next, _throw, key2, arg) {
27182
27177
  try {
27183
27178
  var info = gen[key2](arg);
@@ -30188,7 +30183,8 @@ function getOption(opts) {
30188
30183
  loadTimeout: 5e3,
30189
30184
  stallInterval: 400,
30190
30185
  networkEvaluateInterval: 1e3,
30191
- delayHint: 0
30186
+ delayHint: 0,
30187
+ seamlesslyReload: false
30192
30188
  }, opts);
30193
30189
  }
30194
30190
  function _getStats(stats) {
@@ -30451,6 +30447,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
30451
30447
  _defineProperty$c(_assertThisInitialized$b(_this), "_audioTransceicer", null);
30452
30448
  _defineProperty$c(_assertThisInitialized$b(_this), "_videoTransceicer", null);
30453
30449
  _defineProperty$c(_assertThisInitialized$b(_this), "_mediaStream", null);
30450
+ _defineProperty$c(_assertThisInitialized$b(_this), "_lastMediaStream", null);
30454
30451
  _defineProperty$c(_assertThisInitialized$b(_this), "_media", null);
30455
30452
  _defineProperty$c(_assertThisInitialized$b(_this), "_opts", null);
30456
30453
  _defineProperty$c(_assertThisInitialized$b(_this), "_loader", null);
@@ -30458,19 +30455,10 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
30458
30455
  _defineProperty$c(_assertThisInitialized$b(_this), "_retry", 0);
30459
30456
  _defineProperty$c(_assertThisInitialized$b(_this), "_waitingTimer", 0);
30460
30457
  _defineProperty$c(_assertThisInitialized$b(_this), "_rctConnectStartTs", 0);
30458
+ _defineProperty$c(_assertThisInitialized$b(_this), "_isReplacing", false);
30461
30459
  _defineProperty$c(_assertThisInitialized$b(_this), "_onTrack", function(e) {
30462
30460
  logger$6.log("addTrack: ", e.track, e.streams);
30463
30461
  _this["_".concat(e.track.kind)] = e.track;
30464
- if (!_this._mediaStream) {
30465
- _this._mediaStream = new MediaStream();
30466
- _this._media.srcObject = _this._mediaStream;
30467
- var req = _this._media.play();
30468
- if (req && req.catch) {
30469
- req.catch(function(e2) {
30470
- });
30471
- }
30472
- }
30473
- _this._mediaStream.addTrack(e.track);
30474
30462
  });
30475
30463
  _defineProperty$c(_assertThisInitialized$b(_this), "_mockWaitingByTimeupdate", function() {
30476
30464
  var _this$_pc, _this$_pc2;
@@ -30518,6 +30506,9 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
30518
30506
  }));
30519
30507
  _this._retry = _this._opts.retryCount;
30520
30508
  _this._bindMediaEvent();
30509
+ if (_this._opts.mediaStream && _this._opts.seamlesslyReload) {
30510
+ _this._lastMediaStream = _this._opts.mediaStream;
30511
+ }
30521
30512
  return _this;
30522
30513
  }
30523
30514
  _createClass$e(Rts2, [{
@@ -30561,9 +30552,9 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
30561
30552
  }, {
30562
30553
  key: "load",
30563
30554
  value: function() {
30564
- var _load = _asyncToGenerator$8(/* @__PURE__ */ _regeneratorRuntime$8().mark(function _callee(url) {
30555
+ var _load = _asyncToGenerator$8(/* @__PURE__ */ _regeneratorRuntime$8().mark(function _callee(url, seamless) {
30565
30556
  var _this2 = this;
30566
- var lastPc;
30557
+ var _this$_pc3;
30567
30558
  return _regeneratorRuntime$8().wrap(function _callee$(_context) {
30568
30559
  while (1)
30569
30560
  switch (_context.prev = _context.next) {
@@ -30571,39 +30562,43 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
30571
30562
  this._disconnect();
30572
30563
  this._url = url;
30573
30564
  this._retry = this._opts.retryCount;
30574
- lastPc = this._pc;
30575
- if (lastPc) {
30576
- lastPc.close();
30565
+ if (seamless) {
30566
+ this._lastPc = this._pc;
30567
+ } else {
30568
+ (_this$_pc3 = this._pc) === null || _this$_pc3 === void 0 ? void 0 : _this$_pc3.close();
30577
30569
  }
30578
- _context.prev = 5;
30570
+ _context.prev = 4;
30579
30571
  this._pc = new RTCPeerConnection();
30580
30572
  this._bindRTCEvents();
30581
- _context.next = 10;
30573
+ _context.next = 9;
30582
30574
  return this._connect(url);
30583
- case 10:
30584
- _context.next = 15;
30575
+ case 9:
30576
+ _context.next = 14;
30585
30577
  break;
30586
- case 12:
30587
- _context.prev = 12;
30588
- _context.t0 = _context["catch"](5);
30578
+ case 11:
30579
+ _context.prev = 11;
30580
+ _context.t0 = _context["catch"](4);
30589
30581
  setTimeout(function() {
30590
30582
  return _this2._emitError(StreamingError$2.create(ERR$2.OTHER, null, _context.t0));
30591
30583
  });
30592
- case 15:
30584
+ case 14:
30593
30585
  case "end":
30594
30586
  return _context.stop();
30595
30587
  }
30596
- }, _callee, this, [[5, 12]]);
30588
+ }, _callee, this, [[4, 11]]);
30597
30589
  }));
30598
- function load(_x) {
30590
+ function load(_x, _x2) {
30599
30591
  return _load.apply(this, arguments);
30600
30592
  }
30601
30593
  return load;
30602
30594
  }()
30603
30595
  }, {
30604
30596
  key: "switchURL",
30605
- value: function switchURL(url) {
30606
- this.load(url || this._url);
30597
+ value: function switchURL(url, seamless) {
30598
+ if (seamless) {
30599
+ this._lastMediaStream = this._mediaStream;
30600
+ }
30601
+ this.load(url || this._url, seamless);
30607
30602
  }
30608
30603
  }, {
30609
30604
  key: "_bindRTCEvents",
@@ -30629,6 +30624,8 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
30629
30624
  _this3.load(_this3._url);
30630
30625
  }
30631
30626
  if (pc.connectionState === "connected") {
30627
+ _this3._closeLastPc();
30628
+ _this3._handleMediaStream();
30632
30629
  _this3.emit(EVENT$2.TTFB, {
30633
30630
  url: _this3._url,
30634
30631
  responseUrl: _this3._url,
@@ -30637,6 +30634,40 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
30637
30634
  }
30638
30635
  });
30639
30636
  }
30637
+ }, {
30638
+ key: "_handleMediaStream",
30639
+ value: function _handleMediaStream() {
30640
+ var _this4 = this;
30641
+ if (this._lastMediaStream) {
30642
+ var _this$_media$play;
30643
+ var videoTrack = this._lastMediaStream.getVideoTracks()[0];
30644
+ var audioTrack = this._lastMediaStream.getAudioTracks()[0];
30645
+ if (videoTrack) {
30646
+ this._lastMediaStream.removeTrack(videoTrack);
30647
+ }
30648
+ if (audioTrack) {
30649
+ this._lastMediaStream.removeTrack(audioTrack);
30650
+ }
30651
+ this._mediaStream = this._lastMediaStream;
30652
+ this._mediaStream.addTrack(this._audio);
30653
+ this._mediaStream.addTrack(this._video);
30654
+ this._isReplacing = true;
30655
+ this._media.pause();
30656
+ (_this$_media$play = this._media.play()) === null || _this$_media$play === void 0 ? void 0 : _this$_media$play.finally(function() {
30657
+ _this4._isReplacing = false;
30658
+ });
30659
+ } else {
30660
+ this._mediaStream = new MediaStream();
30661
+ this._mediaStream.addTrack(this._audio);
30662
+ this._mediaStream.addTrack(this._video);
30663
+ this._media.srcObject = this._mediaStream;
30664
+ var req = this._media.play();
30665
+ if (req && req.catch) {
30666
+ req.catch(function(e) {
30667
+ });
30668
+ }
30669
+ }
30670
+ }
30640
30671
  }, {
30641
30672
  key: "_bindMediaEvent",
30642
30673
  value: function _bindMediaEvent() {
@@ -30791,6 +30822,14 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
30791
30822
  }
30792
30823
  return _connect;
30793
30824
  }()
30825
+ }, {
30826
+ key: "_closeLastPc",
30827
+ value: function _closeLastPc() {
30828
+ if (this._lastPc) {
30829
+ this._lastPc.close();
30830
+ this._lastPc = null;
30831
+ }
30832
+ }
30794
30833
  }, {
30795
30834
  key: "_disconnect",
30796
30835
  value: function _disconnect() {
@@ -30805,17 +30844,19 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
30805
30844
  }, {
30806
30845
  key: "_emitError",
30807
30846
  value: function _emitError(error) {
30847
+ this._closeLastPc();
30808
30848
  this.emit(EVENT$2.ERROR, error);
30809
30849
  }
30810
30850
  }, {
30811
30851
  key: "destroy",
30812
30852
  value: function destroy() {
30813
- var _this$_media2;
30853
+ var _this$_media2, _this$_opts;
30814
30854
  this._disconnect();
30815
30855
  (_this$_media2 = this._media) === null || _this$_media2 === void 0 ? void 0 : _this$_media2.removeEventListener("timeupdate", this._mockWaitingByTimeupdate);
30816
- if (this._media) {
30856
+ if (this._media && !((_this$_opts = this._opts) !== null && _this$_opts !== void 0 && _this$_opts.seamlesslyReload)) {
30817
30857
  this._media.srcObject = null;
30818
30858
  }
30859
+ this._closeLastPc();
30819
30860
  if (this._pc) {
30820
30861
  this._pc.close();
30821
30862
  }
@@ -30913,15 +30954,35 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
30913
30954
  }
30914
30955
  _this = _super.call.apply(_super, [this].concat(args));
30915
30956
  _defineProperty$c(_assertThisInitialized$b(_this), "_rts", null);
30957
+ _defineProperty$c(_assertThisInitialized$b(_this), "_mediaStream", null);
30916
30958
  _defineProperty$c(_assertThisInitialized$b(_this), "_rtsOpts", null);
30959
+ _defineProperty$c(_assertThisInitialized$b(_this), "_onPause", function() {
30960
+ var _this$_rts, _this$_rts2, _this$config, _this$_rts4;
30961
+ if (!((_this$_rts = _this._rts) !== null && _this$_rts !== void 0 && _this$_rts._pc) || (_this$_rts2 = _this._rts) !== null && _this$_rts2 !== void 0 && _this$_rts2._isReplacing) {
30962
+ return;
30963
+ }
30964
+ if ((_this$config = _this.config) !== null && _this$config !== void 0 && _this$config.seamlesslyReload) {
30965
+ var _this$_rts3;
30966
+ _this._mediaStream = (_this$_rts3 = _this._rts) === null || _this$_rts3 === void 0 ? void 0 : _this$_rts3._mediaStream;
30967
+ }
30968
+ (_this$_rts4 = _this._rts) === null || _this$_rts4 === void 0 ? void 0 : _this$_rts4.destroy();
30969
+ });
30970
+ _defineProperty$c(_assertThisInitialized$b(_this), "_onPlay", function() {
30971
+ var _this$_rts5, _this$_rts6;
30972
+ if ((_this$_rts5 = _this._rts) !== null && _this$_rts5 !== void 0 && _this$_rts5._pc || (_this$_rts6 = _this._rts) !== null && _this$_rts6 !== void 0 && _this$_rts6._isReplacing) {
30973
+ return;
30974
+ }
30975
+ _this._init();
30976
+ });
30917
30977
  _defineProperty$c(_assertThisInitialized$b(_this), "_init", function() {
30918
- var _this$_rts;
30919
- (_this$_rts = _this._rts) === null || _this$_rts === void 0 ? void 0 : _this$_rts.destroy();
30978
+ var _this$_rts7;
30979
+ (_this$_rts7 = _this._rts) === null || _this$_rts7 === void 0 ? void 0 : _this$_rts7.destroy();
30920
30980
  var config = _this.player.config;
30921
30981
  var rtsOpts = config.rts || {};
30922
30982
  _this._rtsOpts = rtsOpts;
30923
30983
  _this._rts = new Rts(_objectSpread2$7({
30924
30984
  media: _this.player.video,
30985
+ mediaStream: _this._mediaStream,
30925
30986
  preProcessUrl: function preProcessUrl(url, ext) {
30926
30987
  var _this$player$preProce, _this$player;
30927
30988
  return ((_this$player$preProce = (_this$player = _this.player).preProcessUrl) === null || _this$player$preProce === void 0 ? void 0 : _this$player$preProce.call(_this$player, url, ext)) || {
@@ -30932,36 +30993,39 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
30932
30993
  }, rtsOpts));
30933
30994
  _this._rts.load(config.url);
30934
30995
  });
30935
- _defineProperty$c(_assertThisInitialized$b(_this), "_onSwitchURL", function(url) {
30996
+ _defineProperty$c(_assertThisInitialized$b(_this), "_onSwitchURL", function(url, seamless) {
30936
30997
  if (_this._rts) {
30998
+ if (_typeof$7(seamless) === "object") {
30999
+ seamless = seamless.seamless;
31000
+ }
30937
31001
  _this.player.config.url = url;
30938
- _this._rts.switchURL(url);
31002
+ _this._rts.switchURL(url, seamless);
30939
31003
  }
30940
31004
  });
30941
31005
  _defineProperty$c(_assertThisInitialized$b(_this), "destroy", function() {
30942
- var _this$_rts2;
31006
+ var _this$_rts8;
30943
31007
  _this.player.switchURL = _this._originSwitchFn;
30944
- (_this$_rts2 = _this._rts) === null || _this$_rts2 === void 0 ? void 0 : _this$_rts2.destroy();
31008
+ (_this$_rts8 = _this._rts) === null || _this$_rts8 === void 0 ? void 0 : _this$_rts8.destroy();
30945
31009
  });
30946
31010
  return _this;
30947
31011
  }
30948
31012
  _createClass$e(RtsPlugin2, [{
30949
31013
  key: "pc",
30950
31014
  get: function get3() {
30951
- var _this$_rts3;
30952
- return (_this$_rts3 = this._rts) === null || _this$_rts3 === void 0 ? void 0 : _this$_rts3.pc;
31015
+ var _this$_rts9;
31016
+ return (_this$_rts9 = this._rts) === null || _this$_rts9 === void 0 ? void 0 : _this$_rts9.pc;
30953
31017
  }
30954
31018
  }, {
30955
31019
  key: "videoTrack",
30956
31020
  get: function get3() {
30957
- var _this$_rts4;
30958
- return (_this$_rts4 = this._rts) === null || _this$_rts4 === void 0 ? void 0 : _this$_rts4.videoTack;
31021
+ var _this$_rts10;
31022
+ return (_this$_rts10 = this._rts) === null || _this$_rts10 === void 0 ? void 0 : _this$_rts10.videoTack;
30959
31023
  }
30960
31024
  }, {
30961
31025
  key: "audioTrack",
30962
31026
  get: function get3() {
30963
- var _this$_rts5;
30964
- return (_this$_rts5 = this._rts) === null || _this$_rts5 === void 0 ? void 0 : _this$_rts5.audioTrack;
31027
+ var _this$_rts11;
31028
+ return (_this$_rts11 = this._rts) === null || _this$_rts11 === void 0 ? void 0 : _this$_rts11.audioTrack;
30965
31029
  }
30966
31030
  }, {
30967
31031
  key: "core",
@@ -30971,18 +31035,18 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
30971
31035
  }, {
30972
31036
  key: "loader",
30973
31037
  get: function get3() {
30974
- var _this$_rts6;
30975
- return (_this$_rts6 = this._rts) === null || _this$_rts6 === void 0 ? void 0 : _this$_rts6.loader;
31038
+ var _this$_rts12;
31039
+ return (_this$_rts12 = this._rts) === null || _this$_rts12 === void 0 ? void 0 : _this$_rts12.loader;
30976
31040
  }
30977
31041
  }, {
30978
31042
  key: "version",
30979
31043
  get: function get3() {
30980
- return "0.2.1-alpha.1";
31044
+ return "0.2.1-alpha.4";
30981
31045
  }
30982
31046
  }, {
30983
31047
  key: "beforePlayerInit",
30984
31048
  value: function beforePlayerInit() {
30985
- var _this$player2, _this2 = this;
31049
+ var _this$player2, _this2 = this, _this$player$config, _this$player$config$r;
30986
31050
  this._init();
30987
31051
  if (!this._originSwitchFn) {
30988
31052
  this._originSwitchFn = this.player.switchURL.bind(this.player);
@@ -30994,6 +31058,10 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
30994
31058
  });
30995
31059
  this.on(URL_CHANGE, this._onSwitchURL);
30996
31060
  this.on(DESTROY, this.destroy);
31061
+ if ((_this$player$config = this.player.config) !== null && _this$player$config !== void 0 && (_this$player$config$r = _this$player$config.rts) !== null && _this$player$config$r !== void 0 && _this$player$config$r.seamlesslyReload) {
31062
+ this.on(PAUSE, this._onPause);
31063
+ this.on(PLAY, this._onPlay);
31064
+ }
30997
31065
  this._transErrorEvent();
30998
31066
  this._transCoreEvent(EVENT$2.LOAD_START);
30999
31067
  this._transCoreEvent(EVENT$2.LOAD_COMPLETE);
@@ -31023,20 +31091,20 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
31023
31091
  }, {
31024
31092
  key: "getStats",
31025
31093
  value: function getStats2() {
31026
- var _this$_rts7;
31027
- return (_this$_rts7 = this._rts) === null || _this$_rts7 === void 0 ? void 0 : _this$_rts7.getStats();
31094
+ var _this$_rts13;
31095
+ return (_this$_rts13 = this._rts) === null || _this$_rts13 === void 0 ? void 0 : _this$_rts13.getStats();
31028
31096
  }
31029
31097
  }, {
31030
31098
  key: "getStatsSnapshoot",
31031
31099
  value: function getStatsSnapshoot2() {
31032
- var _this$_rts8;
31033
- return (_this$_rts8 = this._rts) === null || _this$_rts8 === void 0 ? void 0 : _this$_rts8.getStatsSnapshoot();
31100
+ var _this$_rts14;
31101
+ return (_this$_rts14 = this._rts) === null || _this$_rts14 === void 0 ? void 0 : _this$_rts14.getStatsSnapshoot();
31034
31102
  }
31035
31103
  }, {
31036
31104
  key: "getNetWorkInfo",
31037
31105
  value: function getNetWorkInfo() {
31038
- var _this$_rts9;
31039
- return (_this$_rts9 = this._rts) === null || _this$_rts9 === void 0 ? void 0 : _this$_rts9.networkStats;
31106
+ var _this$_rts15;
31107
+ return (_this$_rts15 = this._rts) === null || _this$_rts15 === void 0 ? void 0 : _this$_rts15.networkStats;
31040
31108
  }
31041
31109
  }, {
31042
31110
  key: "_transErrorEvent",
@@ -31073,14 +31141,8 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
31073
31141
  }
31074
31142
  player.config.url = backupURL;
31075
31143
  if (backupConstruct) {
31076
- if (!Array.isArray(backupConstruct)) {
31077
- backupConstruct = [backupConstruct];
31078
- }
31079
- backupConstruct.forEach(function(construct3) {
31080
- var _newPlugin$beforePlay;
31081
- var newPlugin = player.registerPlugin(construct3);
31082
- (_newPlugin$beforePlay = newPlugin.beforePlayerInit) === null || _newPlugin$beforePlay === void 0 ? void 0 : _newPlugin$beforePlay.call(newPlugin);
31083
- });
31144
+ var newPlugin = player.registerPlugin(backupConstruct);
31145
+ newPlugin.beforePlayerInit();
31084
31146
  } else {
31085
31147
  player.video.src = backupURL;
31086
31148
  }