streamit-player 1.0.0 → 1.0.2

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.
@@ -4848,7 +4848,7 @@ var StreamitPlayer = function(exports) {
4848
4848
  if (this.hls) {
4849
4849
  this.isAutoMode = index === 0;
4850
4850
  const levelIndex = index - 1;
4851
- this.hls.currentLevel = levelIndex;
4851
+ this.hls.nextLevel = levelIndex;
4852
4852
  if (levelIndex === -1) {
4853
4853
  this.lastLevelIndex = -1;
4854
4854
  } else {
@@ -4908,17 +4908,12 @@ var StreamitPlayer = function(exports) {
4908
4908
  } catch {
4909
4909
  }
4910
4910
  };
4911
- this.handleLivePositionChange = () => {
4912
- var _a2;
4913
- if (!this.player || !this.video) return;
4914
- try {
4915
- if (!this.player.isDynamic()) return;
4916
- const target = (_a2 = this.getRawLiveInfo()) == null ? void 0 : _a2.liveEdgeTarget;
4917
- if (target == null || this.video.currentTime <= 0) return;
4918
- this.followingLive = target - this.video.currentTime <= LOW_LATENCY_LIVE_EDGE_SECONDS;
4919
- this.syncLiveCatchup();
4920
- } catch {
4921
- }
4911
+ this.handleResume = () => {
4912
+ if (this.video) this.recordViewerPosition(this.video.currentTime);
4913
+ };
4914
+ this.handleLiveEdgeSync = () => {
4915
+ this.followingLive = true;
4916
+ this.syncLiveCatchup();
4922
4917
  };
4923
4918
  this.handleTrackChangeRendered = (e2) => {
4924
4919
  if (!this.player || !this.controller) return;
@@ -5216,6 +5211,22 @@ var StreamitPlayer = function(exports) {
5216
5211
  }
5217
5212
  }
5218
5213
  }
5214
+ /**
5215
+ * Records whether the viewer is following the live edge, given a position they chose.
5216
+ * Only viewer actions call this: seeks made by dash.js itself must not count.
5217
+ */
5218
+ recordViewerPosition(position) {
5219
+ var _a2;
5220
+ if (!this.player) return;
5221
+ try {
5222
+ if (!this.player.isDynamic()) return;
5223
+ const target = (_a2 = this.getRawLiveInfo()) == null ? void 0 : _a2.liveEdgeTarget;
5224
+ if (target == null || position <= 0) return;
5225
+ this.followingLive = target - position <= LOW_LATENCY_LIVE_EDGE_SECONDS;
5226
+ this.syncLiveCatchup();
5227
+ } catch {
5228
+ }
5229
+ }
5219
5230
  normalizeQualityIndex(value) {
5220
5231
  return typeof value === "number" && Number.isInteger(value) && value >= 0 ? value : -1;
5221
5232
  }
@@ -5246,9 +5257,9 @@ var StreamitPlayer = function(exports) {
5246
5257
  this.dashRetryCount = 0;
5247
5258
  this.followingLive = true;
5248
5259
  this.catchupEnabled = null;
5249
- video.addEventListener("seeking", this.handleLivePositionChange);
5250
- video.addEventListener("play", this.handleLivePositionChange);
5260
+ video.addEventListener("play", this.handleResume);
5251
5261
  video.addEventListener("timeupdate", this.syncLiveCatchup);
5262
+ controller.addEventListener("live-edge-sync", this.handleLiveEdgeSync);
5252
5263
  loadDashjs().then((dashjsModule) => {
5253
5264
  var _a2;
5254
5265
  if (this.controller !== controller) {
@@ -5602,11 +5613,12 @@ var StreamitPlayer = function(exports) {
5602
5613
  this.controller.updateStatePublic({ activeQuality });
5603
5614
  }
5604
5615
  destroy() {
5616
+ var _a2;
5605
5617
  if (this.video) {
5606
- this.video.removeEventListener("seeking", this.handleLivePositionChange);
5607
- this.video.removeEventListener("play", this.handleLivePositionChange);
5618
+ this.video.removeEventListener("play", this.handleResume);
5608
5619
  this.video.removeEventListener("timeupdate", this.syncLiveCatchup);
5609
5620
  }
5621
+ (_a2 = this.controller) == null ? void 0 : _a2.removeEventListener("live-edge-sync", this.handleLiveEdgeSync);
5610
5622
  if (this.player) {
5611
5623
  try {
5612
5624
  if (this.eventNames.trackChangeRendered)
@@ -5642,8 +5654,16 @@ var StreamitPlayer = function(exports) {
5642
5654
  this.videoRepresentations = [];
5643
5655
  this.uniqueAudioTracks = [];
5644
5656
  }
5645
- seek(_time) {
5646
- return false;
5657
+ seek(time) {
5658
+ this.recordViewerPosition(time);
5659
+ if (!this.player) return false;
5660
+ try {
5661
+ if (!this.player.isDynamic()) return false;
5662
+ this.player.seekToPresentationTime(time);
5663
+ return true;
5664
+ } catch {
5665
+ return false;
5666
+ }
5647
5667
  }
5648
5668
  setQuality(index) {
5649
5669
  if (this.player) {
@@ -5672,7 +5692,7 @@ var StreamitPlayer = function(exports) {
5672
5692
  if (playerWithABR.setRepresentationForTypeById) {
5673
5693
  playerWithABR.setRepresentationForTypeById("video", targetRep.id);
5674
5694
  } else if (playerWithABR.setQualityFor) {
5675
- playerWithABR.setQualityFor("video", levelIndex, true);
5695
+ playerWithABR.setQualityFor("video", levelIndex, false);
5676
5696
  }
5677
5697
  this.lastQualityIndex = levelIndex;
5678
5698
  }