@geekapps/silo-elements-nextjs 0.3.12 → 0.3.15

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.
@@ -773,6 +773,8 @@ function Video({
773
773
  abrBandWidthUpFactor: 0.7
774
774
  });
775
775
  hlsRef.current = hls;
776
+ let pinnedLevel = -1;
777
+ let pinnedAudio = -1;
776
778
  console.debug("[Silo/hls] loadSource", activeSource.src);
777
779
  hls.loadSource(activeSource.src);
778
780
  hls.attachMedia(video);
@@ -797,8 +799,10 @@ function Video({
797
799
  label: t.name ?? t.lang ?? `Track ${i + 1}`
798
800
  }))
799
801
  );
800
- setSelectedAudio(hls.audioTrack ?? 0);
802
+ if (pinnedAudio === -1) setSelectedAudio(hls.audioTrack ?? 0);
801
803
  }
804
+ if (pinnedLevel >= 0) hls.currentLevel = pinnedLevel;
805
+ if (pinnedAudio >= 0) hls.audioTrack = pinnedAudio;
802
806
  setIsLoading(false);
803
807
  });
804
808
  hls.on(Hls.Events.AUDIO_TRACKS_UPDATED, (_, data) => {
@@ -812,7 +816,22 @@ function Video({
812
816
  }))
813
817
  );
814
818
  }
819
+ if (pinnedAudio >= 0 && hls.audioTrack !== pinnedAudio) {
820
+ hls.audioTrack = pinnedAudio;
821
+ }
822
+ });
823
+ hls.on(Hls.Events.LEVEL_SWITCHED, (_, data) => {
824
+ console.debug("[Silo/hls] LEVEL_SWITCHED", data.level);
825
+ if (pinnedAudio >= 0 && hls.audioTrack !== pinnedAudio) {
826
+ hls.audioTrack = pinnedAudio;
827
+ }
815
828
  });
829
+ hls.__pinLevel = (level) => {
830
+ pinnedLevel = level;
831
+ };
832
+ hls.__pinAudio = (track) => {
833
+ pinnedAudio = track;
834
+ };
816
835
  hls.on(Hls.Events.LEVEL_LOADED, (_, data) => {
817
836
  console.debug("[Silo/hls] LEVEL_LOADED level=", data.level, "fragments=", data.details?.fragments?.length);
818
837
  });
@@ -989,6 +1008,7 @@ function Video({
989
1008
  setSelectedAudio(trackId);
990
1009
  closeSettings();
991
1010
  if (hlsRef.current) {
1011
+ hlsRef.current.__pinAudio?.(trackId);
992
1012
  hlsRef.current.audioTrack = trackId;
993
1013
  }
994
1014
  }, [closeSettings]);
@@ -1000,6 +1020,7 @@ function Video({
1000
1020
  closeSettings();
1001
1021
  if (option.type === "auto") {
1002
1022
  if (hlsRef.current) {
1023
+ hlsRef.current.__pinLevel?.(-1);
1003
1024
  hlsRef.current.currentLevel = -1;
1004
1025
  }
1005
1026
  if (dashRef.current) {
@@ -1016,7 +1037,8 @@ function Video({
1016
1037
  return;
1017
1038
  }
1018
1039
  if (option.type === "hls" && hlsRef.current && option.index != null) {
1019
- hlsRef.current.nextLevel = option.index;
1040
+ hlsRef.current.__pinLevel?.(option.index);
1041
+ hlsRef.current.currentLevel = option.index;
1020
1042
  return;
1021
1043
  }
1022
1044
  if (option.type === "dash" && dashRef.current && option.index != null) {