@byteplus/veplayer-plugin 2.5.0 → 2.6.0-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.
Files changed (31) hide show
  1. package/esm/index.d.ts +1 -0
  2. package/esm/index.development.css +11 -0
  3. package/esm/index.development.js +42959 -31350
  4. package/esm/index.production.css +1 -1
  5. package/esm/index.production.js +13 -4
  6. package/esm/veplayer.plugin.ad.development.css +11 -0
  7. package/esm/veplayer.plugin.ad.development.js +13318 -0
  8. package/esm/veplayer.plugin.ad.production.css +1 -0
  9. package/esm/veplayer.plugin.ad.production.js +4 -0
  10. package/esm/veplayer.plugin.flv.development.js +2 -2
  11. package/esm/veplayer.plugin.flv.production.js +1 -1
  12. package/esm/veplayer.plugin.hls.development.js +11 -5
  13. package/esm/veplayer.plugin.hls.production.js +1 -1
  14. package/esm/veplayer.plugin.mp4.development.js +1 -1
  15. package/esm/veplayer.plugin.mp4.production.js +1 -1
  16. package/esm/veplayer.plugin.rtm.development.js +45 -142
  17. package/esm/veplayer.plugin.rtm.production.js +1 -1
  18. package/package.json +1 -1
  19. package/umd/index.d.ts +1 -0
  20. package/umd/veplayer.plugin.ad.development.css +11 -0
  21. package/umd/veplayer.plugin.ad.development.js +13321 -0
  22. package/umd/veplayer.plugin.ad.production.css +1 -0
  23. package/umd/veplayer.plugin.ad.production.js +1 -0
  24. package/umd/veplayer.plugin.flv.development.js +2 -2
  25. package/umd/veplayer.plugin.flv.production.js +1 -1
  26. package/umd/veplayer.plugin.hls.development.js +11 -5
  27. package/umd/veplayer.plugin.hls.production.js +1 -1
  28. package/umd/veplayer.plugin.mp4.development.js +1 -1
  29. package/umd/veplayer.plugin.mp4.production.js +1 -1
  30. package/umd/veplayer.plugin.rtm.development.js +45 -142
  31. package/umd/veplayer.plugin.rtm.production.js +1 -1
@@ -1530,7 +1530,7 @@ util.getCurrentTimeByOffset = function(offsetTime, segments) {
1530
1530
  }
1531
1531
  return offsetTime;
1532
1532
  };
1533
- var version = "3.0.21-rc.2";
1533
+ var version = "3.0.21-rc.3";
1534
1534
  var ERROR_MAP = {
1535
1535
  1: 5101,
1536
1536
  2: 5102,
@@ -1594,8 +1594,6 @@ var Errors = /* @__PURE__ */ _createClass$1(
1594
1594
  }
1595
1595
  }
1596
1596
  );
1597
- var PLAY = "play";
1598
- var PAUSE = "pause";
1599
1597
  var ERROR = "error";
1600
1598
  var DESTROY = "destroy";
1601
1599
  var URL_CHANGE = "urlchange";
@@ -4878,8 +4876,7 @@ function getOption(opts) {
4878
4876
  loadTimeout: 5e3,
4879
4877
  stallInterval: 400,
4880
4878
  networkEvaluateInterval: 1e3,
4881
- delayHint: 0,
4882
- seamlesslyReload: false
4879
+ delayHint: 0
4883
4880
  }, opts);
4884
4881
  }
