@volcengine/veplayer-plugin 2.5.0-rc.0 → 2.5.0

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.
Files changed (43) hide show
  1. package/esm/index.d.ts +0 -1
  2. package/esm/index.development.css +0 -7
  3. package/esm/index.development.js +47254 -53339
  4. package/esm/index.production.css +1 -1
  5. package/esm/index.production.js +4 -13
  6. package/esm/veplayer.plugin.abr.development.js +12 -0
  7. package/esm/veplayer.plugin.abr.production.js +1 -1
  8. package/esm/veplayer.plugin.drm.development.js +12 -0
  9. package/esm/veplayer.plugin.drm.production.js +1 -1
  10. package/esm/veplayer.plugin.flv.development.js +670 -193
  11. package/esm/veplayer.plugin.flv.production.js +1 -1
  12. package/esm/veplayer.plugin.hls.development.js +1155 -371
  13. package/esm/veplayer.plugin.hls.production.js +1 -1
  14. package/esm/veplayer.plugin.mp4.development.js +13 -1
  15. package/esm/veplayer.plugin.mp4.production.js +1 -1
  16. package/esm/veplayer.plugin.rtm.development.js +154 -45
  17. package/esm/veplayer.plugin.rtm.production.js +1 -1
  18. package/esm/veplayer.plugin.shaka.development.js +12 -0
  19. package/esm/veplayer.plugin.shaka.production.js +1 -1
  20. package/package.json +1 -1
  21. package/umd/index.d.ts +0 -1
  22. package/umd/veplayer.plugin.abr.development.js +12 -0
  23. package/umd/veplayer.plugin.abr.production.js +1 -1
  24. package/umd/veplayer.plugin.drm.development.js +12 -0
  25. package/umd/veplayer.plugin.drm.production.js +1 -1
  26. package/umd/veplayer.plugin.flv.development.js +670 -193
  27. package/umd/veplayer.plugin.flv.production.js +1 -1
  28. package/umd/veplayer.plugin.hls.development.js +1122 -338
  29. package/umd/veplayer.plugin.hls.production.js +1 -1
  30. package/umd/veplayer.plugin.mp4.development.js +13 -1
  31. package/umd/veplayer.plugin.mp4.production.js +1 -1
  32. package/umd/veplayer.plugin.rtm.development.js +154 -45
  33. package/umd/veplayer.plugin.rtm.production.js +1 -1
  34. package/umd/veplayer.plugin.shaka.development.js +12 -0
  35. package/umd/veplayer.plugin.shaka.production.js +1 -1
  36. package/esm/veplayer.plugin.ad.development.css +0 -7
  37. package/esm/veplayer.plugin.ad.development.js +0 -9042
  38. package/esm/veplayer.plugin.ad.production.css +0 -1
  39. package/esm/veplayer.plugin.ad.production.js +0 -4
  40. package/umd/veplayer.plugin.ad.development.css +0 -7
  41. package/umd/veplayer.plugin.ad.development.js +0 -9045
  42. package/umd/veplayer.plugin.ad.production.css +0 -1
  43. package/umd/veplayer.plugin.ad.production.js +0 -1
@@ -1530,7 +1530,7 @@ util.getCurrentTimeByOffset = function(offsetTime, segments) {
1530
1530
  }
1531
1531
  return offsetTime;
1532
1532
  };
1533
- var version = "3.0.20-alpha.4";
1533
+ var version = "3.0.21-rc.2";
1534
1534
  var ERROR_MAP = {
1535
1535
  1: 5101,
1536
1536
  2: 5102,
@@ -1594,6 +1594,8 @@ var Errors = /* @__PURE__ */ _createClass$1(
1594
1594
  }
1595
1595
  }
1596
1596
  );
1597
+ var PLAY = "play";
1598
+ var PAUSE = "pause";
1597
1599
  var ERROR = "error";
1598
1600
  var DESTROY = "destroy";
1599
1601
  var URL_CHANGE = "urlchange";
@@ -1997,6 +1999,18 @@ var BasePlugin = /* @__PURE__ */ function() {
1997
1999
  }
1998
2000
  }
1999
2001
  }
