@geekapps/silo-elements-nextjs 0.3.11 → 0.3.14
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/VideoPlayer.js +52 -5
- package/dist/VideoPlayer.js.map +1 -1
- package/dist/index.js +52 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/VideoPlayer.js
CHANGED
|
@@ -762,11 +762,19 @@ function Video({
|
|
|
762
762
|
if (Hls.isSupported()) {
|
|
763
763
|
const hls = new Hls({
|
|
764
764
|
enableWorker: true,
|
|
765
|
-
maxBufferLength:
|
|
766
|
-
maxMaxBufferLength:
|
|
767
|
-
maxBufferSize:
|
|
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;
|
|
776
|
+
let pinnedLevel = -1;
|
|
777
|
+
let pinnedAudio = -1;
|
|
770
778
|
console.debug("[Silo/hls] loadSource", activeSource.src);
|
|
771
779
|
hls.loadSource(activeSource.src);
|
|
772
780
|
hls.attachMedia(video);
|
|
@@ -791,8 +799,10 @@ function Video({
|
|
|
791
799
|
label: t.name ?? t.lang ?? `Track ${i + 1}`
|
|
792
800
|
}))
|
|
793
801
|
);
|
|
794
|
-
setSelectedAudio(hls.audioTrack ?? 0);
|
|
802
|
+
if (pinnedAudio === -1) setSelectedAudio(hls.audioTrack ?? 0);
|
|
795
803
|
}
|
|
804
|
+
if (pinnedLevel >= 0) hls.currentLevel = pinnedLevel;
|
|
805
|
+
if (pinnedAudio >= 0) hls.audioTrack = pinnedAudio;
|
|
796
806
|
setIsLoading(false);
|
|
797
807
|
});
|
|
798
808
|
hls.on(Hls.Events.AUDIO_TRACKS_UPDATED, (_, data) => {
|
|
@@ -806,7 +816,22 @@ function Video({
|
|
|
806
816
|
}))
|
|
807
817
|
);
|
|
808
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
|
+
}
|
|
809
828
|
});
|
|
829
|
+
hls.__pinLevel = (level) => {
|
|
830
|
+
pinnedLevel = level;
|
|
831
|
+
};
|
|
832
|
+
hls.__pinAudio = (track) => {
|
|
833
|
+
pinnedAudio = track;
|
|
834
|
+
};
|
|
810
835
|
hls.on(Hls.Events.LEVEL_LOADED, (_, data) => {
|
|
811
836
|
console.debug("[Silo/hls] LEVEL_LOADED level=", data.level, "fragments=", data.details?.fragments?.length);
|
|
812
837
|
});
|
|
@@ -820,11 +845,29 @@ function Video({
|
|
|
820
845
|
console.debug("[Silo/hls] FRAG_LOADED", data.frag?.type, data.frag?.sn);
|
|
821
846
|
});
|
|
822
847
|
let mediaErrorAttempts = 0;
|
|
848
|
+
let audioAppendErrors = 0;
|
|
823
849
|
hls.on(Hls.Events.ERROR, (_, data) => {
|
|
824
850
|
const fragUrl = (data.frag?.url ?? data.url ?? "").slice(-80);
|
|
825
851
|
const fragType = data.frag?.type ?? "?";
|
|
826
852
|
console.debug("[Silo/hls] ERROR fatal=", data.fatal, "type=", data.type, "details=", data.details, "fragType=", fragType, "url=", fragUrl);
|
|
827
|
-
if (!data.fatal)
|
|
853
|
+
if (!data.fatal) {
|
|
854
|
+
const isAudioBufError = fragType === "audio" && (data.details === Hls.ErrorDetails.BUFFER_APPEND_ERROR || data.details === Hls.ErrorDetails.BUFFER_APPENDING_ERROR);
|
|
855
|
+
if (isAudioBufError) {
|
|
856
|
+
audioAppendErrors += 1;
|
|
857
|
+
if (audioAppendErrors >= 3) {
|
|
858
|
+
console.warn("[Silo/hls] repeated audio buffer errors \u2014 disabling separate audio tracks");
|
|
859
|
+
setAudioTracks([]);
|
|
860
|
+
try {
|
|
861
|
+
hls.audioTrack = -1;
|
|
862
|
+
} catch {
|
|
863
|
+
}
|
|
864
|
+
audioAppendErrors = 0;
|
|
865
|
+
}
|
|
866
|
+
} else {
|
|
867
|
+
audioAppendErrors = 0;
|
|
868
|
+
}
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
828
871
|
if (data.details === Hls.ErrorDetails.FRAG_PARSING_ERROR && fragType === "audio") {
|
|
829
872
|
console.warn("[Silo/hls] audio frag parse failed \u2014 disabling separate audio tracks and retrying");
|
|
830
873
|
setAudioTracks([]);
|
|
@@ -965,6 +1008,7 @@ function Video({
|
|
|
965
1008
|
setSelectedAudio(trackId);
|
|
966
1009
|
closeSettings();
|
|
967
1010
|
if (hlsRef.current) {
|
|
1011
|
+
hlsRef.current.__pinAudio?.(trackId);
|
|
968
1012
|
hlsRef.current.audioTrack = trackId;
|
|
969
1013
|
}
|
|
970
1014
|
}, [closeSettings]);
|
|
@@ -976,6 +1020,7 @@ function Video({
|
|
|
976
1020
|
closeSettings();
|
|
977
1021
|
if (option.type === "auto") {
|
|
978
1022
|
if (hlsRef.current) {
|
|
1023
|
+
hlsRef.current.__pinLevel?.(-1);
|
|
979
1024
|
hlsRef.current.currentLevel = -1;
|
|
980
1025
|
}
|
|
981
1026
|
if (dashRef.current) {
|
|
@@ -992,6 +1037,8 @@ function Video({
|
|
|
992
1037
|
return;
|
|
993
1038
|
}
|
|
994
1039
|
if (option.type === "hls" && hlsRef.current && option.index != null) {
|
|
1040
|
+
hlsRef.current.__pinLevel?.(option.index);
|
|
1041
|
+
hlsRef.current.nextLevel = option.index;
|
|
995
1042
|
hlsRef.current.currentLevel = option.index;
|
|
996
1043
|
return;
|
|
997
1044
|
}
|