4885
4882
  function _getStats(stats) {
@@ -5142,7 +5139,6 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5142
5139
  _defineProperty$2(_assertThisInitialized$1(_this), "_audioTransceicer", null);
5143
5140
  _defineProperty$2(_assertThisInitialized$1(_this), "_videoTransceicer", null);
5144
5141
  _defineProperty$2(_assertThisInitialized$1(_this), "_mediaStream", null);
5145
- _defineProperty$2(_assertThisInitialized$1(_this), "_lastMediaStream", null);
5146
5142
  _defineProperty$2(_assertThisInitialized$1(_this), "_media", null);
5147
5143
  _defineProperty$2(_assertThisInitialized$1(_this), "_opts", null);
5148
5144
  _defineProperty$2(_assertThisInitialized$1(_this), "_loader", null);
@@ -5150,10 +5146,19 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5150
5146
  _defineProperty$2(_assertThisInitialized$1(_this), "_retry", 0);
5151
5147
  _defineProperty$2(_assertThisInitialized$1(_this), "_waitingTimer", 0);
5152
5148
  _defineProperty$2(_assertThisInitialized$1(_this), "_rctConnectStartTs", 0);
5153
- _defineProperty$2(_assertThisInitialized$1(_this), "_isReplacing", false);
5154
5149
  _defineProperty$2(_assertThisInitialized$1(_this), "_onTrack", function(e) {
5155
5150
  logger.log("addTrack: ", e.track, e.streams);
5156
5151
  _this["_".concat(e.track.kind)] = e.track;
5152
+ if (!_this._mediaStream) {
5153
+ _this._mediaStream = new MediaStream();
5154
+ _this._media.srcObject = _this._mediaStream;
5155
+ var req = _this._media.play();
5156
+ if (req && req.catch) {
5157
+ req.catch(function(e2) {
5158
+ });
5159
+ }
5160
+ }
5161
+ _this._mediaStream.addTrack(e.track);
5157
5162
  });
5158
5163
  _defineProperty$2(_assertThisInitialized$1(_this), "_mockWaitingByTimeupdate", function() {
5159
5164
  var _this$_pc, _this$_pc2;
@@ -5201,9 +5206,6 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5201
5206
  }));
5202
5207
  _this._retry = _this._opts.retryCount;
5203
5208
  _this._bindMediaEvent();
5204
- if (_this._opts.mediaStream && _this._opts.seamlesslyReload) {
5205
- _this._lastMediaStream = _this._opts.mediaStream;
5206
- }
5207
5209
  return _this;
5208
5210
  }
