@geekapps/silo-elements-nextjs 0.3.11 → 0.3.12

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.
@@ -762,9 +762,15 @@ function Video({
762
762
  if (Hls.isSupported()) {
763
763
  const hls = new Hls({
764
764
  enableWorker: true,
765
- maxBufferLength: 10,
766
- maxMaxBufferLength: 20,
767
- maxBufferSize: 20 * 1e3 * 1e3
765
+ maxBufferLength: 30,
766
+ maxMaxBufferLength: 60,
767
+ maxBufferSize: 60 * 1e3 * 1e3,
768
+ backBufferLength: 30,
769
+ maxBufferHole: 0.5,
770
+ nudgeMaxRetry: 6,
771
+ startLevel: -1,
772
+ abrBandWidthFactor: 0.95,
773
+ abrBandWidthUpFactor: 0.7
768
774
  });
769
775
  hlsRef.current = hls;
770
776
  console.debug("[Silo/hls] loadSource", activeSource.src);
@@ -820,11 +826,29 @@ function Video({
820
826
  console.debug("[Silo/hls] FRAG_LOADED", data.frag?.type, data.frag?.sn);
821
827
  });
822
828
  let mediaErrorAttempts = 0;
829
+ let audioAppendErrors = 0;
823
830
  hls.on(Hls.Events.ERROR, (_, data) => {
824
831
  const fragUrl = (data.frag?.url ?? data.url ?? "").slice(-80);
825
832
  const fragType = data.frag?.type ?? "?";
826
833
  console.debug("[Silo/hls] ERROR fatal=", data.fatal, "type=", data.type, "details=", data.details, "fragType=", fragType, "url=", fragUrl);
827
- if (!data.fatal) return;
834
+ if (!data.fatal) {
835
+ const isAudioBufError = fragType === "audio" && (data.details === Hls.ErrorDetails.BUFFER_APPEND_ERROR || data.details === Hls.ErrorDetails.BUFFER_APPENDING_ERROR);
836
+ if (isAudioBufError) {
837
+ audioAppendErrors += 1;
838
+ if (audioAppendErrors >= 3) {
839
+ console.warn("[Silo/hls] repeated audio buffer errors \u2014 disabling separate audio tracks");
840
+ setAudioTracks([]);
841
+ try {
842
+ hls.audioTrack = -1;
843
+ } catch {
844
+ }
845
+ audioAppendErrors = 0;
846
+ }
847
+ } else {
848
+ audioAppendErrors = 0;
849
+ }
850
+ return;
851
+ }
828
852
  if (data.details === Hls.ErrorDetails.FRAG_PARSING_ERROR && fragType === "audio") {
829
853
  console.warn("[Silo/hls] audio frag parse failed \u2014 disabling separate audio tracks and retrying");
830
854
  setAudioTracks([]);
@@ -992,7 +1016,7 @@ function Video({
992
1016
  return;
993
1017
  }
994
1018
  if (option.type === "hls" && hlsRef.current && option.index != null) {
995
- hlsRef.current.currentLevel = option.index;
1019
+ hlsRef.current.nextLevel = option.index;
996
1020
  return;
997
1021
  }
998
1022
  if (option.type === "dash" && dashRef.current && option.index != null) {