@byteplus/veplayer-plugin 2.9.1 → 2.9.3-rc.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byteplus/veplayer-plugin",
3
- "version": "2.9.1",
3
+ "version": "2.9.3-rc.0",
4
4
  "main": "./umd/index.production.js",
5
5
  "module": "./esm/index.production.js",
6
6
  "browser": "./umd/index.production.js",
@@ -6759,6 +6759,16 @@
6759
6759
  }]);
6760
6760
  return NetworkQuality2;
6761
6761
  }();
6762
+ function changeNumberInRange(source, min, max, delta) {
6763
+ var target = source + delta;
6764
+ if (target > max) {
6765
+ target = source - delta;
6766
+ }
6767
+ return [source, target];
6768
+ }
6769
+ function isHarmonyOS() {
6770
+ return /(HarmonyOS|OpenHarmony|ArkWeb)/i.test(navigator.userAgent);
6771
+ }
6762
6772
  var logger = new Logger("rts");
6763
6773
  var Rts = /* @__PURE__ */ function(_EventEmitter) {
6764
6774
  _inherits$1(Rts2, _EventEmitter);
@@ -7052,6 +7062,7 @@
7052
7062
  }));
7053
7063
  _this._retry = _this._opts.retryCount;
7054
7064
  _this._bindMediaEvent();
7065
+ _this._changeVolumeInHarmonyWorkaround();
7055
7066
  if (_this._opts.mediaStream && _this._opts.seamlesslyReload) {
7056
7067
  _this._lastMediaStream = _this._opts.mediaStream;
7057
7068
  }
@@ -7676,11 +7687,42 @@
7676
7687
  }
7677
7688
  return _createEmptyPeer;
7678
7689
  }()
7690
+ }, {
7691
+ key: "_changeVolumeInHarmonyWorkaround",
7692
+ value: function _changeVolumeInHarmonyWorkaround() {
7693
+ var _this8 = this;
7694
+ if (isHarmonyOS()) {
7695
+ var originalDescriptor = Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, "muted");
7696
+ if (this._media && originalDescriptor) {
7697
+ logger.log("apply HarmonyOS muted workaround");
7698
+ Object.defineProperty(this._media, "muted", {
7699
+ configurable: true,
7700
+ enumerable: true,
7701
+ get: originalDescriptor.get,
7702
+ set: function set(val) {
7703
+ originalDescriptor.set.call(this, val);
7704
+ var _changeNumberInRange = changeNumberInRange(this.volume, 0, 1, 0.01), _changeNumberInRange2 = _slicedToArray(_changeNumberInRange, 2), sourceVolume = _changeNumberInRange2[0], targetVolume = _changeNumberInRange2[1];
7705
+ this.volume = targetVolume;
7706
+ this.volume = sourceVolume;
7707
+ logger.log("HarmonyOS muted workaround. set muted =", val, "volume:", targetVolume, "->", sourceVolume);
7708
+ }
7709
+ });
7710
+ this._revertVolumeWorkaround = function() {
7711
+ logger.log("revert HarmonyOS muted workaround. video dom:", _this8._media);
7712
+ if (_this8._media) {
7713
+ Object.defineProperty(_this8._media, "muted", originalDescriptor);
7714
+ }
7715
+ };
7716
+ }
7717
+ }
7718
+ }
7679
7719
  }, {
7680
7720
  key: "destroy",
7681
7721
  value: function destroy(keepClearMediaStream) {
7682
- var _this$_media2;
7722
+ var _this$_revertVolumeWo, _this$_media2;
7683
7723
  this._disconnect();
7724
+ (_this$_revertVolumeWo = this._revertVolumeWorkaround) === null || _this$_revertVolumeWo === void 0 ? void 0 : _this$_revertVolumeWo.call(this);
7725
+ delete this._revertVolumeWorkaround;
7684
7726
  (_this$_media2 = this._media) === null || _this$_media2 === void 0 ? void 0 : _this$_media2.removeEventListener("timeupdate", this._mockWaitingByTimeupdate);
7685
7727
  if (this._media && !keepClearMediaStream) {
7686
7728
  this._media.srcObject = null;
@@ -7816,7 +7858,7 @@
7816
7858
  }, {
7817
7859
  key: "version",
7818
7860
  get: function get() {
7819
- return "0.2.1-alpha.43";
7861
+ return "0.2.1-alpha.45";
7820
7862
  }
7821
7863
  }, {
7822
7864
  key: "beforePlayerInit",