5209
5211
  _createClass$2(Rts2, [{
@@ -5315,7 +5317,6 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5315
5317
  _this3.load(_this3._url);
5316
5318
  }
5317
5319
  if (pc.connectionState === "connected") {
5318
- _this3._handleMediaStream();
5319
5320
  _this3.emit(EVENT.TTFB, {
5320
5321
  url: _this3._url,
5321
5322
  responseUrl: _this3._url,
@@ -5324,40 +5325,6 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5324
5325
  }
5325
5326
  });
5326
5327
  }
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
- }
5361
5328
  }, {
5362
5329
  key: "_bindMediaEvent",
5363
5330
  value: function _bindMediaEvent() {
@@ -5530,11 +5497,11 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
5530
5497
  }
5531
5498
  }, {
5532
5499
  key: "destroy",
5533
- value: function destroy(keepClearMediaStream) {
5500
+ value: function destroy() {
5534
5501
  var _this$_media2;
5535
5502
  this._disconnect();
5536
5503
  (_this$_media2 = this._media) === null || _this$_media2 === void 0 ? void 0 : _this$_media2.removeEventListener("timeupdate", this._mockWaitingByTimeupdate);
5537
- if (this._media && !keepClearMediaStream) {
5504
+ if (this._media) {
5538
5505
  this._media.srcObject = null;
5539
5506
  }
5540
5507
  if (this._pc) {
@@ -5634,36 +5601,15 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
5634
5601
  }
5635
5602
  _this = _super.call.apply(_super, [this].concat(args));
5636
5603
  _defineProperty$2(_assertThisInitialized$1(_this), "_rts", null);
5637
- _defineProperty$2(_assertThisInitialized$1(_this), "_mediaStream", null);
5638
- _defineProperty$2(_assertThisInitialized$1(_this), "_disconnectTimer", void 0);
5639
5604
  _defineProperty$2(_assertThisInitialized$1(_this), "_rtsOpts", null);
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() {
5650
- var _this$_rts;
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
5605
  _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();
5606
+ var _this$_rts;
5607
+ (_this$_rts = _this._rts) === null || _this$_rts === void 0 ? void 0 : _this$_rts.destroy();
5661
5608
  var config = _this.player.config;
5662
5609
  var rtsOpts = config.rts || {};
5663
5610
  _this._rtsOpts = rtsOpts;
5664
5611
  _this._rts = new Rts(_objectSpread2$2({
5665
5612
  media: _this.player.video,
5666
- mediaStream: _this._mediaStream,
5667
5613
  preProcessUrl: function preProcessUrl(url, ext) {
5668
5614
  var _this$player$preProce, _this$player;
5669
5615
  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)) || {
@@ -5675,40 +5621,35 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
5675
5621
  _this._rts.load(config.url);
5676
5622
  });
5677
5623
  _defineProperty$2(_assertThisInitialized$1(_this), "_onSwitchURL", function(url) {
5678
- if (url) {
5679
- _this.player.config.url = url;
5680
- }
5681
5624
  if (_this._rts) {
5625
+ _this.player.config.url = url;
5682
5626
  _this._rts.switchURL(url);
5683
- } else {
5684
- _this._reInit();
5685
5627
  }
5686
5628
  });
5687
5629
  _defineProperty$2(_assertThisInitialized$1(_this), "destroy", function() {
5688
- var _this$_rts3;
5630
+ var _this$_rts2;
5689
5631
  _this.player.switchURL = _this._originSwitchFn;
5690
- _this._clearDisconnectTimer();
5691
- (_this$_rts3 = _this._rts) === null || _this$_rts3 === void 0 ? void 0 : _this$_rts3.destroy();
5632
+ (_this$_rts2 = _this._rts) === null || _this$_rts2 === void 0 ? void 0 : _this$_rts2.destroy();
5692
5633
  });
5693
5634
  return _this;
5694
5635
  }
5695
5636
  _createClass$2(RtsPlugin2, [{
5696
5637
  key: "pc",
5697
5638
  get: function get() {
5698
- var _this$_rts4;
5699
- return (_this$_rts4 = this._rts) === null || _this$_rts4 === void 0 ? void 0 : _this$_rts4.pc;
5639
+ var _this$_rts3;
5640
+ return (_this$_rts3 = this._rts) === null || _this$_rts3 === void 0 ? void 0 : _this$_rts3.pc;
5700
5641
  }
5701
5642
  }, {
5702
5643
  key: "videoTrack",
5703
5644
  get: function get() {
5704
- var _this$_rts5;
5705
- return (_this$_rts5 = this._rts) === null || _this$_rts5 === void 0 ? void 0 : _this$_rts5.videoTack;
5645
+ var _this$_rts4;
5646
+ return (_this$_rts4 = this._rts) === null || _this$_rts4 === void 0 ? void 0 : _this$_rts4.videoTack;
5706
5647
  }
5707
5648
  }, {
5708
5649
  key: "audioTrack",
5709
5650
  get: function get() {
5710
- var _this$_rts6;
5711
- return (_this$_rts6 = this._rts) === null || _this$_rts6 === void 0 ? void 0 : _this$_rts6.audioTrack;
5651
+ var _this$_rts5;
5652
+ return (_this$_rts5 = this._rts) === null || _this$_rts5 === void 0 ? void 0 : _this$_rts5.audioTrack;
5712
5653
  }
5713
5654
  }, {
5714
5655
  key: "core",
@@ -5718,43 +5659,37 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
5718
5659
  }, {
5719
5660
  key: "loader",
5720
5661
  get: function get() {
5721
- var _this$_rts7;
5722
- return (_this$_rts7 = this._rts) === null || _this$_rts7 === void 0 ? void 0 : _this$_rts7.loader;
5662
+ var _this$_rts6;
5663
+ return (_this$_rts6 = this._rts) === null || _this$_rts6 === void 0 ? void 0 : _this$_rts6.loader;
5723
5664
  }
5724
5665
  }, {
5725
5666
  key: "version",
5726
5667
  get: function get() {
5727
- return "0.2.1-alpha.12";
5668
+ return "0.2.1-alpha.0";
5728
5669
  }
5729
5670
  }, {
5730
5671
  key: "beforePlayerInit",
5731
5672
  value: function beforePlayerInit() {
5732
- var _this$player2, _this2 = this, _this$player$config, _this$player$config$r;
5673
+ var _this$player2, _this2 = this;
5733
5674
  this._init();
5734
5675
  if (!this._originSwitchFn) {
5735
5676
  this._originSwitchFn = this.player.switchURL.bind(this.player);
5736
5677
  }
5737
5678
  this.player.switchURL = this._onSwitchURL;
5738
5679
  (_this$player2 = this.player) === null || _this$player2 === void 0 ? void 0 : _this$player2.useHooks("replay", function() {
5739
- return _this2._onSwitchURL();
5680
+ var _this2$_rts;
5681
+ return (_this2$_rts = _this2._rts) === null || _this2$_rts === void 0 ? void 0 : _this2$_rts.switchURL();
5740
5682
  });
5741
5683
  this.on(URL_CHANGE, this._onSwitchURL);
5742
5684
  this.on(DESTROY, this.destroy);
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();
5685
+ this._transErrorEvent();
5686
+ this._transCoreEvent(EVENT.LOAD_START);
5687
+ this._transCoreEvent(EVENT.LOAD_COMPLETE);
5688
+ this._transCoreEvent(EVENT.TTFB);
5689
+ this._transCoreEvent(EVENT.LOAD_RESPONSE_HEADERS);
5690
+ this._transCoreEvent(EVENT.LOAD_RETRY);
5691
+ this._transCoreEvent(EVENT.METADATA_PARSED);
5692
+ this._transCoreEvent(EXTEND_EVENTS.RTC_STATE_CHANGE);
5758
5693
  try {
5759
5694
  BasePlugin.defineGetterOrSetter(this.player, {
5760
5695
  __url: {
@@ -5776,52 +5711,20 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
5776
5711
  }, {
5777
5712
  key: "getStats",
5778
5713
  value: function getStats2() {
5779
- var _this$_rts8;
5780
- return (_this$_rts8 = this._rts) === null || _this$_rts8 === void 0 ? void 0 : _this$_rts8.getStats();
5714
+ var _this$_rts7;
5715
+ return (_this$_rts7 = this._rts) === null || _this$_rts7 === void 0 ? void 0 : _this$_rts7.getStats();
5781
5716
  }
5782
5717
  }, {
5783
5718
  key: "getStatsSnapshoot",
5784
5719
  value: function getStatsSnapshoot2() {
5785
- var _this$_rts9;
5786
- return (_this$_rts9 = this._rts) === null || _this$_rts9 === void 0 ? void 0 : _this$_rts9.getStatsSnapshoot();
5720
+ var _this$_rts8;
5721
+ return (_this$_rts8 = this._rts) === null || _this$_rts8 === void 0 ? void 0 : _this$_rts8.getStatsSnapshoot();
5787
5722
  }
5788
5723
  }, {
5789
5724
  key: "getNetWorkInfo",
5790
5725
  value: function getNetWorkInfo() {
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);
5726
+ var _this$_rts9;
5727
+ return (_this$_rts9 = this._rts) === null || _this$_rts9 === void 0 ? void 0 : _this$_rts9.networkStats;
5825
5728
  }
5826
5729
  }, {
5827
5730
  key: "_transErrorEvent",