2002
+ }, {
2003
+ key: "defineMethod",
2004
+ value: function defineMethod(Obj, map) {
2005
+ for (var key in map) {
2006
+ if (Object.prototype.hasOwnProperty.call(map, key) && typeof map[key] === "function") {
2007
+ Object.defineProperty(Obj, key, {
2008
+ configurable: true,
2009
+ value: map[key]
2010
+ });
2011
+ }
2012
+ }
2013
+ }
2000
2014
  }, {
2001
2015
  key: "defaultConfig",
2002
2016
  get: function get() {
@@ -4864,7 +4878,8 @@ function getOption(opts) {
4864
4878
  loadTimeout: 5e3,
4865
4879
  stallInterval: 400,
4866
4880
  networkEvaluateInterval: 1e3,
4867
- delayHint: 0
4881
+ delayHint: 0,
4882
+ seamlesslyReload: false
4868
4883
  }, opts);
4869
4884
  }
4870
4885
  function _getStats(stats) {
@@ -5127,6 +5142,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5127
5142
  _defineProperty$2(_assertThisInitialized$1(_this), "_audioTransceicer", null);
5128
5143
  _defineProperty$2(_assertThisInitialized$1(_this), "_videoTransceicer", null);
5129
5144
  _defineProperty$2(_assertThisInitialized$1(_this), "_mediaStream", null);
5145
+ _defineProperty$2(_assertThisInitialized$1(_this), "_lastMediaStream", null);
5130
5146
  _defineProperty$2(_assertThisInitialized$1(_this), "_media", null);
5131
5147
  _defineProperty$2(_assertThisInitialized$1(_this), "_opts", null);
5132
5148
  _defineProperty$2(_assertThisInitialized$1(_this), "_loader", null);
@@ -5134,19 +5150,10 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5134
5150
  _defineProperty$2(_assertThisInitialized$1(_this), "_retry", 0);
5135
5151
  _defineProperty$2(_assertThisInitialized$1(_this), "_waitingTimer", 0);
5136
5152
  _defineProperty$2(_assertThisInitialized$1(_this), "_rctConnectStartTs", 0);
5153
+ _defineProperty$2(_assertThisInitialized$1(_this), "_isReplacing", false);
5137
5154
  _defineProperty$2(_assertThisInitialized$1(_this), "_onTrack", function(e) {
5138
5155
  logger.log("addTrack: ", e.track, e.streams);
5139
5156
  _this["_".concat(e.track.kind)] = e.track;
5140
- if (!_this._mediaStream) {
5141
- _this._mediaStream = new MediaStream();
5142
- _this._media.srcObject = _this._mediaStream;
5143
- var req = _this._media.play();
5144
- if (req && req.catch) {
5145
- req.catch(function(e2) {
5146
- });
5147
- }
5148
- }
5149
- _this._mediaStream.addTrack(e.track);
5150
5157
  });
5151
5158
  _defineProperty$2(_assertThisInitialized$1(_this), "_mockWaitingByTimeupdate", function() {
5152
5159
  var _this$_pc, _this$_pc2;
@@ -5194,6 +5201,9 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5194
5201
  }));
5195
5202
  _this._retry = _this._opts.retryCount;
5196
5203
  _this._bindMediaEvent();
5204
+ if (_this._opts.mediaStream && _this._opts.seamlesslyReload) {
5205
+ _this._lastMediaStream = _this._opts.mediaStream;
5206
+ }
5197
5207
  return _this;
5198
5208
  }
