@lazycatcloud/lzc-video-player 0.0.34 → 0.0.36

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.
@@ -31614,7 +31614,7 @@ function enableLogs(t, e) {
31614
31614
  "error"
31615
31615
  );
31616
31616
  try {
31617
- exportedLogger.log(`Debug logs enabled for "${e}" in hls.js version 1.5.8`);
31617
+ exportedLogger.log(`Debug logs enabled for "${e}" in hls.js version 1.5.18`);
31618
31618
  } catch {
31619
31619
  exportedLogger = fakeLogger;
31620
31620
  }
@@ -31983,11 +31983,19 @@ function keySystemFormatToKeySystemDomain(t) {
31983
31983
  }
31984
31984
  }
31985
31985
  var KeySystemIds = {
31986
+ CENC: "1077efecc0b24d02ace33c1e52e2fb4b",
31987
+ CLEARKEY: "e2719d58a985b3c9781ab030af78d30e",
31988
+ FAIRPLAY: "94ce86fb07ff4f43adb893d2fa968ca2",
31989
+ PLAYREADY: "9a04f07998404286ab92e65be0885f95",
31986
31990
  WIDEVINE: "edef8ba979d64acea3c827dcd51d21ed"
31987
31991
  };
31988
31992
  function keySystemIdToKeySystemDomain(t) {
31989
31993
  if (t === KeySystemIds.WIDEVINE)
31990
31994
  return KeySystems.WIDEVINE;
31995
+ if (t === KeySystemIds.PLAYREADY)
31996
+ return KeySystems.PLAYREADY;
31997
+ if (t === KeySystemIds.CENC || t === KeySystemIds.CLEARKEY)
31998
+ return KeySystems.CLEARKEY;
31991
31999
  }
