@geekapps/silo-elements-nextjs 0.3.6 → 0.3.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/MediaUploader.js +147 -4
- package/dist/MediaUploader.js.map +1 -1
- package/dist/VideoPlayer.js +47 -4
- package/dist/VideoPlayer.js.map +1 -1
- package/dist/VideoUploader.js +145 -2
- package/dist/VideoUploader.js.map +1 -1
- package/dist/index.js +194 -8
- package/dist/index.js.map +1 -1
- package/dist/styles.css +2 -2
- package/package.json +48 -48
- package/styles.css +2 -2
package/dist/VideoPlayer.js
CHANGED
|
@@ -218,7 +218,12 @@ function Video({
|
|
|
218
218
|
const best = sorted.find((e) => e.px >= targetPx) ?? sorted[sorted.length - 1];
|
|
219
219
|
setPoster(best.url);
|
|
220
220
|
}, [parsed.thumbnailUrls, parsed.thumbnailSrc, playerWidth]);
|
|
221
|
-
const
|
|
221
|
+
const rawActiveSource = parsed.sources[sourceIndex] ?? parsed.sources[0] ?? null;
|
|
222
|
+
const activeSourceRef = useRef(null);
|
|
223
|
+
if (rawActiveSource?.src !== activeSourceRef.current?.src || rawActiveSource?.type !== activeSourceRef.current?.type) {
|
|
224
|
+
activeSourceRef.current = rawActiveSource;
|
|
225
|
+
}
|
|
226
|
+
const activeSource = activeSourceRef.current;
|
|
222
227
|
const progressPercent = duration ? currentTime / duration * 100 : 0;
|
|
223
228
|
const bufferedPercent = duration ? bufferedTime / duration * 100 : 0;
|
|
224
229
|
const destroyMediaEngines = useCallback(() => {
|
|
@@ -466,7 +471,9 @@ function Video({
|
|
|
466
471
|
}, 60 * 1e3);
|
|
467
472
|
}
|
|
468
473
|
};
|
|
469
|
-
const onWaiting = () =>
|
|
474
|
+
const onWaiting = () => {
|
|
475
|
+
if (video.played.length > 0) setIsLoading(true);
|
|
476
|
+
};
|
|
470
477
|
const onCanPlay = () => setIsLoading(false);
|
|
471
478
|
const onEnded = () => setControlsVisible(true);
|
|
472
479
|
video.addEventListener("timeupdate", syncTime);
|
|
@@ -751,6 +758,7 @@ function Video({
|
|
|
751
758
|
const HlsModule = await import('hls.js');
|
|
752
759
|
if (cancelled) return;
|
|
753
760
|
const Hls = HlsModule.default;
|
|
761
|
+
console.debug("[Silo/hls] Hls.isSupported()=", Hls.isSupported());
|
|
754
762
|
if (Hls.isSupported()) {
|
|
755
763
|
const hls = new Hls({
|
|
756
764
|
enableWorker: true,
|
|
@@ -759,10 +767,12 @@ function Video({
|
|
|
759
767
|
maxBufferSize: 20 * 1e3 * 1e3
|
|
760
768
|
});
|
|
761
769
|
hlsRef.current = hls;
|
|
770
|
+
console.debug("[Silo/hls] loadSource", activeSource.src);
|
|
762
771
|
hls.loadSource(activeSource.src);
|
|
763
772
|
hls.attachMedia(video);
|
|
764
773
|
hls.on(Hls.Events.MANIFEST_PARSED, (_, data) => {
|
|
765
774
|
const levels = data.levels ?? hls.levels ?? [];
|
|
775
|
+
console.debug("[Silo/hls] MANIFEST_PARSED levels=", levels.length, "audioTracks=", hls.audioTracks?.length ?? 0);
|
|
766
776
|
setQualities([
|
|
767
777
|
AUTO_QUALITY,
|
|
768
778
|
...levels.map((level, index) => ({
|
|
@@ -773,6 +783,7 @@ function Video({
|
|
|
773
783
|
}))
|
|
774
784
|
]);
|
|
775
785
|
const tracks = hls.audioTracks ?? [];
|
|
786
|
+
console.debug("[Silo/hls] audio tracks:", tracks.map((t) => ({ name: t.name, lang: t.lang, url: t.url })));
|
|
776
787
|
if (tracks.length > 1) {
|
|
777
788
|
setAudioTracks(
|
|
778
789
|
tracks.map((t, i) => ({
|
|
@@ -786,6 +797,7 @@ function Video({
|
|
|
786
797
|
});
|
|
787
798
|
hls.on(Hls.Events.AUDIO_TRACKS_UPDATED, (_, data) => {
|
|
788
799
|
const tracks = data.audioTracks ?? [];
|
|
800
|
+
console.debug("[Silo/hls] AUDIO_TRACKS_UPDATED", tracks.length);
|
|
789
801
|
if (tracks.length > 1) {
|
|
790
802
|
setAudioTracks(
|
|
791
803
|
tracks.map((t, i) => ({
|
|
@@ -795,18 +807,49 @@ function Video({
|
|
|
795
807
|
);
|
|
796
808
|
}
|
|
797
809
|
});
|
|
810
|
+
hls.on(Hls.Events.LEVEL_LOADED, (_, data) => {
|
|
811
|
+
console.debug("[Silo/hls] LEVEL_LOADED level=", data.level, "fragments=", data.details?.fragments?.length);
|
|
812
|
+
});
|
|
813
|
+
hls.on(Hls.Events.AUDIO_TRACK_LOADED, (_, data) => {
|
|
814
|
+
console.debug("[Silo/hls] AUDIO_TRACK_LOADED track=", data.id, "fragments=", data.details?.fragments?.length);
|
|
815
|
+
});
|
|
816
|
+
hls.on(Hls.Events.FRAG_LOADING, (_, data) => {
|
|
817
|
+
console.debug("[Silo/hls] FRAG_LOADING", data.frag?.type, data.frag?.url?.slice(-60));
|
|
818
|
+
});
|
|
819
|
+
hls.on(Hls.Events.FRAG_LOADED, (_, data) => {
|
|
820
|
+
console.debug("[Silo/hls] FRAG_LOADED", data.frag?.type, data.frag?.sn);
|
|
821
|
+
});
|
|
822
|
+
let mediaErrorAttempts = 0;
|
|
798
823
|
hls.on(Hls.Events.ERROR, (_, data) => {
|
|
824
|
+
const fragUrl = (data.frag?.url ?? data.url ?? "").slice(-80);
|
|
825
|
+
const fragType = data.frag?.type ?? "?";
|
|
826
|
+
console.debug("[Silo/hls] ERROR fatal=", data.fatal, "type=", data.type, "details=", data.details, "fragType=", fragType, "url=", fragUrl);
|
|
799
827
|
if (!data.fatal) return;
|
|
800
|
-
if (data.
|
|
828
|
+
if (data.details === Hls.ErrorDetails.FRAG_PARSING_ERROR && fragType === "audio") {
|
|
829
|
+
console.warn("[Silo/hls] audio frag parse failed \u2014 disabling separate audio tracks and retrying");
|
|
830
|
+
setAudioTracks([]);
|
|
831
|
+
hls.recoverMediaError();
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
if (data.type === Hls.ErrorTypes.MEDIA_ERROR && mediaErrorAttempts < 2) {
|
|
835
|
+
mediaErrorAttempts += 1;
|
|
836
|
+
console.debug("[Silo/hls] recoverMediaError attempt", mediaErrorAttempts);
|
|
801
837
|
hls.recoverMediaError();
|
|
802
838
|
return;
|
|
803
839
|
}
|
|
804
|
-
console.error("[Silo] HLS playback failed");
|
|
840
|
+
console.error("[Silo] HLS playback failed", data.details, "fragType=", fragType, "url=", fragUrl);
|
|
841
|
+
hls.destroy();
|
|
842
|
+
hlsRef.current = null;
|
|
805
843
|
setIsLoading(false);
|
|
806
844
|
});
|
|
845
|
+
video.addEventListener("waiting", () => console.debug("[Silo/hls] video:waiting readyState=", video.readyState, "played=", video.played.length));
|
|
846
|
+
video.addEventListener("canplay", () => console.debug("[Silo/hls] video:canplay readyState=", video.readyState));
|
|
847
|
+
video.addEventListener("stalled", () => console.debug("[Silo/hls] video:stalled"));
|
|
848
|
+
video.addEventListener("suspend", () => console.debug("[Silo/hls] video:suspend"));
|
|
807
849
|
return;
|
|
808
850
|
}
|
|
809
851
|
if (video.canPlayType("application/vnd.apple.mpegurl")) {
|
|
852
|
+
console.debug("[Silo/hls] using native HLS (Safari)");
|
|
810
853
|
video.src = activeSource.src;
|
|
811
854
|
video.load();
|
|
812
855
|
setIsLoading(false);
|