5199
5209
  _createClass$2(Rts2, [{
@@ -5305,6 +5315,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5305
5315
  _this3.load(_this3._url);
5306
5316
  }
5307
5317
  if (pc.connectionState === "connected") {
5318
+ _this3._handleMediaStream();
5308
5319
  _this3.emit(EVENT.TTFB, {
5309
5320
  url: _this3._url,
5310
5321
  responseUrl: _this3._url,
@@ -5313,6 +5324,40 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5313
5324
  }
5314
5325
  });
5315
5326
  }
5327
+ }, {
5328
+ key: "_handleMediaStream",
5329
+ value: function _handleMediaStream() {
5330
+ var _this4 = this;
5331
+ if (this._lastMediaStream) {
5332
+ var _this$_media$play;
5333
+ var videoTrack = this._lastMediaStream.getVideoTracks()[0];
5334
+ var audioTrack = this._lastMediaStream.getAudioTracks()[0];
5335
+ if (videoTrack) {
5336
+ this._lastMediaStream.removeTrack(videoTrack);
5337
+ }
5338
+ if (audioTrack) {
5339
+ this._lastMediaStream.removeTrack(audioTrack);
5340
+ }
5341
+ this._mediaStream = this._lastMediaStream;
5342
+ this._audio && this._mediaStream.addTrack(this._audio);
5343
+ this._video && this._mediaStream.addTrack(this._video);
5344
+ this._isReplacing = true;
5345
+ this._media.pause();
5346
+ (_this$_media$play = this._media.play()) === null || _this$_media$play === void 0 ? void 0 : _this$_media$play.finally(function() {
5347
+ _this4._isReplacing = false;
5348
+ });
5349
+ } else {
5350
+ this._mediaStream = new MediaStream();
5351
+ this._audio && this._mediaStream.addTrack(this._audio);
5352
+ this._video && this._mediaStream.addTrack(this._video);
5353
+ this._media.srcObject = this._mediaStream;
5354
+ var req = this._media.play();
5355
+ if (req && req.catch) {
5356
+ req.catch(function(e) {
5357
+ });
5358
+ }
5359
+ }
5360
+ }
5316
5361
  }, {
5317
5362
  key: "_bindMediaEvent",
5318
5363
  value: function _bindMediaEvent() {
@@ -5485,11 +5530,11 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5485
5530
  }
5486
5531
  }, {
5487
5532
  key: "destroy",
5488
- value: function destroy() {
5533
+ value: function destroy(keepClearMediaStream) {
5489
5534
  var _this$_media2;
5490
5535
  this._disconnect();
5491
5536
  (_this$_media2 = this._media) === null || _this$_media2 === void 0 ? void 0 : _this$_media2.removeEventListener("timeupdate", this._mockWaitingByTimeupdate);
5492
- if (this._media) {
5537
+ if (this._media && !keepClearMediaStream) {
5493
5538
  this._media.srcObject = null;
5494
5539
  }
5495
5540
  if (this._pc) {
@@ -5589,15 +5634,36 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
5589
5634
  }
5590
5635
  _this = _super.call.apply(_super, [this].concat(args));
5591
5636
  _defineProperty$2(_assertThisInitialized$1(_this), "_rts", null);
5637
+ _defineProperty$2(_assertThisInitialized$1(_this), "_mediaStream", null);
5638
+ _defineProperty$2(_assertThisInitialized$1(_this), "_disconnectTimer", void 0);
5592
5639
  _defineProperty$2(_assertThisInitialized$1(_this), "_rtsOpts", null);
5593
- _defineProperty$2(_assertThisInitialized$1(_this), "_init", function() {
5640
+ _defineProperty$2(_assertThisInitialized$1(_this), "_onPause", function() {
5641
+ if (_this._disconnectTimer) {
5642
+ return;
5643
+ }
5644
+ _this._disconnectTimer = setTimeout(function() {
5645
+ _this._closeAfterPause();
5646
+ _this._clearDisconnectTimer();
5647
+ }, _this.config.disconnectTime * 1e3);
5648
+ });
5649
+ _defineProperty$2(_assertThisInitialized$1(_this), "_reInit", function() {
5594
5650
  var _this$_rts;
5595
- (_this$_rts = _this._rts) === null || _this$_rts === void 0 ? void 0 : _this$_rts.destroy();
5651
+ _this._clearDisconnectTimer();
5652
+ if ((_this$_rts = _this._rts) !== null && _this$_rts !== void 0 && _this$_rts._pc) {
5653
+ return;
5654
+ }
5655
+ _this._init();
5656
+ _this._bindRtsEvents();
5657
+ });
5658
+ _defineProperty$2(_assertThisInitialized$1(_this), "_init", function() {
5659
+ var _this$_rts2;
5660
+ (_this$_rts2 = _this._rts) === null || _this$_rts2 === void 0 ? void 0 : _this$_rts2.destroy();
5596
5661
  var config = _this.player.config;
5597
5662
  var rtsOpts = config.rts || {};
5598
5663
  _this._rtsOpts = rtsOpts;
5599
5664
  _this._rts = new Rts(_objectSpread2$2({
5600
5665
  media: _this.player.video,
5666
+ mediaStream: _this._mediaStream,
5601
5667
  preProcessUrl: function preProcessUrl(url, ext) {
5602
5668
  var _this$player$preProce, _this$player;
5603
5669
  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)) || {
@@ -5609,35 +5675,40 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
5609
5675
  _this._rts.load(config.url);
5610
5676
  });
5611
5677
  _defineProperty$2(_assertThisInitialized$1(_this), "_onSwitchURL", function(url) {
5612
- if (_this._rts) {
5678
+ if (url) {
5613
5679
  _this.player.config.url = url;
5680
+ }
5681
+ if (_this._rts) {
5614
5682
  _this._rts.switchURL(url);
5683
+ } else {
5684
+ _this._reInit();
5615
5685
  }
5616
5686
  });
5617
5687
  _defineProperty$2(_assertThisInitialized$1(_this), "destroy", function() {
5618
- var _this$_rts2;
5688
+ var _this$_rts3;
5619
5689
  _this.player.switchURL = _this._originSwitchFn;
5620
- (_this$_rts2 = _this._rts) === null || _this$_rts2 === void 0 ? void 0 : _this$_rts2.destroy();
5690
+ _this._clearDisconnectTimer();
5691
+ (_this$_rts3 = _this._rts) === null || _this$_rts3 === void 0 ? void 0 : _this$_rts3.destroy();
5621
5692
  });
5622
5693
  return _this;
5623
5694
  }
5624
5695
  _createClass$2(RtsPlugin2, [{
5625
5696
  key: "pc",
5626
5697
  get: function get() {
5627
- var _this$_rts3;
5628
- return (_this$_rts3 = this._rts) === null || _this$_rts3 === void 0 ? void 0 : _this$_rts3.pc;
5698
+ var _this$_rts4;
5699
+ return (_this$_rts4 = this._rts) === null || _this$_rts4 === void 0 ? void 0 : _this$_rts4.pc;
5629
5700
  }
5630
5701
  }, {
5631
5702
  key: "videoTrack",
5632
5703
  get: function get() {
5633
- var _this$_rts4;
5634
- return (_this$_rts4 = this._rts) === null || _this$_rts4 === void 0 ? void 0 : _this$_rts4.videoTack;
5704
+ var _this$_rts5;
5705
+ return (_this$_rts5 = this._rts) === null || _this$_rts5 === void 0 ? void 0 : _this$_rts5.videoTack;
5635
5706
  }
5636
5707
  }, {
5637
5708
  key: "audioTrack",
5638
5709
  get: function get() {
5639
- var _this$_rts5;
5640
- return (_this$_rts5 = this._rts) === null || _this$_rts5 === void 0 ? void 0 : _this$_rts5.audioTrack;
5710
+ var _this$_rts6;
5711
+ return (_this$_rts6 = this._rts) === null || _this$_rts6 === void 0 ? void 0 : _this$_rts6.audioTrack;
5641
5712
  }
5642
5713
  }, {
5643
5714
  key: "core",
@@ -5647,37 +5718,43 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
5647
5718
  }, {
5648
5719
  key: "loader",
5649
5720
  get: function get() {
5650
- var _this$_rts6;
5651
- return (_this$_rts6 = this._rts) === null || _this$_rts6 === void 0 ? void 0 : _this$_rts6.loader;
5721
+ var _this$_rts7;
5722
+ return (_this$_rts7 = this._rts) === null || _this$_rts7 === void 0 ? void 0 : _this$_rts7.loader;
5652
5723
  }
5653
5724
  }, {
5654
5725
  key: "version",
5655
5726
  get: function get() {
5656
- return "0.2.1-alpha.0";
5727
+ return "0.2.1-alpha.12";
5657
5728
  }
5658
5729
  }, {
5659
5730
  key: "beforePlayerInit",
5660
5731
  value: function beforePlayerInit() {
5661
- var _this$player2, _this2 = this;
5732
+ var _this$player2, _this2 = this, _this$player$config, _this$player$config$r;
5662
5733
  this._init();
5663
5734
  if (!this._originSwitchFn) {
5664
5735
  this._originSwitchFn = this.player.switchURL.bind(this.player);
5665
5736
  }
5666
5737
  this.player.switchURL = this._onSwitchURL;
5667
5738
  (_this$player2 = this.player) === null || _this$player2 === void 0 ? void 0 : _this$player2.useHooks("replay", function() {
5668
- var _this2$_rts;
5669
- return (_this2$_rts = _this2._rts) === null || _this2$_rts === void 0 ? void 0 : _this2$_rts.switchURL();
5739
+ return _this2._onSwitchURL();
5670
5740
  });
5671
5741
  this.on(URL_CHANGE, this._onSwitchURL);
5672
5742
  this.on(DESTROY, this.destroy);
5673
- this._transErrorEvent();
5674
- this._transCoreEvent(EVENT.LOAD_START);
5675
- this._transCoreEvent(EVENT.LOAD_COMPLETE);
5676
- this._transCoreEvent(EVENT.TTFB);
5677
- this._transCoreEvent(EVENT.LOAD_RESPONSE_HEADERS);
5678
- this._transCoreEvent(EVENT.LOAD_RETRY);
5679
- this._transCoreEvent(EVENT.METADATA_PARSED);
5680
- this._transCoreEvent(EXTEND_EVENTS.RTC_STATE_CHANGE);
5743
+ if (typeof ((_this$player$config = this.player.config) === null || _this$player$config === void 0 ? void 0 : (_this$player$config$r = _this$player$config.rts) === null || _this$player$config$r === void 0 ? void 0 : _this$player$config$r.disconnectTime) !== "undefined") {
5744
+ this.on(PAUSE, function() {
5745
+ var _this2$_rts;
5746
+ if (!((_this2$_rts = _this2._rts) !== null && _this2$_rts !== void 0 && _this2$_rts._isReplacing)) {
5747
+ _this2._onPause();
5748
+ }
5749
+ });
5750
+ this.on(PLAY, function() {
5751
+ var _this2$_rts2;
5752
+ if (!((_this2$_rts2 = _this2._rts) !== null && _this2$_rts2 !== void 0 && _this2$_rts2._isReplacing)) {
5753
+ _this2._reInit();
5754
+ }
5755
+ });
5756
+ }
5757
+ this._bindRtsEvents();
5681
5758
  try {
5682
5759
  BasePlugin.defineGetterOrSetter(this.player, {
5683
5760
  __url: {
@@ -5699,20 +5776,52 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
5699
5776
  }, {
5700
5777
  key: "getStats",
5701
5778
  value: function getStats2() {
5702
- var _this$_rts7;
5703
- return (_this$_rts7 = this._rts) === null || _this$_rts7 === void 0 ? void 0 : _this$_rts7.getStats();
5779
+ var _this$_rts8;
5780
+ return (_this$_rts8 = this._rts) === null || _this$_rts8 === void 0 ? void 0 : _this$_rts8.getStats();
5704
5781
  }
5705
5782
  }, {
5706
5783
  key: "getStatsSnapshoot",
5707
5784
  value: function getStatsSnapshoot2() {
5708
- var _this$_rts8;
5709
- return (_this$_rts8 = this._rts) === null || _this$_rts8 === void 0 ? void 0 : _this$_rts8.getStatsSnapshoot();
5785
+ var _this$_rts9;
5786
+ return (_this$_rts9 = this._rts) === null || _this$_rts9 === void 0 ? void 0 : _this$_rts9.getStatsSnapshoot();
5710
5787
  }
5711
5788
  }, {
5712
5789
  key: "getNetWorkInfo",
5713
5790
  value: function getNetWorkInfo() {
5714
- var _this$_rts9;
5715
- return (_this$_rts9 = this._rts) === null || _this$_rts9 === void 0 ? void 0 : _this$_rts9.networkStats;
5791
+ var _this$_rts10;
5792
+ return (_this$_rts10 = this._rts) === null || _this$_rts10 === void 0 ? void 0 : _this$_rts10.networkStats;
5793
+ }
5794
+ }, {
5795
+ key: "_clearDisconnectTimer",
5796
+ value: function _clearDisconnectTimer() {
5797
+ clearTimeout(this._disconnectTimer);
5798
+ this._disconnectTimer = void 0;
5799
+ }
5800
+ }, {
5801
+ key: "_closeAfterPause",
5802
+ value: function _closeAfterPause() {
5803
+ var _this$_rts11, _this$config, _this$_rts13;
5804
+ if (!((_this$_rts11 = this._rts) !== null && _this$_rts11 !== void 0 && _this$_rts11._pc)) {
5805
+ return;
5806
+ }
5807
+ if ((_this$config = this.config) !== null && _this$config !== void 0 && _this$config.seamlesslyReload) {
5808
+ var _this$_rts12;
5809
+ this._mediaStream = (_this$_rts12 = this._rts) === null || _this$_rts12 === void 0 ? void 0 : _this$_rts12._mediaStream;
5810
+ }
5811
+ (_this$_rts13 = this._rts) === null || _this$_rts13 === void 0 ? void 0 : _this$_rts13.destroy(true);
5812
+ this._rts = null;
5813
+ }
5814
+ }, {
5815
+ key: "_bindRtsEvents",
5816
+ value: function _bindRtsEvents() {
5817
+ this._transErrorEvent();
5818
+ this._transCoreEvent(EVENT.LOAD_START);
5819
+ this._transCoreEvent(EVENT.LOAD_COMPLETE);
5820
+ this._transCoreEvent(EVENT.TTFB);
5821
+ this._transCoreEvent(EVENT.LOAD_RESPONSE_HEADERS);
5822
+ this._transCoreEvent(EVENT.LOAD_RETRY);
5823
+ this._transCoreEvent(EVENT.METADATA_PARSED);
5824
+ this._transCoreEvent(EXTEND_EVENTS.RTC_STATE_CHANGE);
5716
5825
  }
5717
5826
  }, {
5718
5827
  key: "_transErrorEvent",