31992
32000
  function keySystemDomainToKeySystemFormat(t) {
31993
32001
  switch (t) {
@@ -32449,7 +32457,7 @@ function parseSinf(t) {
32449
32457
  if (r === "cbcs" || r === "cenc")
32450
32458
  return findBox(t, ["schi", "tenc"])[0];
32451
32459
  }
32452
- return logger.error("[eme] missing 'schm' box"), null;
32460
+ return null;
32453
32461
  }
32454
32462
  function getStartDTS(t, e) {
32455
32463
  return findBox(e, ["moof", "traf"]).reduce((r, a) => {
@@ -32777,30 +32785,64 @@ function mp4pssh(t, e, r) {
32777
32785
  r || new Uint8Array()
32778
32786
  );
32779
32787
  }
32780
- function parsePssh(t) {
32781
- if (!(t instanceof ArrayBuffer) || t.byteLength < 32)
32782
- return null;
32783
- const e = {
32784
- version: 0,
32785
- systemId: "",
32786
- kids: null,
32787
- data: null
32788
- }, r = new DataView(t), a = r.getUint32(0);
32789
- if (t.byteLength !== a && a > 44 || r.getUint32(4) !== 1886614376 || (e.version = r.getUint32(8) >>> 24, e.version > 1))
32790
- return null;
32791
- e.systemId = Hex.hexDump(new Uint8Array(t, 12, 16));
32792
- const s = r.getUint32(28);
32793
- if (e.version === 0) {
32794
- if (a - 32 < s)
32795
- return null;
32796
- e.data = new Uint8Array(t, 32, s);
32797
- } else if (e.version === 1) {
32798
- e.kids = [];
32799
- for (let o = 0; o < s; o++)
32800
- e.kids.push(new Uint8Array(t, 32 + o * 16, 16));
32788
+ function parseMultiPssh(t) {
32789
+ const e = [];
32790
+ if (t instanceof ArrayBuffer) {
32791
+ const r = t.byteLength;
32792
+ let a = 0;
32793
+ for (; a + 32 < r; ) {
32794
+ const n = new DataView(t, a), s = parsePssh(n);
32795
+ e.push(s), a += s.size;
32796
+ }
32801
32797
  }
32802
32798
  return e;
32803
32799
  }
32800
+ function parsePssh(t) {
32801
+ const e = t.getUint32(0), r = t.byteOffset, a = t.byteLength;
32802
+ if (a < e)
32803
+ return {
32804
+ offset: r,
32805
+ size: a
32806
+ };
32807
+ if (t.getUint32(4) !== 1886614376)
32808
+ return {
32809
+ offset: r,
32810
+ size: e
32811
+ };
32812
+ const s = t.getUint32(8) >>> 24;
32813
+ if (s !== 0 && s !== 1)
32814
+ return {
32815
+ offset: r,
32816
+ size: e
32817
+ };
32818
+ const o = t.buffer, u = Hex.hexDump(new Uint8Array(o, r + 12, 16)), l = t.getUint32(28);
32819
+ let c = null, d = null;
32820
+ if (s === 0) {
32821
+ if (e - 32 < l || l < 22)
32822
+ return {
32823
+ offset: r,
32824
+ size: e
32825
+ };
32826
+ d = new Uint8Array(o, r + 32, l);
32827
+ } else if (s === 1) {
32828
+ if (!l || a < r + 32 + l * 16 + 16)
32829
+ return {
32830
+ offset: r,
32831
+ size: e
32832
+ };
32833
+ c = [];
32834
+ for (let f = 0; f < l; f++)
32835
+ c.push(new Uint8Array(o, r + 32 + f * 16, 16));
32836
+ }
32837
+ return {
32838
+ version: s,
32839
+ systemId: u,
32840
+ kids: c,
32841
+ data: d,
32842
+ offset: r,
32843
+ size: e
32844
+ };
32845
+ }
32804
32846
  let keyUriToKeyIdMap = {};
32805
32847
  class LevelKey {
32806
32848
  static clearKeyUriToKeyIdMap() {
@@ -33056,16 +33098,19 @@ function pickMostCompleteCodecName(t, e) {
33056
33098
  return t && t !== "mp4a" ? t : e && e.split(",")[0];
33057
33099
  }
33058
33100
  function convertAVC1ToAVCOTI(t) {
33059
- const e = t.split(".");
33060
- if (e.length > 2) {
33061
- let r = e.shift() + ".";
33062
- return r += parseInt(e.shift()).toString(16), r += ("000" + parseInt(e.shift()).toString(16)).slice(-4), r;
33101
+ const e = t.split(",");
33102
+ for (let r = 0; r < e.length; r++) {
33103
+ const a = e[r].split(".");
33104
+ if (a.length > 2) {
33105
+ let n = a.shift() + ".";
33106
+ n += parseInt(a.shift()).toString(16), n += ("000" + parseInt(a.shift()).toString(16)).slice(-4), e[r] = n;
33107
+ }
33063
33108
  }
33064
- return t;
33109
+ return e.join(",");
33065
33110
  }
33066
33111
  const MASTER_PLAYLIST_REGEX = /#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g, MASTER_PLAYLIST_MEDIA_REGEX = /#EXT-X-MEDIA:(.*)/g, IS_MEDIA_PLAYLIST = /^#EXT(?:INF|-X-TARGETDURATION):/m, LEVEL_PLAYLIST_REGEX_FAST = new RegExp([
33067
33112
  /#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,
33068
- /(?!#) *(\S[\S ]*)/.source,
33113
+ /(?!#) *(\S[^\r\n]*)/.source,
33069
33114
  /#EXT-X-BYTERANGE:*(.+)/.source,
33070
33115
  /#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,
33071
33116
  /#.*/.source
@@ -34554,18 +34599,25 @@ function findFragmentByPDT(t, e, r) {
34554
34599
  }
34555
34600
  return null;
34556
34601
  }
34557
- function findFragmentByPTS(t, e, r = 0, a = 0) {
34558
- let n = null;
34602
+ function findFragmentByPTS(t, e, r = 0, a = 0, n = 5e-3) {
34603
+ let s = null;
34559
34604
  if (t) {
34560
- n = e[t.sn - e[0].sn + 1] || null;
34561
- const o = t.endDTS - r;
34562
- o > 0 && o < 15e-7 && (r += 15e-7);
34605
+ s = e[t.sn - e[0].sn + 1] || null;
34606
+ const u = t.endDTS - r;
34607
+ u > 0 && u < 15e-7 && (r += 15e-7);
34563
34608
  } else
34564
- r === 0 && e[0].start === 0 && (n = e[0]);
34565
- if (n && (!t || t.level === n.level) && fragmentWithinToleranceTest(r, a, n) === 0)
34566
- return n;
34567
- const s = BinarySearch.search(e, fragmentWithinToleranceTest.bind(null, r, a));
34568
- return s && (s !== t || !n) ? s : n;
34609
+ r === 0 && e[0].start === 0 && (s = e[0]);
34610
+ if (s && ((!t || t.level === s.level) && fragmentWithinToleranceTest(r, a, s) === 0 || fragmentWithinFastStartSwitch(s, t, Math.min(n, a))))
34611
+ return s;
34612
+ const o = BinarySearch.search(e, fragmentWithinToleranceTest.bind(null, r, a));
34613
+ return o && (o !== t || !s) ? o : s;
34614
+ }
34615
+ function fragmentWithinFastStartSwitch(t, e, r) {
34616
+ if (e && e.start === 0 && e.level < t.level && (e.endPTS || 0) > 0) {
34617
+ const a = e.tagList.reduce((n, s) => (s[0] === "INF" && (n += parseFloat(s[1])), n), r);
34618
+ return t.start <= a;
34619
+ }
34620
+ return !1;
34569
34621
  }
34570
34622
  function fragmentWithinToleranceTest(t = 0, e = 0, r) {
34571
34623
  if (r.start <= t && r.start + r.duration > t)
@@ -34762,7 +34814,7 @@ class ErrorController {
34762
34814
  if (_ !== p && _ >= g && _ <= m && f[_].loadError === 0) {
34763
34815
  var u, l;
34764
34816
  const x = f[_];
34765
- if (c === ErrorDetails.FRAG_GAP && e.frag) {
34817
+ if (c === ErrorDetails.FRAG_GAP && v === PlaylistLevelType.MAIN && e.frag) {
34766
34818
  const D = f[_].details;
34767
34819
  if (D) {
34768
34820
  const C = findFragmentByPTS(e.frag, D.fragments, e.frag.start);
@@ -35252,7 +35304,7 @@ function findClosestLevelWithAudioGroup(t, e, r, a, n) {
35252
35304
  });
35253
35305
  }
35254
35306
  function searchDownAndUpList(t, e, r) {
35255
- for (let a = e; a; a--)
35307
+ for (let a = e; a > -1; a--)
35256
35308
  if (r(t[a]))
35257
35309
  return a;
35258
35310
  for (let a = e + 1; a < t.length; a++)
@@ -36318,7 +36370,7 @@ class Decrypter {
36318
36370
  a && (this.subtle = a.subtle || a.webkitSubtle);
36319
36371
  } catch {
36320
36372
  }
36321
- this.subtle === null && (this.useSoftware = !0);
36373
+ this.useSoftware = !this.subtle;
36322
36374
  }
36323
36375
  destroy() {
36324
36376
  this.subtle = null, this.softwareDecrypter = null, this.key = null, this.fastAesKey = null, this.remainderData = null, this.currentIV = null, this.currentResult = null;
@@ -36363,8 +36415,12 @@ class Decrypter {
36363
36415
  return this.currentResult = l.decrypt(u.buffer, 0, a), this.currentIV = sliceUint8(u, -16).buffer, c || null;
36364
36416
  }
36365
36417
  webCryptoDecrypt(e, r, a) {
36366
- const n = this.subtle;
36367
- return (this.key !== r || !this.fastAesKey) && (this.key = r, this.fastAesKey = new FastAESKey(n, r)), this.fastAesKey.expandKey().then((s) => n ? (this.logOnce("WebCrypto AES decrypt"), new AESCrypto(n, new Uint8Array(a)).decrypt(e.buffer, s)) : Promise.reject(new Error("web crypto not initialized"))).catch((s) => (logger.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${s.name}: ${s.message}`), this.onWebCryptoError(e, r, a)));
36418
+ if (this.key !== r || !this.fastAesKey) {
36419
+ if (!this.subtle)
36420
+ return Promise.resolve(this.onWebCryptoError(e, r, a));
36421
+ this.key = r, this.fastAesKey = new FastAESKey(this.subtle, r);
36422
+ }
36423
+ return this.fastAesKey.expandKey().then((n) => this.subtle ? (this.logOnce("WebCrypto AES decrypt"), new AESCrypto(this.subtle, new Uint8Array(a)).decrypt(e.buffer, n)) : Promise.reject(new Error("web crypto not initialized"))).catch((n) => (logger.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`), this.onWebCryptoError(e, r, a)));
36368
36424
  }
36369
36425
  onWebCryptoError(e, r, a) {
36370
36426
  this.useSoftware = !0, this.logEnabled = !0, this.softwareDecrypt(e, r, a);
@@ -36406,7 +36462,7 @@ const TimeRanges = {
36406
36462
  };
36407
36463
  class BaseStreamController extends TaskLoop {
36408
36464
  constructor(e, r, a, n, s) {
36409
- super(), this.hls = void 0, this.fragPrevious = null, this.fragCurrent = null, this.fragmentTracker = void 0, this.transmuxer = null, this._state = State$1.STOPPED, this.playlistType = void 0, this.media = null, this.mediaBuffer = null, this.config = void 0, this.bitrateTest = !1, this.lastCurrentTime = 0, this.nextLoadPosition = 0, this.startPosition = 0, this.startTimeOffset = null, this.loadedmetadata = !1, this.retryDate = 0, this.levels = null, this.fragmentLoader = void 0, this.keyLoader = void 0, this.levelLastLoaded = null, this.startFragRequested = !1, this.decrypter = void 0, this.initPTS = [], this.onvseeking = null, this.onvended = null, this.logPrefix = "", this.log = void 0, this.warn = void 0, this.playlistType = s, this.logPrefix = n, this.log = logger.log.bind(logger, `${n}:`), this.warn = logger.warn.bind(logger, `${n}:`), this.hls = e, this.fragmentLoader = new FragmentLoader(e.config), this.keyLoader = a, this.fragmentTracker = r, this.config = e.config, this.decrypter = new Decrypter(e.config), e.on(Events.MANIFEST_LOADED, this.onManifestLoaded, this);
36465
+ super(), this.hls = void 0, this.fragPrevious = null, this.fragCurrent = null, this.fragmentTracker = void 0, this.transmuxer = null, this._state = State$1.STOPPED, this.playlistType = void 0, this.media = null, this.mediaBuffer = null, this.config = void 0, this.bitrateTest = !1, this.lastCurrentTime = 0, this.nextLoadPosition = 0, this.startPosition = 0, this.startTimeOffset = null, this.loadedmetadata = !1, this.retryDate = 0, this.levels = null, this.fragmentLoader = void 0, this.keyLoader = void 0, this.levelLastLoaded = null, this.startFragRequested = !1, this.decrypter = void 0, this.initPTS = [], this.buffering = !0, this.onvseeking = null, this.onvended = null, this.logPrefix = "", this.log = void 0, this.warn = void 0, this.playlistType = s, this.logPrefix = n, this.log = logger.log.bind(logger, `${n}:`), this.warn = logger.warn.bind(logger, `${n}:`), this.hls = e, this.fragmentLoader = new FragmentLoader(e.config), this.keyLoader = a, this.fragmentTracker = r, this.config = e.config, this.decrypter = new Decrypter(e.config), e.on(Events.MANIFEST_LOADED, this.onManifestLoaded, this);
36410
36466
  }
36411
36467
  doTick() {
36412
36468
  this.onTickEnd();
@@ -36420,6 +36476,12 @@ class BaseStreamController extends TaskLoop {
36420
36476
  const e = this.fragCurrent;
36421
36477
  e != null && e.loader && (e.abortRequests(), this.fragmentTracker.removeFragment(e)), this.resetTransmuxer(), this.fragCurrent = null, this.fragPrevious = null, this.clearInterval(), this.clearNextTick(), this.state = State$1.STOPPED;
36422
36478
  }
36479
+ pauseBuffering() {
36480
+ this.buffering = !1;
36481
+ }
36482
+ resumeBuffering() {
36483
+ this.buffering = !0;
36484
+ }
36423
36485
  _streamEnded(e, r) {
36424
36486
  if (r.live || e.nextStart || !e.end || !this.media)
36425
36487
  return !1;
@@ -36499,7 +36561,7 @@ class BaseStreamController extends TaskLoop {
36499
36561
  }
36500
36562
  "payload" in s && (this.log(`Loaded fragment ${e.sn} of level ${e.level}`), this.hls.trigger(Events.FRAG_LOADED, s)), this._handleFragmentLoadComplete(s);
36501
36563
  }).catch((s) => {
36502
- this.state === State$1.STOPPED || this.state === State$1.ERROR || (this.warn(s), this.resetFragmentLoading(e));
36564
+ this.state === State$1.STOPPED || this.state === State$1.ERROR || (this.warn(`Frag error: ${(s == null ? void 0 : s.message) || s}`), this.resetFragmentLoading(e));
36503
36565
  });
36504
36566
  }
36505
36567
  clearTrackerIfNeeded(e) {
@@ -36508,8 +36570,8 @@ class BaseStreamController extends TaskLoop {
36508
36570
  fragmentTracker: a
36509
36571
  } = this;
36510
36572
  if (a.getState(e) === FragmentState.APPENDING) {
36511
- const s = e.type, o = this.getFwdBufferInfo(this.mediaBuffer, s), u = Math.max(e.duration, o ? o.len : this.config.maxBufferLength);
36512
- this.reduceMaxBufferLength(u) && a.removeFragment(e);
36573
+ const s = e.type, o = this.getFwdBufferInfo(this.mediaBuffer, s), u = Math.max(e.duration, o ? o.len : this.config.maxBufferLength), l = this.backtrackFragment;
36574
+ ((l ? e.sn - l.sn : 0) === 1 || this.reduceMaxBufferLength(u, e.duration)) && a.removeFragment(e);
36513
36575
  } else
36514
36576
  ((r = this.mediaBuffer) == null ? void 0 : r.buffered.length) === 0 ? a.removeAllFragments() : a.hasParts(e.type) && (a.detectPartialFragments({
36515
36577
  frag: e,
@@ -36792,9 +36854,9 @@ class BaseStreamController extends TaskLoop {
36792
36854
  let a;
36793
36855
  return e ? a = Math.max(8 * r.maxBufferSize / e, r.maxBufferLength) : a = r.maxBufferLength, Math.min(a, r.maxMaxBufferLength);
36794
36856
  }
36795
- reduceMaxBufferLength(e) {
36796
- const r = this.config, a = e || r.maxBufferLength;
36797
- return r.maxMaxBufferLength >= a ? (r.maxMaxBufferLength /= 2, this.warn(`Reduce max buffer length to ${r.maxMaxBufferLength}s`), !0) : !1;
36857
+ reduceMaxBufferLength(e, r) {
36858
+ const a = this.config, n = Math.max(Math.min(e - r, a.maxBufferLength), r), s = Math.max(e - r * 3, a.maxMaxBufferLength / 2, n);
36859
+ return s >= n ? (a.maxMaxBufferLength = s, this.warn(`Reduce max buffer length to ${s}s`), !0) : !1;
36798
36860
  }
36799
36861
  getAppendedFrag(e, r = PlaylistLevelType.MAIN) {
36800
36862
  const a = this.fragmentTracker.getAppendedFrag(e, PlaylistLevelType.MAIN);
@@ -36884,7 +36946,9 @@ class BaseStreamController extends TaskLoop {
36884
36946
  } = a;
36885
36947
  const {
36886
36948
  fragmentHint: l
36887
- } = a, c = n.maxFragLookUpTolerance, d = a.partList, f = !!(n.lowLatencyMode && d != null && d.length && l);
36949
+ } = a, {
36950
+ maxFragLookUpTolerance: c
36951
+ } = n, d = a.partList, f = !!(n.lowLatencyMode && d != null && d.length && l);
36888
36952
  f && l && !this.bitrateTest && (o = o.concat(l), u = l.sn);
36889
36953
  let p;
36890
36954
  if (e < r) {
@@ -36990,10 +37054,10 @@ class BaseStreamController extends TaskLoop {
36990
37054
  }
36991
37055
  reduceLengthAndFlushBuffer(e) {
36992
37056
  if (this.state === State$1.PARSING || this.state === State$1.PARSED) {
36993
- const r = e.parent, a = this.getFwdBufferInfo(this.mediaBuffer, r), n = a && a.len > 0.5;
36994
- n && this.reduceMaxBufferLength(a.len);
36995
- const s = !n;
36996
- return s && this.warn(`Buffer full error while media.currentTime is not buffered, flush ${r} buffer`), e.frag && (this.fragmentTracker.removeFragment(e.frag), this.nextLoadPosition = e.frag.start), this.resetLoadingState(), s;
37057
+ const r = e.frag, a = e.parent, n = this.getFwdBufferInfo(this.mediaBuffer, a), s = n && n.len > 0.5;
37058
+ s && this.reduceMaxBufferLength(n.len, (r == null ? void 0 : r.duration) || 10);
37059
+ const o = !s;
37060
+ return o && this.warn(`Buffer full error while media.currentTime is not buffered, flush ${a} buffer`), r && (this.fragmentTracker.removeFragment(r), this.nextLoadPosition = r.start), this.resetLoadingState(), o;
36997
37061
  }
36998
37062
  return !1;
36999
37063
  }
@@ -38098,7 +38162,7 @@ class TSDemuxer {
38098
38162
  break;
38099
38163
  case I: {
38100
38164
  x && (k += e[k] + 1);
38101
- const M = parsePMT(e, k, this.typeSupported, a);
38165
+ const M = parsePMT(e, k, this.typeSupported, a, this.observer);
38102
38166
  d = M.videoPid, d > 0 && (o.pid = d, o.segmentCodec = M.segmentVideoCodec), p = M.audioPid, p > 0 && (u.pid = p, u.segmentCodec = M.segmentAudioCodec), g = M.id3Pid, g > 0 && (l.pid = g), y !== null && !E && (logger.warn(`MPEG-TS PMT found at ${_} after unknown PID '${y}'. Backtracking to sync byte @${F} to parse all TS packets.`), y = null, _ = F - 188), E = this.pmtParsed = !0;
38103
38167
  break;
38104
38168
  }
@@ -38111,17 +38175,7 @@ class TSDemuxer {
38111
38175
  }
38112
38176
  } else
38113
38177
  N++;
38114
- if (N > 0) {
38115
- const _ = new Error(`Found ${N} TS packet/s that do not start with 0x47`);
38116
- this.observer.emit(Events.ERROR, Events.ERROR, {
38117
- type: ErrorTypes.MEDIA_ERROR,
38118
- details: ErrorDetails.FRAG_PARSING_ERROR,
38119
- fatal: !1,
38120
- error: _,
38121
- reason: _.message
38122
- });
38123
- }
38124
- o.pesData = f, u.pesData = m, l.pesData = v;
38178
+ N > 0 && emitParsingError(this.observer, new Error(`Found ${N} TS packet/s that do not start with 0x47`)), o.pesData = f, u.pesData = m, l.pesData = v;
38125
38179
  const S = {
38126
38180
  audioTrack: u,
38127
38181
  videoTrack: o,
@@ -38210,16 +38264,7 @@ class TSDemuxer {
38210
38264
  if (o !== a) {
38211
38265
  let f;
38212
38266
  const p = o < u - 1;
38213
- p ? f = `AAC PES did not start with ADTS header,offset:${o}` : f = "No ADTS header found in AAC PES";
38214
- const g = new Error(f);
38215
- if (logger.warn(`parsing error: ${f}`), this.observer.emit(Events.ERROR, Events.ERROR, {
38216
- type: ErrorTypes.MEDIA_ERROR,
38217
- details: ErrorDetails.FRAG_PARSING_ERROR,
38218
- fatal: !1,
38219
- levelRetry: p,
38220
- error: g,
38221
- reason: f
38222
- }), !p)
38267
+ if (p ? f = `AAC PES did not start with ADTS header,offset:${o}` : f = "No ADTS header found in AAC PES", emitParsingError(this.observer, new Error(f), p), !p)
38223
38268
  return;
38224
38269
  }
38225
38270
  initTrackConfig(e, this.observer, s, o, this.audioCodec);
@@ -38291,16 +38336,16 @@ function parsePID(t, e) {
38291
38336
  function parsePAT(t, e) {
38292
38337
  return (t[e + 10] & 31) << 8 | t[e + 11];
38293
38338
  }
38294
- function parsePMT(t, e, r, a) {
38295
- const n = {
38339
+ function parsePMT(t, e, r, a, n) {
38340
+ const s = {
38296
38341
  audioPid: -1,
38297
38342
  videoPid: -1,
38298
38343
  id3Pid: -1,
38299
38344
  segmentVideoCodec: "avc",
38300
38345
  segmentAudioCodec: "aac"
38301
- }, s = (t[e + 1] & 15) << 8 | t[e + 2], o = e + 3 + s - 4, u = (t[e + 10] & 15) << 8 | t[e + 11];
38302
- for (e += 12 + u; e < o; ) {
38303
- const l = parsePID(t, e), c = (t[e + 3] & 15) << 8 | t[e + 4];
38346
+ }, o = (t[e + 1] & 15) << 8 | t[e + 2], u = e + 3 + o - 4, l = (t[e + 10] & 15) << 8 | t[e + 11];
38347
+ for (e += 12 + l; e < u; ) {
38348
+ const c = parsePID(t, e), d = (t[e + 3] & 15) << 8 | t[e + 4];
38304
38349
  switch (t[e]) {
38305
38350
  case 207:
38306
38351
  if (!a) {
@@ -38308,10 +38353,10 @@ function parsePMT(t, e, r, a) {
38308
38353
  break;
38309
38354
  }
38310
38355
  case 15:
38311
- n.audioPid === -1 && (n.audioPid = l);
38356
+ s.audioPid === -1 && (s.audioPid = c);
38312
38357
  break;
38313
38358
  case 21:
38314
- n.id3Pid === -1 && (n.id3Pid = l);
38359
+ s.id3Pid === -1 && (s.id3Pid = c);
38315
38360
  break;
38316
38361
  case 219:
38317
38362
  if (!a) {
@@ -38319,11 +38364,11 @@ function parsePMT(t, e, r, a) {
38319
38364
  break;
38320
38365
  }
38321
38366
  case 27:
38322
- n.videoPid === -1 && (n.videoPid = l, n.segmentVideoCodec = "avc");
38367
+ s.videoPid === -1 && (s.videoPid = c, s.segmentVideoCodec = "avc");
38323
38368
  break;
38324
38369
  case 3:
38325
38370
  case 4:
38326
- !r.mpeg && !r.mp3 ? logger.log("MPEG audio found, not supported in this browser") : n.audioPid === -1 && (n.audioPid = l, n.segmentAudioCodec = "mp3");
38371
+ !r.mpeg && !r.mp3 ? logger.log("MPEG audio found, not supported in this browser") : s.audioPid === -1 && (s.audioPid = c, s.segmentAudioCodec = "mp3");
38327
38372
  break;
38328
38373
  case 193:
38329
38374
  if (!a) {
@@ -38331,33 +38376,41 @@ function parsePMT(t, e, r, a) {
38331
38376
  break;
38332
38377
  }
38333
38378
  case 129:
38334
- r.ac3 ? n.audioPid === -1 && (n.audioPid = l, n.segmentAudioCodec = "ac3") : logger.log("AC-3 audio found, not supported in this browser");
38379
+ r.ac3 ? s.audioPid === -1 && (s.audioPid = c, s.segmentAudioCodec = "ac3") : logger.log("AC-3 audio found, not supported in this browser");
38335
38380
  break;
38336
38381
  case 6:
38337
- if (n.audioPid === -1 && c > 0) {
38338
- let d = e + 5, f = c;
38339
- for (; f > 2; ) {
38340
- switch (t[d]) {
38382
+ if (s.audioPid === -1 && d > 0) {
38383
+ let f = e + 5, p = d;
38384
+ for (; p > 2; ) {
38385
+ switch (t[f]) {
38341
38386
  case 106:
38342
- r.ac3 !== !0 ? logger.log("AC-3 audio found, not supported in this browser for now") : (n.audioPid = l, n.segmentAudioCodec = "ac3");
38387
+ r.ac3 !== !0 ? logger.log("AC-3 audio found, not supported in this browser for now") : (s.audioPid = c, s.segmentAudioCodec = "ac3");
38343
38388
  break;
38344
38389
  }
38345
- const g = t[d + 1] + 2;
38346
- d += g, f -= g;
38390
+ const m = t[f + 1] + 2;
38391
+ f += m, p -= m;
38347
38392
  }
38348
38393
  }
38349
38394
  break;
38350
38395
  case 194:
38351
38396
  case 135:
38352
- logger.warn("Unsupported EC-3 in M2TS found");
38353
- break;
38397
+ return emitParsingError(n, new Error("Unsupported EC-3 in M2TS found")), s;
38354
38398
  case 36:
38355
- logger.warn("Unsupported HEVC in M2TS found");
38356
- break;
38399
+ return emitParsingError(n, new Error("Unsupported HEVC in M2TS found")), s;
38357
38400
  }
38358
- e += c + 5;
38401
+ e += d + 5;
38359
38402
  }
38360
- return n;
38403
+ return s;
38404
+ }
38405
+ function emitParsingError(t, e, r) {
38406
+ logger.warn(`parsing error: ${e.message}`), t.emit(Events.ERROR, Events.ERROR, {
38407
+ type: ErrorTypes.MEDIA_ERROR,
38408
+ details: ErrorDetails.FRAG_PARSING_ERROR,
38409
+ fatal: !1,
38410
+ levelRetry: r,
38411
+ error: e,
38412
+ reason: e.message
38413
+ });
38361
38414
  }
38362
38415
  function logEncryptedSamplesFoundInUnencryptedStream(t) {
38363
38416
  logger.log(`${t} with AES-128-CBC encryption found in unencrypted stream`);
@@ -39350,11 +39403,11 @@ class MP4Remuxer {
39350
39403
  }
39351
39404
  getVideoStartPts(e) {
39352
39405
  let r = !1;
39353
- const a = e.reduce((n, s) => {
39354
- const o = s.pts - n;
39355
- return o < -4294967296 ? (r = !0, normalizePts(n, s.pts)) : o > 0 ? n : s.pts;
39356
- }, e[0].pts);
39357
- return r && logger.debug("PTS rollover detected"), a;
39406
+ const a = e[0].pts, n = e.reduce((s, o) => {
39407
+ let u = o.pts, l = u - s;
39408
+ return l < -4294967296 && (r = !0, u = normalizePts(u, a), l = u - s), l > 0 ? s : u;
39409
+ }, a);
39410
+ return r && logger.debug("PTS rollover detected"), n;
39358
39411
  }
39359
39412
  remux(e, r, a, n, s, o, u, l) {
39360
39413
  let c, d, f, p, g, m, v = s, y = s;
@@ -40193,8 +40246,8 @@ class TransmuxerInterface {
40193
40246
  this.error = null, this.hls = void 0, this.id = void 0, this.observer = void 0, this.frag = null, this.part = null, this.useWorker = void 0, this.workerContext = null, this.onwmsg = void 0, this.transmuxer = null, this.onTransmuxComplete = void 0, this.onFlush = void 0;
40194
40247
  const s = e.config;
40195
40248
  this.hls = e, this.id = r, this.useWorker = !!s.enableWorker, this.onTransmuxComplete = a, this.onFlush = n;
40196
- const o = (d, f) => {
40197
- f = f || {}, f.frag = this.frag, f.id = this.id, d === Events.ERROR && (this.error = f.error), this.hls.trigger(d, f);
40249
+ const o = (c, d) => {
40250
+ d = d || {}, d.frag = this.frag, d.id = this.id, c === Events.ERROR && (this.error = d.error), this.hls.trigger(c, d);
40198
40251
  };
40199
40252
  this.observer = new EventEmitter$1(), this.observer.on(Events.FRAG_DECRYPTED, o), this.observer.on(Events.ERROR, o);
40200
40253
  const u = getMediaSource(s.preferManagedMediaSource) || {
@@ -40203,35 +40256,35 @@ class TransmuxerInterface {
40203
40256
  mpeg: u.isTypeSupported("audio/mpeg"),
40204
40257
  mp3: u.isTypeSupported('audio/mp4; codecs="mp3"'),
40205
40258
  ac3: u.isTypeSupported('audio/mp4; codecs="ac-3"')
40206
- }, c = navigator.vendor;
40259
+ };
40207
40260
  if (this.useWorker && typeof Worker < "u" && (s.workerPath || hasUMDWorker())) {
40208
40261
  try {
40209
- s.workerPath ? (logger.log(`loading Web Worker ${s.workerPath} for "${r}"`), this.workerContext = loadWorker(s.workerPath)) : (logger.log(`injecting Web Worker for "${r}"`), this.workerContext = injectWorker()), this.onwmsg = (p) => this.onWorkerMessage(p);
40262
+ s.workerPath ? (logger.log(`loading Web Worker ${s.workerPath} for "${r}"`), this.workerContext = loadWorker(s.workerPath)) : (logger.log(`injecting Web Worker for "${r}"`), this.workerContext = injectWorker()), this.onwmsg = (f) => this.onWorkerMessage(f);
40210
40263
  const {
40211
- worker: f
40264
+ worker: d
40212
40265
  } = this.workerContext;
40213
- f.addEventListener("message", this.onwmsg), f.onerror = (p) => {
40214
- const g = new Error(`${p.message} (${p.filename}:${p.lineno})`);
40266
+ d.addEventListener("message", this.onwmsg), d.onerror = (f) => {
40267
+ const p = new Error(`${f.message} (${f.filename}:${f.lineno})`);
40215
40268
  s.enableWorker = !1, logger.warn(`Error in "${r}" Web Worker, fallback to inline`), this.hls.trigger(Events.ERROR, {
40216
40269
  type: ErrorTypes.OTHER_ERROR,
40217
40270
  details: ErrorDetails.INTERNAL_EXCEPTION,
40218
40271
  fatal: !1,
40219
40272
  event: "demuxerWorker",
40220
- error: g
40273
+ error: p
40221
40274
  });
40222
- }, f.postMessage({
40275
+ }, d.postMessage({
40223
40276
  cmd: "init",
40224
40277
  typeSupported: l,
40225
- vendor: c,
40278
+ vendor: "",
40226
40279
  id: r,
40227
40280
  config: JSON.stringify(s)
40228
40281
  });
40229
- } catch (f) {
40230
- logger.warn(`Error setting up "${r}" Web Worker, fallback to inline`, f), this.resetWorker(), this.error = null, this.transmuxer = new Transmuxer(this.observer, l, s, c, r);
40282
+ } catch (d) {
40283
+ logger.warn(`Error setting up "${r}" Web Worker, fallback to inline`, d), this.resetWorker(), this.error = null, this.transmuxer = new Transmuxer(this.observer, l, s, "", r);
40231
40284
  }
40232
40285
  return;
40233
40286
  }
40234
- this.transmuxer = new Transmuxer(this.observer, l, s, c, r);
40287
+ this.transmuxer = new Transmuxer(this.observer, l, s, "", r);
40235
40288
  }
40236
40289
  resetWorker() {
40237
40290
  if (this.workerContext) {
@@ -40312,6 +40365,7 @@ class TransmuxerInterface {
40312
40365
  type: ErrorTypes.MEDIA_ERROR,
40313
40366
  details: ErrorDetails.FRAG_PARSING_ERROR,
40314
40367
  chunkMeta: r,
40368
+ frag: this.frag || void 0,
40315
40369
  fatal: !1,
40316
40370
  error: e,
40317
40371
  err: e,
@@ -40324,30 +40378,36 @@ class TransmuxerInterface {
40324
40378
  }), this.onFlush(r);
40325
40379
  }
40326
40380
  onWorkerMessage(e) {
40327
- const r = e.data, a = this.hls;
40328
- switch (r.event) {
40329
- case "init": {
40330
- var n;
40331
- const s = (n = this.workerContext) == null ? void 0 : n.objectURL;
40332
- s && self.URL.revokeObjectURL(s);
40333
- break;
40334
- }
40335
- case "transmuxComplete": {
40336
- this.handleTransmuxComplete(r.data);
40337
- break;
40338
- }
40339
- case "flush": {
40340
- this.onFlush(r.data);
40341
- break;
40342
- }
40343
- case "workerLog":
40344
- logger[r.data.logType] && logger[r.data.logType](r.data.message);
40345
- break;
40346
- default: {
40347
- r.data = r.data || {}, r.data.frag = this.frag, r.data.id = this.id, a.trigger(r.event, r.data);
40348
- break;
40349
- }
40381
+ const r = e.data;
40382
+ if (!(r != null && r.event)) {
40383
+ logger.warn(`worker message received with no ${r ? "event name" : "data"}`);
40384
+ return;
40350
40385
  }
40386
+ const a = this.hls;
40387
+ if (!!this.hls)
40388
+ switch (r.event) {
40389
+ case "init": {
40390
+ var n;
40391
+ const s = (n = this.workerContext) == null ? void 0 : n.objectURL;
40392
+ s && self.URL.revokeObjectURL(s);
40393
+ break;
40394
+ }
40395
+ case "transmuxComplete": {
40396
+ this.handleTransmuxComplete(r.data);
40397
+ break;
40398
+ }
40399
+ case "flush": {
40400
+ this.onFlush(r.data);
40401
+ break;
40402
+ }
40403
+ case "workerLog":
40404
+ logger[r.data.logType] && logger[r.data.logType](r.data.message);
40405
+ break;
40406
+ default: {
40407
+ r.data = r.data || {}, r.data.frag = this.frag, r.data.id = this.id, a.trigger(r.event, r.data);
40408
+ break;
40409
+ }
40410
+ }
40351
40411
  }
40352
40412
  configureTransmuxer(e) {
40353
40413
  const {
@@ -40499,7 +40559,7 @@ class AudioStreamController extends BaseStreamController {
40499
40559
  media: a,
40500
40560
  trackId: n
40501
40561
  } = this, s = e.config;
40502
- if (!a && (this.startFragRequested || !s.startFragPrefetch) || !(r != null && r[n]))
40562
+ if (!this.buffering || !a && (this.startFragRequested || !s.startFragPrefetch) || !(r != null && r[n]))
40503
40563
  return;
40504
40564
  const o = r[n], u = o.details;
40505
40565
  if (!u || u.live && this.levelLastLoaded !== o || this.waitForCdnTuneIn(u)) {
@@ -41150,7 +41210,7 @@ class SubtitleStreamController extends BaseStreamController {
41150
41210
  }
41151
41211
  onError(e, r) {
41152
41212
  const a = r.frag;
41153
- (a == null ? void 0 : a.type) === PlaylistLevelType.SUBTITLE && (this.fragCurrent && this.fragCurrent.abortRequests(), this.state !== State$1.STOPPED && (this.state = State$1.IDLE));
41213
+ (a == null ? void 0 : a.type) === PlaylistLevelType.SUBTITLE && (r.details === ErrorDetails.FRAG_GAP && this.fragmentTracker.fragBuffered(a, !0), this.fragCurrent && this.fragCurrent.abortRequests(), this.state !== State$1.STOPPED && (this.state = State$1.IDLE));
41154
41214
  }
41155
41215
  onSubtitleTracksUpdated(e, {
41156
41216
  subtitleTracks: r
@@ -41186,8 +41246,8 @@ class SubtitleStreamController extends BaseStreamController {
41186
41246
  this.warn(`Subtitle tracks were reset while loading level ${u}`);
41187
41247
  return;
41188
41248
  }
41189
- const l = s[n];
41190
- if (u >= s.length || u !== n || !l)
41249
+ const l = s[u];
41250
+ if (u >= s.length || !l)
41191
41251
  return;
41192
41252
  this.log(`Subtitle track ${u} loaded [${o.startSN},${o.endSN}]${o.lastPartSn ? `[part-${o.lastPartSn}-${o.lastPartIndex}]` : ""},duration:${o.totalduration}`), this.mediaBuffer = this.mediaBufferTimeRanges;
41193
41253
  let c = 0;
@@ -41203,7 +41263,7 @@ class SubtitleStreamController extends BaseStreamController {
41203
41263
  c = this.alignPlaylists(o, l.details, (d = this.levelLastLoaded) == null ? void 0 : d.details), c === 0 && p && (c = p.start, addSliding(o, c));
41204
41264
  }
41205
41265
  }
41206
- l.details = o, this.levelLastLoaded = l, !this.startFragRequested && (this.mainDetails || !o.live) && this.setStartPosition(this.mainDetails || o, c), this.tick(), o.live && !this.fragCurrent && this.media && this.state === State$1.IDLE && (findFragmentByPTS(null, o.fragments, this.media.currentTime, 0) || (this.warn("Subtitle playlist not aligned with playback"), l.details = void 0));
41266
+ l.details = o, this.levelLastLoaded = l, u === n && (!this.startFragRequested && (this.mainDetails || !o.live) && this.setStartPosition(this.mainDetails || o, c), this.tick(), o.live && !this.fragCurrent && this.media && this.state === State$1.IDLE && (findFragmentByPTS(null, o.fragments, this.media.currentTime, 0) || (this.warn("Subtitle playlist not aligned with playback"), l.details = void 0)));
41207
41267
  }
41208
41268
  _handleFragmentLoadComplete(e) {
41209
41269
  const {
@@ -41724,7 +41784,7 @@ class BufferController {
41724
41784
  onBufferReset() {
41725
41785
  this.getSourceBufferTypes().forEach((e) => {
41726
41786
  this.resetBuffer(e);
41727
- }), this._initSourceBuffer();
41787
+ }), this._initSourceBuffer(), this.hls.resumeBuffering();
41728
41788
  }
41729
41789
  resetBuffer(e) {
41730
41790
  const r = this.sourceBuffer[e];
@@ -42091,9 +42151,9 @@ class BufferController {
42091
42151
  }
42092
42152
  }
42093
42153
  get mediaSrc() {
42094
- var e;
42095
- const r = ((e = this.media) == null ? void 0 : e.firstChild) || this.media;
42096
- return r == null ? void 0 : r.src;
42154
+ var e, r;
42155
+ const a = ((e = this.media) == null || (r = e.querySelector) == null ? void 0 : r.call(e, "source")) || this.media;
42156
+ return a == null ? void 0 : a.src;
42097
42157
  }
42098
42158
  _onSBUpdateStart(e) {
42099
42159
  const {
@@ -42284,10 +42344,7 @@ const specialCea608CharsCodes = {
42284
42344
  205: 9491,
42285
42345
  206: 9495,
42286
42346
  207: 9499
42287
- }, getCharForByte = function(e) {
42288
- let r = e;
42289
- return specialCea608CharsCodes.hasOwnProperty(e) && (r = specialCea608CharsCodes[e]), String.fromCharCode(r);
42290
- }, NR_ROWS = 15, NR_COLS = 100, rowsLowCh1 = {
42347
+ }, getCharForByte = (t) => String.fromCharCode(specialCea608CharsCodes[t] || t), NR_ROWS = 15, NR_COLS = 100, rowsLowCh1 = {
42291
42348
  17: 1,
42292
42349
  18: 3,
42293
42350
  21: 5,
@@ -42682,27 +42739,35 @@ class Cea608Parser {
42682
42739
  this.channels[e].setHandler(r);
42683
42740
  }
42684
42741
  addData(e, r) {
42685
- let a, n, s, o = !1;
42686
42742
  this.logger.time = e;
42687
- for (let u = 0; u < r.length; u += 2)
42688
- if (n = r[u] & 127, s = r[u + 1] & 127, !(n === 0 && s === 0)) {
42689
- if (this.logger.log(3, "[" + numArrayToHexArray([r[u], r[u + 1]]) + "] -> (" + numArrayToHexArray([n, s]) + ")"), a = this.parseCmd(n, s), a || (a = this.parseMidrow(n, s)), a || (a = this.parsePAC(n, s)), a || (a = this.parseBackgroundAttributes(n, s)), !a && (o = this.parseChars(n, s), o)) {
42690
- const l = this.currentChannel;
42691
- l && l > 0 ? this.channels[l].insertChars(o) : this.logger.log(2, "No channel found yet. TEXT-MODE?");
42743
+ for (let a = 0; a < r.length; a += 2) {
42744
+ const n = r[a] & 127, s = r[a + 1] & 127;
42745
+ let o = !1, u = null;
42746
+ if (n === 0 && s === 0)
42747
+ continue;
42748
+ this.logger.log(3, () => "[" + numArrayToHexArray([r[a], r[a + 1]]) + "] -> (" + numArrayToHexArray([n, s]) + ")");
42749
+ const l = this.cmdHistory;
42750
+ if (n >= 16 && n <= 31) {
42751
+ if (hasCmdRepeated(n, s, l)) {
42752
+ setLastCmd(null, null, l), this.logger.log(3, () => "Repeated command (" + numArrayToHexArray([n, s]) + ") is dropped");
42753
+ continue;
42692
42754
  }
42693
- !a && !o && this.logger.log(2, "Couldn't parse cleaned data " + numArrayToHexArray([n, s]) + " orig: " + numArrayToHexArray([r[u], r[u + 1]]));
42755
+ setLastCmd(n, s, this.cmdHistory), o = this.parseCmd(n, s), o || (o = this.parseMidrow(n, s)), o || (o = this.parsePAC(n, s)), o || (o = this.parseBackgroundAttributes(n, s));
42756
+ } else
42757
+ setLastCmd(null, null, l);
42758
+ if (!o && (u = this.parseChars(n, s), u)) {
42759
+ const d = this.currentChannel;
42760
+ d && d > 0 ? this.channels[d].insertChars(u) : this.logger.log(2, "No channel found yet. TEXT-MODE?");
42694
42761
  }
42762
+ !o && !u && this.logger.log(2, () => "Couldn't parse cleaned data " + numArrayToHexArray([n, s]) + " orig: " + numArrayToHexArray([r[a], r[a + 1]]));
42763
+ }
42695
42764
  }
42696
42765
  parseCmd(e, r) {
42697
- const {
42698
- cmdHistory: a
42699
- } = this, n = (e === 20 || e === 28 || e === 21 || e === 29) && r >= 32 && r <= 47, s = (e === 23 || e === 31) && r >= 33 && r <= 35;
42700
- if (!(n || s))
42766
+ const a = (e === 20 || e === 28 || e === 21 || e === 29) && r >= 32 && r <= 47, n = (e === 23 || e === 31) && r >= 33 && r <= 35;
42767
+ if (!(a || n))
42701
42768
  return !1;
42702
- if (hasCmdRepeated(e, r, a))
42703
- return setLastCmd(null, null, a), this.logger.log(3, "Repeated command (" + numArrayToHexArray([e, r]) + ") is dropped"), !0;
42704
- const o = e === 20 || e === 21 || e === 23 ? 1 : 2, u = this.channels[o];
42705
- return e === 20 || e === 21 || e === 28 || e === 29 ? r === 32 ? u.ccRCL() : r === 33 ? u.ccBS() : r === 34 ? u.ccAOF() : r === 35 ? u.ccAON() : r === 36 ? u.ccDER() : r === 37 ? u.ccRU(2) : r === 38 ? u.ccRU(3) : r === 39 ? u.ccRU(4) : r === 40 ? u.ccFON() : r === 41 ? u.ccRDC() : r === 42 ? u.ccTR() : r === 43 ? u.ccRTD() : r === 44 ? u.ccEDM() : r === 45 ? u.ccCR() : r === 46 ? u.ccENM() : r === 47 && u.ccEOC() : u.ccTO(r - 32), setLastCmd(e, r, a), this.currentChannel = o, !0;
42769
+ const s = e === 20 || e === 21 || e === 23 ? 1 : 2, o = this.channels[s];
42770
+ return e === 20 || e === 21 || e === 28 || e === 29 ? r === 32 ? o.ccRCL() : r === 33 ? o.ccBS() : r === 34 ? o.ccAOF() : r === 35 ? o.ccAON() : r === 36 ? o.ccDER() : r === 37 ? o.ccRU(2) : r === 38 ? o.ccRU(3) : r === 39 ? o.ccRU(4) : r === 40 ? o.ccFON() : r === 41 ? o.ccRDC() : r === 42 ? o.ccTR() : r === 43 ? o.ccRTD() : r === 44 ? o.ccEDM() : r === 45 ? o.ccCR() : r === 46 ? o.ccENM() : r === 47 && o.ccEOC() : o.ccTO(r - 32), this.currentChannel = s, !0;
42706
42771
  }
42707
42772
  parseMidrow(e, r) {
42708
42773
  let a = 0;
@@ -42710,21 +42775,19 @@ class Cea608Parser {
42710
42775
  if (e === 17 ? a = 1 : a = 2, a !== this.currentChannel)
42711
42776
  return this.logger.log(0, "Mismatch channel in midrow parsing"), !1;
42712
42777
  const n = this.channels[a];
42713
- return n ? (n.ccMIDROW(r), this.logger.log(3, "MIDROW (" + numArrayToHexArray([e, r]) + ")"), !0) : !1;
42778
+ return n ? (n.ccMIDROW(r), this.logger.log(3, () => "MIDROW (" + numArrayToHexArray([e, r]) + ")"), !0) : !1;
42714
42779
  }
42715
42780
  return !1;
42716
42781
  }
42717
42782
  parsePAC(e, r) {
42718
42783
  let a;
42719
- const n = this.cmdHistory, s = (e >= 17 && e <= 23 || e >= 25 && e <= 31) && r >= 64 && r <= 127, o = (e === 16 || e === 24) && r >= 64 && r <= 95;
42720
- if (!(s || o))
42784
+ const n = (e >= 17 && e <= 23 || e >= 25 && e <= 31) && r >= 64 && r <= 127, s = (e === 16 || e === 24) && r >= 64 && r <= 95;
42785
+ if (!(n || s))
42721
42786
  return !1;
42722
- if (hasCmdRepeated(e, r, n))
42723
- return setLastCmd(null, null, n), !0;
42724
- const u = e <= 23 ? 1 : 2;
42725
- r >= 64 && r <= 95 ? a = u === 1 ? rowsLowCh1[e] : rowsLowCh2[e] : a = u === 1 ? rowsHighCh1[e] : rowsHighCh2[e];
42726
- const l = this.channels[u];
42727
- return l ? (l.setPAC(this.interpretPAC(a, r)), setLastCmd(e, r, n), this.currentChannel = u, !0) : !1;
42787
+ const o = e <= 23 ? 1 : 2;
42788
+ r >= 64 && r <= 95 ? a = o === 1 ? rowsLowCh1[e] : rowsLowCh2[e] : a = o === 1 ? rowsHighCh1[e] : rowsHighCh2[e];
42789
+ const u = this.channels[o];
42790
+ return u ? (u.setPAC(this.interpretPAC(a, r)), this.currentChannel = o, !0) : !1;
42728
42791
  }
42729
42792
  interpretPAC(e, r) {
42730
42793
  let a;
@@ -42741,14 +42804,10 @@ class Cea608Parser {
42741
42804
  let a, n = null, s = null;
42742
42805
  if (e >= 25 ? (a = 2, s = e - 8) : (a = 1, s = e), s >= 17 && s <= 19) {
42743
42806
  let o;
42744
- s === 17 ? o = r + 80 : s === 18 ? o = r + 112 : o = r + 144, this.logger.log(2, "Special char '" + getCharForByte(o) + "' in channel " + a), n = [o];
42807
+ s === 17 ? o = r + 80 : s === 18 ? o = r + 112 : o = r + 144, this.logger.log(2, () => "Special char '" + getCharForByte(o) + "' in channel " + a), n = [o];
42745
42808
  } else
42746
42809
  e >= 32 && e <= 127 && (n = r === 0 ? [e] : [e, r]);
42747
- if (n) {
42748
- const o = numArrayToHexArray(n);
42749
- this.logger.log(3, "Char codes = " + o.join(",")), setLastCmd(e, r, this.cmdHistory);
42750
- }
42751
- return n;
42810
+ return n && this.logger.log(3, () => "Char codes = " + numArrayToHexArray(n).join(",")), n;
42752
42811
  }
42753
42812
  parseBackgroundAttributes(e, r) {
42754
42813
  const a = (e === 16 || e === 24) && r >= 32 && r <= 47, n = (e === 23 || e === 31) && r >= 45 && r <= 47;
@@ -42758,14 +42817,14 @@ class Cea608Parser {
42758
42817
  const o = {};
42759
42818
  e === 16 || e === 24 ? (s = Math.floor((r - 32) / 2), o.background = backgroundColors[s], r % 2 === 1 && (o.background = o.background + "_semi")) : r === 45 ? o.background = "transparent" : (o.foreground = "black", r === 47 && (o.underline = !0));
42760
42819
  const u = e <= 23 ? 1 : 2;
42761
- return this.channels[u].setBkgData(o), setLastCmd(e, r, this.cmdHistory), !0;
42820
+ return this.channels[u].setBkgData(o), !0;
42762
42821
  }
42763
42822
  reset() {
42764
42823
  for (let e = 0; e < Object.keys(this.channels).length; e++) {
42765
42824
  const r = this.channels[e];
42766
42825
  r && r.reset();
42767
42826
  }
42768
- this.cmdHistory = createCmdHistory();
42827
+ setLastCmd(null, null, this.cmdHistory);
42769
42828
  }
42770
42829
  cueSplitAtTime(e) {
42771
42830
  for (let r = 0; r < this.channels.length; r++) {
@@ -43579,21 +43638,17 @@ class TimelineController {
43579
43638
  return r == null ? void 0 : r.attrs["CLOSED-CAPTIONS"];
43580
43639
  }
43581
43640
  onFragLoading(e, r) {
43582
- this.initCea608Parsers();
43583
- const {
43584
- cea608Parser1: a,
43585
- cea608Parser2: n,
43586
- lastCc: s,
43587
- lastSn: o,
43588
- lastPartIndex: u
43589
- } = this;
43590
- if (!(!this.enabled || !a || !n) && r.frag.type === PlaylistLevelType.MAIN) {
43591
- var l, c;
43641
+ if (this.enabled && r.frag.type === PlaylistLevelType.MAIN) {
43642
+ var a, n;
43592
43643
  const {
43593
- cc: d,
43594
- sn: f
43595
- } = r.frag, p = (l = r == null || (c = r.part) == null ? void 0 : c.index) != null ? l : -1;
43596
- f === o + 1 || f === o && p === u + 1 || d === s || (a.reset(), n.reset()), this.lastCc = d, this.lastSn = f, this.lastPartIndex = p;
43644
+ cea608Parser1: s,
43645
+ cea608Parser2: o,
43646
+ lastSn: u
43647
+ } = this, {
43648
+ cc: l,
43649
+ sn: c
43650
+ } = r.frag, d = (a = (n = r.part) == null ? void 0 : n.index) != null ? a : -1;
43651
+ s && o && (c !== u + 1 || c === u && d !== this.lastPartIndex + 1 || l !== this.lastCc) && (s.reset(), o.reset()), this.lastCc = l, this.lastSn = c, this.lastPartIndex = d;
43597
43652
  }
43598
43653
  }
43599
43654
  onFragLoaded(e, r) {
@@ -44139,61 +44194,68 @@ class EMEController {
44139
44194
  const {
44140
44195
  initDataType: r,
44141
44196
  initData: a
44142
- } = e;
44143
- if (this.debug(`"${e.type}" event: init data type: "${r}"`), a === null)
44197
+ } = e, n = `"${e.type}" event: init data type: "${r}"`;
44198
+ if (this.debug(n), a === null)
44144
44199
  return;
44145
- let n, s;
44200
+ let s, o;
44146
44201
  if (r === "sinf" && this.config.drmSystems[KeySystems.FAIRPLAY]) {
44147
- const d = bin2str(new Uint8Array(a));
44202
+ const f = bin2str(new Uint8Array(a));
44148
44203
  try {
44149
- const f = base64Decode(JSON.parse(d).sinf), p = parseSinf(new Uint8Array(f));
44150
- if (!p)
44151
- return;
44152
- n = p.subarray(8, 24), s = KeySystems.FAIRPLAY;
44153
- } catch {
44154
- this.warn('Failed to parse sinf "encrypted" event message initData');
44204
+ const p = base64Decode(JSON.parse(f).sinf), g = parseSinf(new Uint8Array(p));
44205
+ if (!g)
44206
+ throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");
44207
+ s = g.subarray(8, 24), o = KeySystems.FAIRPLAY;
44208
+ } catch (p) {
44209
+ this.warn(`${n} Failed to parse sinf: ${p}`);
44155
44210
  return;
44156
44211
  }
44157
44212
  } else {
44158
- const d = parsePssh(a);
44159
- if (d === null)
44213
+ const f = parseMultiPssh(a), p = f.filter((g) => g.systemId === KeySystemIds.WIDEVINE)[0];
44214
+ if (!p) {
44215
+ f.length === 0 || f.some((g) => !g.systemId) ? this.warn(`${n} contains incomplete or invalid pssh data`) : this.log(`ignoring ${n} for ${f.map((g) => keySystemIdToKeySystemDomain(g.systemId)).join(",")} pssh data in favor of playlist keys`);
44160
44216
  return;
44161
- d.version === 0 && d.systemId === KeySystemIds.WIDEVINE && d.data && (n = d.data.subarray(8, 24)), s = keySystemIdToKeySystemDomain(d.systemId);
44217
+ }
44218
+ if (o = keySystemIdToKeySystemDomain(p.systemId), p.version === 0 && p.data) {
44219
+ const g = p.data.length - 22;
44220
+ s = p.data.subarray(g, g + 16);
44221
+ }
44162
44222
  }
44163
- if (!s || !n)
44223
+ if (!o || !s)
44164
44224
  return;
44165
- const o = Hex.hexDump(n), {
44166
- keyIdToKeySessionPromise: u,
44167
- mediaKeySessions: l
44225
+ const u = Hex.hexDump(s), {
44226
+ keyIdToKeySessionPromise: l,
44227
+ mediaKeySessions: c
44168
44228
  } = this;
44169
- let c = u[o];
44170
- for (let d = 0; d < l.length; d++) {
44171
- const f = l[d], p = f.decryptdata;
44172
- if (p.pssh || !p.keyId)
44229
+ let d = l[u];
44230
+ for (let f = 0; f < c.length; f++) {
44231
+ const p = c[f], g = p.decryptdata;
44232
+ if (!g.keyId)
44173
44233
  continue;
44174
- const g = Hex.hexDump(p.keyId);
44175
- if (o === g || p.uri.replace(/-/g, "").indexOf(o) !== -1) {
44176
- c = u[g], delete u[g], p.pssh = new Uint8Array(a), p.keyId = n, c = u[o] = c.then(() => this.generateRequestWithPreferredKeySession(f, r, a, "encrypted-event-key-match"));
44234
+ const m = Hex.hexDump(g.keyId);
44235
+ if (u === m || g.uri.replace(/-/g, "").indexOf(u) !== -1) {
44236
+ if (d = l[m], g.pssh)
44237
+ break;
44238
+ delete l[m], g.pssh = new Uint8Array(a), g.keyId = s, d = l[u] = d.then(() => this.generateRequestWithPreferredKeySession(p, r, a, "encrypted-event-key-match"));
44177
44239
  break;
44178
44240
  }
44179
44241
  }
44180
- c || (c = u[o] = this.getKeySystemSelectionPromise([s]).then(({
44181
- keySystem: d,
44182
- mediaKeys: f
44242
+ d || (d = l[u] = this.getKeySystemSelectionPromise([o]).then(({
44243
+ keySystem: f,
44244
+ mediaKeys: p
44183
44245
  }) => {
44184
- var p;
44246
+ var g;
44185
44247
  this.throwIfDestroyed();
44186
- const g = new LevelKey("ISO-23001-7", o, (p = keySystemDomainToKeySystemFormat(d)) != null ? p : "");
44187
- return g.pssh = new Uint8Array(a), g.keyId = n, this.attemptSetMediaKeys(d, f).then(() => {
44248
+ const m = new LevelKey("ISO-23001-7", u, (g = keySystemDomainToKeySystemFormat(f)) != null ? g : "");
44249
+ return m.pssh = new Uint8Array(a), m.keyId = s, this.attemptSetMediaKeys(f, p).then(() => {
44188
44250
  this.throwIfDestroyed();
44189
- const m = this.createMediaKeySessionContext({
44190
- decryptdata: g,
44191
- keySystem: d,
44192
- mediaKeys: f
44251
+ const v = this.createMediaKeySessionContext({
44252
+ decryptdata: m,
44253
+ keySystem: f,
44254
+ mediaKeys: p
44193
44255
  });
44194
- return this.generateRequestWithPreferredKeySession(m, r, a, "encrypted-event-no-match");
44256
+ return this.generateRequestWithPreferredKeySession(v, r, a, "encrypted-event-no-match");
44195
44257
  });
44196
- })), c.catch((d) => this.handleError(d));
44258
+ })), d.catch((f) => this.handleError(f));
44197
44259
  }
44198
44260
  _onWaitingForKey(e) {
44199
44261
  this.log(`"${e.type}" event`);
@@ -44956,7 +45018,7 @@ class ContentSteeringController {
44956
45018
  const a = e[0].pathwayId;
44957
45019
  this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${a}"`), r = this.getLevelsForPathway(a), this.pathwayId = a;
44958
45020
  }
44959
- return r.length !== e.length ? (this.log(`Found ${r.length}/${e.length} levels in Pathway "${this.pathwayId}"`), r) : e;
45021
+ return r.length !== e.length && this.log(`Found ${r.length}/${e.length} levels in Pathway "${this.pathwayId}"`), r;
44960
45022
  }
44961
45023
  getLevelsForPathway(e) {
44962
45024
  return this.levels === null ? [] : this.levels.filter((r) => e === r.pathwayId);
@@ -45145,7 +45207,7 @@ class XhrLoader {
45145
45207
  this.xhrSetup = void 0, this.requestTimeout = void 0, this.retryTimeout = void 0, this.retryDelay = void 0, this.config = null, this.callbacks = null, this.context = null, this.loader = null, this.stats = void 0, this.xhrSetup = e && e.xhrSetup || null, this.stats = new LoadStats(), this.retryDelay = 0;
45146
45208
  }
45147
45209
  destroy() {
45148
- this.callbacks = null, this.abortInternal(), this.loader = null, this.config = null, this.context = null, this.xhrSetup = null, this.stats = null;
45210
+ this.callbacks = null, this.abortInternal(), this.loader = null, this.config = null, this.context = null, this.xhrSetup = null;
45149
45211
  }
45150
45212
  abortInternal() {
45151
45213
  const e = this.loader;
@@ -45171,10 +45233,13 @@ class XhrLoader {
45171
45233
  n.loading.first = 0, n.loaded = 0, n.aborted = !1;
45172
45234
  const s = this.xhrSetup;
45173
45235
  s ? Promise.resolve().then(() => {
45174
- if (!this.stats.aborted)
45236
+ if (!(this.loader !== a || this.stats.aborted))
45175
45237
  return s(a, r.url);
45176
- }).catch((o) => (a.open("GET", r.url, !0), s(a, r.url))).then(() => {
45177
- this.stats.aborted || this.openAndSendXhr(a, r, e);
45238
+ }).catch((o) => {
45239
+ if (!(this.loader !== a || this.stats.aborted))
45240
+ return a.open("GET", r.url, !0), s(a, r.url);
45241
+ }).then(() => {
45242
+ this.loader !== a || this.stats.aborted || this.openAndSendXhr(a, r, e);
45178
45243
  }).catch((o) => {
45179
45244
  this.callbacks.onError({
45180
45245
  code: a.status,
@@ -45204,44 +45269,48 @@ class XhrLoader {
45204
45269
  const n = r.readyState, s = this.config;
45205
45270
  if (!a.aborted && n >= 2 && (a.loading.first === 0 && (a.loading.first = Math.max(self.performance.now(), a.loading.start), s.timeout !== s.loadPolicy.maxLoadTimeMs && (self.clearTimeout(this.requestTimeout), s.timeout = s.loadPolicy.maxLoadTimeMs, this.requestTimeout = self.setTimeout(this.loadtimeout.bind(this), s.loadPolicy.maxLoadTimeMs - (a.loading.first - a.loading.start)))), n === 4)) {
45206
45271
  self.clearTimeout(this.requestTimeout), r.onreadystatechange = null, r.onprogress = null;
45207
- const o = r.status, u = r.responseType !== "text";
45208
- if (o >= 200 && o < 300 && (u && r.response || r.responseText !== null)) {
45209
- a.loading.end = Math.max(self.performance.now(), a.loading.first);
45210
- const l = u ? r.response : r.responseText, c = r.responseType === "arraybuffer" ? l.byteLength : l.length;
45211
- if (a.loaded = a.total = c, a.bwEstimate = a.total * 8e3 / (a.loading.end - a.loading.first), !this.callbacks)
45212
- return;
45213
- const d = this.callbacks.onProgress;
45214
- if (d && d(a, e, l, r), !this.callbacks)
45272
+ const o = r.status, u = r.responseType === "text" ? r.responseText : null;
45273
+ if (o >= 200 && o < 300) {
45274
+ const f = u != null ? u : r.response;
45275
+ if (f != null) {
45276
+ a.loading.end = Math.max(self.performance.now(), a.loading.first);
45277
+ const p = r.responseType === "arraybuffer" ? f.byteLength : f.length;
45278
+ if (a.loaded = a.total = p, a.bwEstimate = a.total * 8e3 / (a.loading.end - a.loading.first), !this.callbacks)
45279
+ return;
45280
+ const g = this.callbacks.onProgress;
45281
+ if (g && g(a, e, f, r), !this.callbacks)
45282
+ return;
45283
+ const m = {
45284
+ url: r.responseURL,
45285
+ data: f,
45286
+ code: o
45287
+ };
45288
+ this.callbacks.onSuccess(m, a, e, r);
45215
45289
  return;
45216
- const f = {
45217
- url: r.responseURL,
45218
- data: l,
45219
- code: o
45220
- };
45221
- this.callbacks.onSuccess(f, a, e, r);
45222
- } else {
45223
- const l = s.loadPolicy.errorRetry, c = a.retry, d = {
45224
- url: e.url,
45225
- data: void 0,
45226
- code: o
45227
- };
45228
- shouldRetry(l, c, !1, d) ? this.retry(l) : (logger.error(`${o} while loading ${e.url}`), this.callbacks.onError({
45229
- code: o,
45230
- text: r.statusText
45231
- }, e, r, a));
45290
+ }
45232
45291
  }
45292
+ const l = s.loadPolicy.errorRetry, c = a.retry, d = {
45293
+ url: e.url,
45294
+ data: void 0,
45295
+ code: o
45296
+ };
45297
+ shouldRetry(l, c, !1, d) ? this.retry(l) : (logger.error(`${o} while loading ${e.url}`), this.callbacks.onError({
45298
+ code: o,
45299
+ text: r.statusText
45300
+ }, e, r, a));
45233
45301
  }
45234
45302
  }
45235
45303
  loadtimeout() {
45236
- var e;
45237
- const r = (e = this.config) == null ? void 0 : e.loadPolicy.timeoutRetry, a = this.stats.retry;
45238
- if (shouldRetry(r, a, !0))
45239
- this.retry(r);
45304
+ if (!this.config)
45305
+ return;
45306
+ const e = this.config.loadPolicy.timeoutRetry, r = this.stats.retry;
45307
+ if (shouldRetry(e, r, !0))
45308
+ this.retry(e);
45240
45309
  else {
45241
- var n;
45242
- logger.warn(`timeout while loading ${(n = this.context) == null ? void 0 : n.url}`);
45243
- const s = this.callbacks;
45244
- s && (this.abortInternal(), s.onTimeout(this.stats, this.context, this.loader));
45310
+ var a;
45311
+ logger.warn(`timeout while loading ${(a = this.context) == null ? void 0 : a.url}`);
45312
+ const n = this.callbacks;
45313
+ n && (this.abortInternal(), n.onTimeout(this.stats, this.context, this.loader));
45245
45314
  }
45246
45315
  }
45247
45316
  retry(e) {
@@ -46438,7 +46507,7 @@ class StreamController extends BaseStreamController {
46438
46507
  } = this;
46439
46508
  if (r === null || !n && (this.startFragRequested || !e.config.startFragPrefetch) || this.altAudio && this.audioOnly)
46440
46509
  return;
46441
- const s = e.nextLoadLevel;
46510
+ const s = this.buffering ? e.nextLoadLevel : e.loadLevel;
46442
46511
  if (!(a != null && a[s]))
46443
46512
  return;
46444
46513
  const o = a[s], u = this.getMainFwdBufferInfo();
@@ -46450,6 +46519,8 @@ class StreamController extends BaseStreamController {
46450
46519
  this.altAudio && (v.type = "video"), this.hls.trigger(Events.BUFFER_EOS, v), this.state = State$1.ENDED;
46451
46520
  return;
46452
46521
  }
46522
+ if (!this.buffering)
46523
+ return;
46453
46524
  e.loadLevel !== s && e.manualLevel === -1 && this.log(`Adapting to level ${s} from level ${this.level}`), this.level = e.nextLoadLevel = s;
46454
46525
  const c = o.details;
46455
46526
  if (!c || this.state === State$1.WAITING_LEVEL || c.live && this.levelLastLoaded !== o) {
@@ -46910,7 +46981,12 @@ class StreamController extends BaseStreamController {
46910
46981
  if (s) {
46911
46982
  let l = e.audioCodec;
46912
46983
  const c = navigator.userAgent.toLowerCase();
46913
- this.audioCodecSwitch && (l && (l.indexOf("mp4a.40.5") !== -1 ? l = "mp4a.40.2" : l = "mp4a.40.5"), s.metadata.channelCount !== 1 && c.indexOf("firefox") === -1 && (l = "mp4a.40.5")), l && l.indexOf("mp4a.40.5") !== -1 && c.indexOf("android") !== -1 && s.container !== "audio/mpeg" && (l = "mp4a.40.2", this.log(`Android: force audio codec to ${l}`)), e.audioCodec && e.audioCodec !== l && this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`), s.levelCodec = l, s.id = "main", this.log(`Init audio buffer, container:${s.container}, codecs[selected/level/parsed]=[${l || ""}/${e.audioCodec || ""}/${s.codec}]`);
46984
+ if (this.audioCodecSwitch) {
46985
+ l && (l.indexOf("mp4a.40.5") !== -1 ? l = "mp4a.40.2" : l = "mp4a.40.5");
46986
+ const d = s.metadata;
46987
+ d && "channelCount" in d && (d.channelCount || 1) !== 1 && c.indexOf("firefox") === -1 && (l = "mp4a.40.5");
46988
+ }
46989
+ l && l.indexOf("mp4a.40.5") !== -1 && c.indexOf("android") !== -1 && s.container !== "audio/mpeg" && (l = "mp4a.40.2", this.log(`Android: force audio codec to ${l}`)), e.audioCodec && e.audioCodec !== l && this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`), s.levelCodec = l, s.id = "main", this.log(`Init audio buffer, container:${s.container}, codecs[selected/level/parsed]=[${l || ""}/${e.audioCodec || ""}/${s.codec}]`);
46914
46990
  }
46915
46991
  o && (o.levelCodec = e.videoCodec, o.id = "main", this.log(`Init video buffer, container:${o.container}, codecs[level/parsed]=[${e.videoCodec || ""}/${o.codec}]`)), u && this.log(`Init audiovideo buffer, container:${u.container}, codecs[level/parsed]=[${e.codecs}/${u.codec}]`), this.hls.trigger(Events.BUFFER_CODECS, r), Object.keys(r).forEach((l) => {
46916
46992
  const d = r[l].initSegment;
@@ -46979,7 +47055,7 @@ class StreamController extends BaseStreamController {
46979
47055
  }
46980
47056
  class Hls {
46981
47057
  static get version() {
46982
- return "1.5.8";
47058
+ return "1.5.18";
46983
47059
  }
46984
47060
  static isMSESupported() {
46985
47061
  return isMSESupported();
@@ -47099,23 +47175,23 @@ class Hls {
47099
47175
  });
47100
47176
  }
47101
47177
  startLoad(e = -1) {
47102
- logger.log(`startLoad(${e})`), this.started = !0, this.networkControllers.forEach((r) => {
47103
- r.startLoad(e);
47104
- });
47178
+ logger.log(`startLoad(${e})`), this.started = !0, this.resumeBuffering();
47179
+ for (let r = 0; r < this.networkControllers.length && (this.networkControllers[r].startLoad(e), !(!this.started || !this.networkControllers)); r++)
47180
+ ;
47105
47181
  }
47106
47182
  stopLoad() {
47107
- logger.log("stopLoad"), this.started = !1, this.networkControllers.forEach((e) => {
47108
- e.stopLoad();
47109
- });
47183
+ logger.log("stopLoad"), this.started = !1;
47184
+ for (let e = 0; e < this.networkControllers.length && (this.networkControllers[e].stopLoad(), !(this.started || !this.networkControllers)); e++)
47185
+ ;
47110
47186
  }
47111
47187
  resumeBuffering() {
47112
- this.started && this.networkControllers.forEach((e) => {
47113
- "fragmentLoader" in e && e.startLoad(-1);
47188
+ logger.log("resume buffering"), this.networkControllers.forEach((e) => {
47189
+ e.resumeBuffering && e.resumeBuffering();
47114
47190
  });
47115
47191
  }
47116
47192
  pauseBuffering() {
47117
- this.networkControllers.forEach((e) => {
47118
- "fragmentLoader" in e && e.stopLoad();
47193
+ logger.log("pause buffering"), this.networkControllers.forEach((e) => {
47194
+ e.pauseBuffering && e.pauseBuffering();
47119
47195
  });
47120
47196
  }
47121
47197
  swapAudioCodec() {
@@ -47590,8 +47666,9 @@ const getHtml5Hlsjs = function(t) {
47590
47666
  if (t.type === "video/lzc-cast")
47591
47667
  return "";
47592
47668
  const e = navigator.userAgent.toLowerCase();
47593
- if (e.indexOf("safari") !== -1 && e.indexOf("chrome") === -1 && e.indexOf("edg") === -1 && !window.ManagedMediaSource)
47669
+ if (e.indexOf("safari") !== -1 && e.indexOf("chrome") === -1 && e.indexOf("edg") === -1 || !window.ManagedMediaSource)
47594
47670
  return "";
47671
+ console.log("use hls.js load video.");
47595
47672
  let a = /^application\/x-mpegURL|application\/vnd\.apple\.mpegurl$/i, n = /\.m3u8/i, s;
47596
47673
  return a.test(t.type) ? s = "probably" : n.test(t.src) ? s = "maybe" : s = "", s;
47597
47674
  }, HlsjsSourceHandler = {
@@ -51386,6 +51463,12 @@ const getFrame = (t) => t ? client$2.getFileDownloadLink(t) : EmptySvg, addFrame
51386
51463
  getters: {
51387
51464
  getHistoryInfo(r) {
51388
51465
  return (a) => r.infos.find((n) => n.sourceUrl === a);
51466
+ },
51467
+ getHistoryInfoByPath(r) {
51468
+ return (a) => r.infos.find((n) => {
51469
+ if (n.path && n.path === a)
51470
+ return n;
51471
+ });
51389
51472
  }
51390
51473
  },
51391
51474
  actions: {
@@ -53230,7 +53313,7 @@ const QItem = createComponent({
53230
53313
  }, s = (u, l) => {
53231
53314
  var c, d, f;
53232
53315
  return (c = a.value) != null && c.auto ? u.id == "auto" : (d = a.value) != null && d.origin ? u.id === "origin" : Math.min(u.height, u.width) === ((f = a.value) == null ? void 0 : f.res) && l > 0;
53233
- }, o = (u) => u.id === "origin" ? "\u539F\u59CB\u753B\u8D28" : u.id === "auto" ? "\u81EA\u52A8" : `${u.id} P`;
53316
+ }, o = (u) => u.id === "origin" ? "\u539F\u59CB\u753B\u8D28" : u.id === "auto" ? "\u81EA\u52A8" : `${u.height} P`;
53234
53317
  return (u, l) => (openBlock(), createBlock(SimpleList, {
53235
53318
  items: unref(r),
53236
53319
  isActive: s,
@@ -87106,16 +87189,6 @@ const previewConfig = {
87106
87189
  tile: 4,
87107
87190
  len: 16
87108
87191
  };
87109
- function isNetdiskSource(t, e = !1) {
87110
- return e ? !0 : !(t.startsWith("http") || t.startsWith("blob"));
87111
- }
87112
- function filenameByUrl(t, e) {
87113
- e = e.split("?")[0];
87114
- let r = new RegExp(`${t}/hls/(.*?)/master.m3u8$`, "i"), a = e.match(r);
87115
- if (a && a.length >= 2 || (a = e.match(/_lzc\/files\/home\/(.*?)$/i), a && a.length >= 2))
87116
- return a[1];
87117
- throw "invalid netdisk file url";
87118
- }
87119
87192
  function clearUrl(t) {
87120
87193
  return t.startsWith("/") ? t.substring(1) : t.startsWith("%2F") ? t.substring(3) : t;
87121
87194
  }
@@ -87126,11 +87199,11 @@ function useVideoPreview(t, e) {
87126
87199
  e.currentTime() / (previewConfig.len * previewConfig.interval)
87127
87200
  );
87128
87201
  }
87129
- function s(c = 0) {
87130
- const d = c * previewConfig.len * previewConfig.interval, f = e.src();
87202
+ function s(c, d = 0) {
87203
+ const f = d * previewConfig.len * previewConfig.interval, p = c.path;
87131
87204
  return `${t}/screenshot/${clearUrl(
87132
- f
87133
- )}?start=${d}`;
87205
+ p
87206
+ )}?start=${f}`;
87134
87207
  }
87135
87208
  function o(c) {
87136
87209
  if (a)
@@ -87140,13 +87213,16 @@ function useVideoPreview(t, e) {
87140
87213
  );
87141
87214
  if (c > d)
87142
87215
  return;
87143
- const f = s(c);
87144
- if (r.has(f))
87216
+ const f = e.currentVideoInfo();
87217
+ if (!f.fromNetdisk && !f.path)
87218
+ return;
87219
+ const p = s(f, c);
87220
+ if (r.has(p))
87145
87221
  return o(c + 1);
87146
- console.log("load video preview: ", c, f);
87147
- const p = new Image();
87148
- p.src = f, a = !0, p.onload = () => {
87149
- r.set(f, p), a = !1;
87222
+ console.log("load video preview: ", c, p);
87223
+ const g = new Image();
87224
+ g.src = p, a = !0, g.onload = () => {
87225
+ r.set(p, g), a = !1;
87150
87226
  };
87151
87227
  }
87152
87228
  function u() {
@@ -87154,8 +87230,11 @@ function useVideoPreview(t, e) {
87154
87230
  return o(c);
87155
87231
  }
87156
87232
  function l() {
87157
- const c = n(), d = s(c);
87158
- return r.get(d);
87233
+ const c = n(), d = e.currentVideoInfo();
87234
+ if (!d.fromNetdisk && !d.path)
87235
+ return;
87236
+ const f = s(d, c);
87237
+ return r.get(f);
87159
87238
  }
87160
87239
  return { loadPreview: u, getPreview: l, currentPage: n };
87161
87240
  }
@@ -87174,7 +87253,7 @@ function useSource(t) {
87174
87253
  async function u(g) {
87175
87254
  getFileLinkWithDefault(g._id).then((m) => {
87176
87255
  t.poster(m);
87177
- }), t.src(g.sourceUrl), g.name && (e = g.name), isNetdiskSource(g.sourceUrl, g.fromNetdisk) && !LzcApp.isTvOsWebShell() && t.on(
87256
+ }), t.src(g.sourceUrl), g.name && (e = g.name), g.fromNetdisk && !LzcApp.isTvOsWebShell() && t.on(
87178
87257
  "timeupdate",
87179
87258
  lodash_throttle(() => {
87180
87259
  (t.networkState() == 1 || t.networkState() == 2) && n.loadPreview();
@@ -87198,20 +87277,19 @@ function useSource(t) {
87198
87277
  image: g
87199
87278
  };
87200
87279
  }
87201
- t.currentSrc.bind(t), t.currentSrc = function() {
87202
- const g = decodeURI(f());
87203
- return isNetdiskSource(g) ? "/" + clearUrl(decodeURIComponent(filenameByUrl(a, g))) : g;
87204
- };
87205
87280
  const f = t.src.bind(t);
87206
87281
  function p(g) {
87207
87282
  if (!g)
87208
87283
  return f();
87209
- const m = (y, E = "") => isNetdiskSource(y) ? {
87210
- src: `${a}/hls/${clearUrl(y)}/master.m3u8`,
87211
- type: "application/x-mpegURL"
87212
- } : {
87213
- src: y,
87214
- type: E
87284
+ const m = (y, E = "") => {
87285
+ const I = t.currentVideoInfo();
87286
+ return I.fromNetdisk && I.path || y.startsWith("/") && !y.startsWith(a) ? {
87287
+ src: `${a}/hls/${clearUrl(I.path || y)}/master.m3u8`,
87288
+ type: "application/x-mpegURL"
87289
+ } : {
87290
+ src: y,
87291
+ type: E
87292
+ };
87215
87293
  };
87216
87294
  let v = [];
87217
87295
  Array.isArray(g) ? v = g.map((y) => m(y.src, y.type)) : typeof g == "string" ? v.push(m(g, "")) : v.push(m(g.src, g.type)), f(v);
@@ -87245,7 +87323,12 @@ function useSource(t) {
87245
87323
  }
87246
87324
  }, t.on("openVideo", async (g) => {
87247
87325
  const m = g.info;
87248
- e = m.name, t.isCastMode() || (console.debug("openVideo: ", m), await u(m), t.isNetdiskSource = () => isNetdiskSource(t.src(), m.fromNetdisk), m.duration - m.currentTime > 3 && t.one("canplay", function() {
87326
+ e = m.name, t.currentVideoInfo = () => ({
87327
+ ...m,
87328
+ duration: t.duration(),
87329
+ currentTime: t.currentTime(),
87330
+ name: t.currentVideoName()
87331
+ }), t.isCastMode() || (console.debug("openVideo: ", m), await u(m), t.isNetdiskSource = () => !!m.fromNetdisk, m.duration - m.currentTime > 3 && t.one("canplay", function() {
87249
87332
  t.currentTime(m.currentTime);
87250
87333
  }));
87251
87334
  }), t.currentVideoName = c, t.currentPreview = d, t.isCastMode = function() {
@@ -87255,7 +87338,7 @@ function useSource(t) {
87255
87338
  t.one("loadedmetadata", function() {
87256
87339
  g != null && o(g), t.currentTime(m);
87257
87340
  }), t.src(t.currentSource()), t.play();
87258
- }, t.init = u;
87341
+ };
87259
87342
  }
87260
87343
  function unrefElement(t) {
87261
87344
  var e;
@@ -87386,33 +87469,26 @@ const _hoisted_1 = ["onClick"], _sfc_main = /* @__PURE__ */ defineComponent({
87386
87469
  c.name = "referrer", c.content = "no-referrer", document.head.append(c), n = videojs(s.value, u()), useSource(n), n.dimensions(window.innerWidth, window.innerHeight), n.poster(r.poster);
87387
87470
  const d = new LzcModal(n);
87388
87471
  n.addChild(d), n.lzcModal = () => d, n.enableTouchActivity();
87389
- const f = () => ({
87390
- _id: "",
87391
- sourceUrl: n.src(),
87392
- duration: n.duration(),
87393
- currentTime: n.currentTime(),
87394
- name: n.currentVideoName(),
87395
- invalid: !1
87396
- }), p = async (m) => {
87472
+ const f = async (g) => {
87397
87473
  if (n.isDisposed()) {
87398
87474
  console.debug("skip update because player already disposed.");
87399
87475
  return;
87400
87476
  }
87401
- let v = null;
87402
- m && (v = () => makeVideoFrame(n)), l.updateOrCreateHistory(f(), v);
87403
- }, g = lodash_debounce(() => p(!1), 5e3, {
87477
+ let m = null;
87478
+ g && (m = () => makeVideoFrame(n)), l.updateOrCreateHistory(n.currentVideoInfo(), m);
87479
+ }, p = lodash_debounce(() => f(!1), 5e3, {
87404
87480
  maxWait: 15e3
87405
87481
  });
87406
87482
  r.options && r.options.preload == "auto" && n.load(), n.on("back", () => {
87407
87483
  n.dispose(), e("back");
87408
- }), n.on("seeked", g), n.on("pause", () => p(!0)), n.on("timeupdate", g), n.on("userinactive", () => {
87484
+ }), n.on("seeked", p), n.on("pause", () => f(!0)), n.on("timeupdate", p), n.on("userinactive", () => {
87409
87485
  document.body.style.cursor = "none";
87410
87486
  }), n.on("useractive", () => {
87411
87487
  document.body.style.cursor = "default";
87412
87488
  }), n.one("canplay", () => {
87413
- var m;
87414
- (m = r.options) != null && m.autoplay && n.play(), p(!0);
87415
- }), console.log("player", n), r.onInit && r.onInit(n), window.videojs = videojs, videojs.log.level("debug"), window.player = n;
87489
+ var g;
87490
+ (g = r.options) != null && g.autoplay && n.play(), f(!0);
87491
+ }), console.log("player", n), r.onInit && r.onInit(n), window.videojs = videojs, window.player = n;
87416
87492
  }), onUnmounted(() => {
87417
87493
  n.isDisposed() || n.dispose();
87418
87494
  }), (l, c) => (openBlock(), createElementBlock("div", {