@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
@@ -1534,7 +1534,7 @@
1534
1534
  }
1535
1535
  return offsetTime;
1536
1536
  };
1537
- var version = "3.0.20-alpha.4";
1537
+ var version = "3.0.21-rc.2";
1538
1538
  var ERROR_MAP = {
1539
1539
  1: 5101,
1540
1540
  2: 5102,
@@ -1598,6 +1598,8 @@
1598
1598
  }
1599
1599
  }
1600
1600
  );
1601
+ var PLAY = "play";
1602
+ var PAUSE = "pause";
1601
1603
  var ERROR = "error";
1602
1604
  var DESTROY = "destroy";
1603
1605
  var URL_CHANGE = "urlchange";
@@ -2001,6 +2003,18 @@
2001
2003
  }
2002
2004
  }
2003
2005
  }
2006
+ }, {
2007
+ key: "defineMethod",
2008
+ value: function defineMethod(Obj, map) {
2009
+ for (var key in map) {
2010
+ if (Object.prototype.hasOwnProperty.call(map, key) && typeof map[key] === "function") {
2011
+ Object.defineProperty(Obj, key, {
2012
+ configurable: true,
2013
+ value: map[key]
2014
+ });
2015
+ }
2016
+ }
2017
+ }
2004
2018
  }, {
2005
2019
  key: "defaultConfig",
2006
2020
  get: function get() {
@@ -4868,7 +4882,8 @@
4868
4882
  loadTimeout: 5e3,
4869
4883
  stallInterval: 400,
4870
4884
  networkEvaluateInterval: 1e3,
4871
- delayHint: 0
4885
+ delayHint: 0,
4886
+ seamlesslyReload: false
4872
4887
  }, opts);
4873
4888
  }
4874
4889
  function _getStats(stats) {
@@ -5131,6 +5146,7 @@
5131
5146
  _defineProperty$2(_assertThisInitialized$1(_this), "_audioTransceicer", null);
5132
5147
  _defineProperty$2(_assertThisInitialized$1(_this), "_videoTransceicer", null);
5133
5148
  _defineProperty$2(_assertThisInitialized$1(_this), "_mediaStream", null);
5149
+ _defineProperty$2(_assertThisInitialized$1(_this), "_lastMediaStream", null);
5134
5150
  _defineProperty$2(_assertThisInitialized$1(_this), "_media", null);
5135
5151
  _defineProperty$2(_assertThisInitialized$1(_this), "_opts", null);
5136
5152
  _defineProperty$2(_assertThisInitialized$1(_this), "_loader", null);
@@ -5138,19 +5154,10 @@
5138
5154
  _defineProperty$2(_assertThisInitialized$1(_this), "_retry", 0);
5139
5155
  _defineProperty$2(_assertThisInitialized$1(_this), "_waitingTimer", 0);
5140
5156
  _defineProperty$2(_assertThisInitialized$1(_this), "_rctConnectStartTs", 0);
5157
+ _defineProperty$2(_assertThisInitialized$1(_this), "_isReplacing", false);
5141
5158
  _defineProperty$2(_assertThisInitialized$1(_this), "_onTrack", function(e) {
5142
5159
  logger.log("addTrack: ", e.track, e.streams);
5143
5160
  _this["_".concat(e.track.kind)] = e.track;
5144
- if (!_this._mediaStream) {
5145
- _this._mediaStream = new MediaStream();
5146
- _this._media.srcObject = _this._mediaStream;
5147
- var req = _this._media.play();
5148
- if (req && req.catch) {
5149
- req.catch(function(e2) {
5150
- });
5151
- }
5152
- }
5153
- _this._mediaStream.addTrack(e.track);
5154
5161
  });
5155
5162
  _defineProperty$2(_assertThisInitialized$1(_this), "_mockWaitingByTimeupdate", function() {
5156
5163
  var _this$_pc, _this$_pc2;
@@ -5198,6 +5205,9 @@
5198
5205
  }));
5199
5206
  _this._retry = _this._opts.retryCount;
5200
5207
  _this._bindMediaEvent();
5208
+ if (_this._opts.mediaStream && _this._opts.seamlesslyReload) {
5209
+ _this._lastMediaStream = _this._opts.mediaStream;
5210
+ }
5201
5211
  return _this;
5202
5212
  }
