@give-tech/ec-player 0.0.1-beta.14 → 0.0.1-beta.16

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/dist/index.js CHANGED
@@ -1592,7 +1592,9 @@ class HLSPlayer extends BasePlayer {
1592
1592
  }
1593
1593
  } else {
1594
1594
  if (this.playStartTime !== 0) {
1595
+ const oldPlayStartTime = this.playStartTime;
1595
1596
  this.playStartTime = now - this.accumulatedMediaTime;
1597
+ console.log("[renderLoop] No frames, adjusting playStartTime from", oldPlayStartTime, "to", this.playStartTime, "accumulated=", this.accumulatedMediaTime);
1596
1598
  }
1597
1599
  }
1598
1600
  this.frameTimer = requestAnimationFrame(this.renderLoop);
@@ -1716,6 +1718,10 @@ class HLSPlayer extends BasePlayer {
1716
1718
  let batchCount = 0;
1717
1719
  while (this.isPlaying && !this.decodeLoopAbort) {
1718
1720
  this.prefetcher?.processQueue();
1721
+ if (!this.config.isLive && this.frameBuffer.length >= this.config.targetBufferSize) {
1722
+ await this.sleep(10);
1723
+ continue;
1724
+ }
1719
1725
  const batchSize = this.config.decodeBatchSize;
1720
1726
  let decodedInBatch = 0;
1721
1727
  if (this.isFMP4) {
@@ -1730,9 +1736,11 @@ class HLSPlayer extends BasePlayer {
1730
1736
  if (frame) {
1731
1737
  this.frameBuffer.push(frame);
1732
1738
  decodedInBatch++;
1733
- while (this.frameBuffer.length > this.config.targetBufferSize) {
1734
- this.frameBuffer.shift();
1735
- this.droppedFrames++;
1739
+ if (this.config.isLive) {
1740
+ while (this.frameBuffer.length > this.config.targetBufferSize) {
1741
+ this.frameBuffer.shift();
1742
+ this.droppedFrames++;
1743
+ }
1736
1744
  }
1737
1745
  }
1738
1746
  }
@@ -1748,9 +1756,11 @@ class HLSPlayer extends BasePlayer {
1748
1756
  if (frame) {
1749
1757
  this.frameBuffer.push(frame);
1750
1758
  decodedInBatch++;
1751
- while (this.frameBuffer.length > this.config.targetBufferSize) {
1752
- this.frameBuffer.shift();
1753
- this.droppedFrames++;
1759
+ if (this.config.isLive) {
1760
+ while (this.frameBuffer.length > this.config.targetBufferSize) {
1761
+ this.frameBuffer.shift();
1762
+ this.droppedFrames++;
1763
+ }
1754
1764
  }
1755
1765
  }
1756
1766
  }
@@ -1923,7 +1933,6 @@ class HLSPlayer extends BasePlayer {
1923
1933
  console.log("[fMP4] Loading new init segment for discontinuity:", uri);
1924
1934
  this._sampleQueue.length = 0;
1925
1935
  this._nalQueue.length = 0;
1926
- this.frameBuffer = [];
1927
1936
  const url = uri.startsWith("http") ? uri : this.currentPlaylistUrl.substring(0, this.currentPlaylistUrl.lastIndexOf("/") + 1) + uri;
1928
1937
  const response = await fetch(url);
1929
1938
  const data = new Uint8Array(await response.arrayBuffer());