@give-tech/ec-player 0.0.1-beta.7 → 0.0.1-beta.8

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
@@ -1759,33 +1759,46 @@ class HLSPlayer extends BasePlayer {
1759
1759
  * 解析 fMP4 数据
1760
1760
  */
1761
1761
  parseFMP4Data(data) {
1762
- let moofOffset = -1;
1763
- let mdatOffset = -1;
1764
- let mdatSize = 0;
1762
+ let totalSampleCount = 0;
1765
1763
  let offset = 0;
1766
1764
  while (offset < data.length - 8) {
1767
- const boxSize = this.readBoxSize(data, offset);
1768
- const boxType = this.readBoxType(data, offset + 4);
1769
- if (boxType === "moof") {
1770
- moofOffset = offset;
1771
- } else if (boxType === "mdat") {
1772
- mdatOffset = offset;
1773
- mdatSize = boxSize;
1774
- break;
1765
+ let moofOffset = -1;
1766
+ let mdatOffset = -1;
1767
+ let mdatSize = 0;
1768
+ while (offset < data.length - 8) {
1769
+ const boxSize = this.readBoxSize(data, offset);
1770
+ const boxType = this.readBoxType(data, offset + 4);
1771
+ if (boxSize < 8) break;
1772
+ if (boxType === "moof") {
1773
+ moofOffset = offset;
1774
+ offset += boxSize;
1775
+ break;
1776
+ }
1777
+ offset += boxSize;
1778
+ }
1779
+ if (moofOffset < 0) break;
1780
+ while (offset < data.length - 8) {
1781
+ const boxSize = this.readBoxSize(data, offset);
1782
+ const boxType = this.readBoxType(data, offset + 4);
1783
+ if (boxSize < 8) break;
1784
+ if (boxType === "mdat") {
1785
+ mdatOffset = offset;
1786
+ mdatSize = boxSize;
1787
+ offset += boxSize;
1788
+ break;
1789
+ }
1790
+ offset += boxSize;
1775
1791
  }
1776
- offset += boxSize;
1777
- }
1778
- let sampleCount = 0;
1779
- if (moofOffset >= 0 && mdatOffset >= 0) {
1792
+ if (mdatOffset < 0) break;
1780
1793
  const moof = this.fmp4Demuxer.parseMoof(data, moofOffset);
1781
1794
  const mdatData = data.slice(mdatOffset + 8, mdatOffset + mdatSize);
1782
1795
  const samples = this.fmp4Demuxer.extractSamples(moof, mdatData, mdatOffset);
1783
1796
  for (const sample of samples) {
1784
1797
  this._sampleQueue.push({ sample });
1785
1798
  }
1786
- sampleCount = samples.length;
1799
+ totalSampleCount += samples.length;
1787
1800
  }
1788
- return sampleCount;
1801
+ return totalSampleCount;
1789
1802
  }
1790
1803
  /**
1791
1804
  * 解析 TS 数据