5203
5213
  _createClass$2(Rts2, [{
@@ -5309,6 +5319,7 @@
5309
5319
  _this3.load(_this3._url);
5310
5320
  }
5311
5321
  if (pc.connectionState === "connected") {
5322
+ _this3._handleMediaStream();
5312
5323
  _this3.emit(EVENT.TTFB, {
5313
5324
  url: _this3._url,
5314
5325
  responseUrl: _this3._url,
@@ -5317,6 +5328,40 @@
5317
5328
  }
5318
5329
  });
5319
5330
  }
5331
+ }, {
5332
+ key: "_handleMediaStream",
5333
+ value: function _handleMediaStream() {
5334
+ var _this4 = this;
5335
+ if (this._lastMediaStream) {
5336
+ var _this$_media$play;
5337
+ var videoTrack = this._lastMediaStream.getVideoTracks()[0];
5338
+ var audioTrack = this._lastMediaStream.getAudioTracks()[0];
5339
+ if (videoTrack) {
5340
+ this._lastMediaStream.removeTrack(videoTrack);
5341
+ }
5342
+ if (audioTrack) {
5343
+ this._lastMediaStream.removeTrack(audioTrack);
5344
+ }
5345
+ this._mediaStream = this._lastMediaStream;
5346
+ this._audio && this._mediaStream.addTrack(this._audio);
5347
+ this._video && this._mediaStream.addTrack(this._video);
5348
+ this._isReplacing = true;
5349
+ this._media.pause();
5350
+ (_this$_media$play = this._media.play()) === null || _this$_media$play === void 0 ? void 0 : _this$_media$play.finally(function() {
5351
+ _this4._isReplacing = false;
5352
+ });
5353
+ } else {
5354
+ this._mediaStream = new MediaStream();
5355
+ this._audio && this._mediaStream.addTrack(this._audio);
5356
+ this._video && this._mediaStream.addTrack(this._video);
5357
+ this._media.srcObject = this._mediaStream;
5358
+ var req = this._media.play();
5359
+ if (req && req.catch) {
5360
+ req.catch(function(e) {
5361
+ });
5362
+ }
5363
+ }
5364
+ }
5320
5365
  }, {
5321
5366
  key: "_bindMediaEvent",
5322
5367
  value: function _bindMediaEvent() {
@@ -5489,11 +5534,11 @@
5489
5534
  }
5490
5535
  }, {
5491
5536
  key: "destroy",
5492
- value: function destroy() {
5537
+ value: function destroy(keepClearMediaStream) {
5493
5538
  var _this$_media2;
5494
5539
  this._disconnect();
5495
5540
  (_this$_media2 = this._media) === null || _this$_media2 === void 0 ? void 0 : _this$_media2.removeEventListener("timeupdate", this._mockWaitingByTimeupdate);
5496
- if (this._media) {
5541
+ if (this._media && !keepClearMediaStream) {
5497
5542
  this._media.srcObject = null;
5498
5543
  }
5499
5544
  if (this._pc) {
@@ -5593,15 +5638,36 @@
5593
5638
  }
5594
5639
  _this = _super.call.apply(_super, [this].concat(args));
5595
5640
  _defineProperty$2(_assertThisInitialized$1(_this), "_rts", null);
5641
+ _defineProperty$2(_assertThisInitialized$1(_this), "_mediaStream", null);
5642
+ _defineProperty$2(_assertThisInitialized$1(_this), "_disconnectTimer", void 0);
5596
5643
  _defineProperty$2(_assertThisInitialized$1(_this), "_rtsOpts", null);
5597
- _defineProperty$2(_assertThisInitialized$1(_this), "_init", function() {
5644
+ _defineProperty$2(_assertThisInitialized$1(_this), "_onPause", function() {
5645
+ if (_this._disconnectTimer) {
5646
+ return;
5647
+ }
5648
+ _this._disconnectTimer = setTimeout(function() {
5649
+ _this._closeAfterPause();
5650
+ _this._clearDisconnectTimer();
5651
+ }, _this.config.disconnectTime * 1e3);
5652
+ });
5653
+ _defineProperty$2(_assertThisInitialized$1(_this), "_reInit", function() {
5598
5654
  var _this$_rts;
5599
- (_this$_rts = _this._rts) === null || _this$_rts === void 0 ? void 0 : _this$_rts.destroy();
5655
+ _this._clearDisconnectTimer();
5656
+ if ((_this$_rts = _this._rts) !== null && _this$_rts !== void 0 && _this$_rts._pc) {
5657
+ return;
5658
+ }
5659
+ _this._init();
5660
+ _this._bindRtsEvents();
5661
+ });
5662
+ _defineProperty$2(_assertThisInitialized$1(_this), "_init", function() {
5663
+ var _this$_rts2;
5664
+ (_this$_rts2 = _this._rts) === null || _this$_rts2 === void 0 ? void 0 : _this$_rts2.destroy();
5600
5665
  var config = _this.player.config;
5601
5666
  var rtsOpts = config.rts || {};
5602
5667
  _this._rtsOpts = rtsOpts;
5603
5668
  _this._rts = new Rts(_objectSpread2$2({
5604
5669
  media: _this.player.video,
5670
+ mediaStream: _this._mediaStream,
5605
5671
  preProcessUrl: function preProcessUrl(url, ext) {
5606
5672
  var _this$player$preProce, _this$player;
5607
5673
  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)) || {
@@ -5613,35 +5679,40 @@
5613
5679
  _this._rts.load(config.url);
5614
5680
  });
5615
5681
  _defineProperty$2(_assertThisInitialized$1(_this), "_onSwitchURL", function(url) {
5616
- if (_this._rts) {
5682
+ if (url) {
5617
5683
  _this.player.config.url = url;
5684
+ }
5685
+ if (_this._rts) {
5618
5686
  _this._rts.switchURL(url);
5687
+ } else {
5688
+ _this._reInit();
5619
5689
  }
5620
5690
  });
5621
5691
  _defineProperty$2(_assertThisInitialized$1(_this), "destroy", function() {
5622
- var _this$_rts2;
5692
+ var _this$_rts3;
5623
5693
  _this.player.switchURL = _this._originSwitchFn;
5624
- (_this$_rts2 = _this._rts) === null || _this$_rts2 === void 0 ? void 0 : _this$_rts2.destroy();
5694
+ _this._clearDisconnectTimer();
5695
+ (_this$_rts3 = _this._rts) === null || _this$_rts3 === void 0 ? void 0 : _this$_rts3.destroy();
5625
5696
  });
5626
5697
  return _this;
5627
5698
  }
5628
5699
  _createClass$2(RtsPlugin2, [{
5629
5700
  key: "pc",
5630
5701
  get: function get() {
5631
- var _this$_rts3;
5632
- return (_this$_rts3 = this._rts) === null || _this$_rts3 === void 0 ? void 0 : _this$_rts3.pc;
5702
+ var _this$_rts4;
5703
+ return (_this$_rts4 = this._rts) === null || _this$_rts4 === void 0 ? void 0 : _this$_rts4.pc;
5633
5704
  }
5634
5705
  }, {
5635
5706
  key: "videoTrack",
5636
5707
  get: function get() {
5637
- var _this$_rts4;
5638
- return (_this$_rts4 = this._rts) === null || _this$_rts4 === void 0 ? void 0 : _this$_rts4.videoTack;
5708
+ var _this$_rts5;
5709
+ return (_this$_rts5 = this._rts) === null || _this$_rts5 === void 0 ? void 0 : _this$_rts5.videoTack;
5639
5710
  }
5640
5711
  }, {
5641
5712
  key: "audioTrack",
5642
5713
  get: function get() {
5643
- var _this$_rts5;
5644
- return (_this$_rts5 = this._rts) === null || _this$_rts5 === void 0 ? void 0 : _this$_rts5.audioTrack;
5714
+ var _this$_rts6;
5715
+ return (_this$_rts6 = this._rts) === null || _this$_rts6 === void 0 ? void 0 : _this$_rts6.audioTrack;
5645
5716
  }
5646
5717
  }, {
5647
5718
  key: "core",
@@ -5651,37 +5722,43 @@
5651
5722
  }, {
5652
5723
  key: "loader",
5653
5724
  get: function get() {
5654
- var _this$_rts6;
5655
- return (_this$_rts6 = this._rts) === null || _this$_rts6 === void 0 ? void 0 : _this$_rts6.loader;
5725
+ var _this$_rts7;
5726
+ return (_this$_rts7 = this._rts) === null || _this$_rts7 === void 0 ? void 0 : _this$_rts7.loader;
5656
5727
  }
5657
5728
  }, {
5658
5729
  key: "version",
5659
5730
  get: function get() {
5660
- return "0.2.1-alpha.0";
5731
+ return "0.2.1-alpha.12";
5661
5732
  }
5662
5733
  }, {
5663
5734
  key: "beforePlayerInit",
5664
5735
  value: function beforePlayerInit() {
5665
- var _this$player2, _this2 = this;
5736
+ var _this$player2, _this2 = this, _this$player$config, _this$player$config$r;
5666
5737
  this._init();
5667
5738
  if (!this._originSwitchFn) {
5668
5739
  this._originSwitchFn = this.player.switchURL.bind(this.player);
5669
5740
  }
5670
5741
  this.player.switchURL = this._onSwitchURL;
5671
5742
  (_this$player2 = this.player) === null || _this$player2 === void 0 ? void 0 : _this$player2.useHooks("replay", function() {
5672
- var _this2$_rts;
5673
- return (_this2$_rts = _this2._rts) === null || _this2$_rts === void 0 ? void 0 : _this2$_rts.switchURL();
5743
+ return _this2._onSwitchURL();
5674
5744
  });
5675
5745
  this.on(URL_CHANGE, this._onSwitchURL);
5676
5746
  this.on(DESTROY, this.destroy);
5677
- this._transErrorEvent();
5678
- this._transCoreEvent(EVENT.LOAD_START);
5679
- this._transCoreEvent(EVENT.LOAD_COMPLETE);
5680
- this._transCoreEvent(EVENT.TTFB);
5681
- this._transCoreEvent(EVENT.LOAD_RESPONSE_HEADERS);
5682
- this._transCoreEvent(EVENT.LOAD_RETRY);
5683
- this._transCoreEvent(EVENT.METADATA_PARSED);
5684
- this._transCoreEvent(EXTEND_EVENTS.RTC_STATE_CHANGE);
5747
+ 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") {
5748
+ this.on(PAUSE, function() {
5749
+ var _this2$_rts;
5750
+ if (!((_this2$_rts = _this2._rts) !== null && _this2$_rts !== void 0 && _this2$_rts._isReplacing)) {
5751
+ _this2._onPause();
5752
+ }
5753
+ });
5754
+ this.on(PLAY, function() {
5755
+ var _this2$_rts2;
5756
+ if (!((_this2$_rts2 = _this2._rts) !== null && _this2$_rts2 !== void 0 && _this2$_rts2._isReplacing)) {
5757
+ _this2._reInit();
5758
+ }
5759
+ });
5760
+ }
5761
+ this._bindRtsEvents();
5685
5762
  try {
5686
5763
  BasePlugin.defineGetterOrSetter(this.player, {
5687
5764
  __url: {
@@ -5703,20 +5780,52 @@
5703
5780
  }, {
5704
5781
  key: "getStats",
5705
5782
  value: function getStats2() {
5706
- var _this$_rts7;
5707
- return (_this$_rts7 = this._rts) === null || _this$_rts7 === void 0 ? void 0 : _this$_rts7.getStats();
5783
+ var _this$_rts8;
5784
+ return (_this$_rts8 = this._rts) === null || _this$_rts8 === void 0 ? void 0 : _this$_rts8.getStats();
5708
5785
  }
5709
5786
  }, {
5710
5787
  key: "getStatsSnapshoot",
5711
5788
  value: function getStatsSnapshoot2() {
5712
- var _this$_rts8;
5713
- return (_this$_rts8 = this._rts) === null || _this$_rts8 === void 0 ? void 0 : _this$_rts8.getStatsSnapshoot();
5789
+ var _this$_rts9;
5790
+ return (_this$_rts9 = this._rts) === null || _this$_rts9 === void 0 ? void 0 : _this$_rts9.getStatsSnapshoot();
5714
5791
  }
5715
5792
  }, {
5716
5793
  key: "getNetWorkInfo",
5717
5794
  value: function getNetWorkInfo() {
5718
- var _this$_rts9;
5719
- return (_this$_rts9 = this._rts) === null || _this$_rts9 === void 0 ? void 0 : _this$_rts9.networkStats;
5795
+ var _this$_rts10;
5796
+ return (_this$_rts10 = this._rts) === null || _this$_rts10 === void 0 ? void 0 : _this$_rts10.networkStats;
5797
+ }
5798
+ }, {
5799
+ key: "_clearDisconnectTimer",
5800
+ value: function _clearDisconnectTimer() {
5801
+ clearTimeout(this._disconnectTimer);
5802
+ this._disconnectTimer = void 0;
5803
+ }
5804
+ }, {
5805
+ key: "_closeAfterPause",
5806
+ value: function _closeAfterPause() {
5807
+ var _this$_rts11, _this$config, _this$_rts13;
5808
+ if (!((_this$_rts11 = this._rts) !== null && _this$_rts11 !== void 0 && _this$_rts11._pc)) {
5809
+ return;
5810
+ }
5811
+ if ((_this$config = this.config) !== null && _this$config !== void 0 && _this$config.seamlesslyReload) {
5812
+ var _this$_rts12;
5813
+ this._mediaStream = (_this$_rts12 = this._rts) === null || _this$_rts12 === void 0 ? void 0 : _this$_rts12._mediaStream;
5814
+ }
5815
+ (_this$_rts13 = this._rts) === null || _this$_rts13 === void 0 ? void 0 : _this$_rts13.destroy(true);
5816
+ this._rts = null;
5817
+ }
5818
+ }, {
5819
+ key: "_bindRtsEvents",
5820
+ value: function _bindRtsEvents() {
5821
+ this._transErrorEvent();
5822
+ this._transCoreEvent(EVENT.LOAD_START);
5823
+ this._transCoreEvent(EVENT.LOAD_COMPLETE);
5824
+ this._transCoreEvent(EVENT.TTFB);
5825
+ this._transCoreEvent(EVENT.LOAD_RESPONSE_HEADERS);
5826
+ this._transCoreEvent(EVENT.LOAD_RETRY);
5827
+ this._transCoreEvent(EVENT.METADATA_PARSED);
5828
+ this._transCoreEvent(EXTEND_EVENTS.RTC_STATE_CHANGE);
5720
5829
  }
5721
5830
  }, {
5722
5831
  key: "_transErrorEvent",