@geekapps/silo-elements-nextjs 0.3.5 → 0.3.7
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 +40 -5
- package/dist/VideoPlayer.js.map +1 -1
- package/dist/index.js +40 -5
- package/dist/index.js.map +1 -1
- package/dist/styles.css +2 -2
- package/package.json +2 -1
- package/styles.css +2 -2
package/dist/index.js
CHANGED
|
@@ -1565,7 +1565,12 @@ function Video({
|
|
|
1565
1565
|
const best = sorted.find((e) => e.px >= targetPx) ?? sorted[sorted.length - 1];
|
|
1566
1566
|
setPoster(best.url);
|
|
1567
1567
|
}, [parsed.thumbnailUrls, parsed.thumbnailSrc, playerWidth]);
|
|
1568
|
-
const
|
|
1568
|
+
const rawActiveSource = parsed.sources[sourceIndex] ?? parsed.sources[0] ?? null;
|
|
1569
|
+
const activeSourceRef = useRef(null);
|
|
1570
|
+
if (rawActiveSource?.src !== activeSourceRef.current?.src || rawActiveSource?.type !== activeSourceRef.current?.type) {
|
|
1571
|
+
activeSourceRef.current = rawActiveSource;
|
|
1572
|
+
}
|
|
1573
|
+
const activeSource = activeSourceRef.current;
|
|
1569
1574
|
const progressPercent = duration ? currentTime / duration * 100 : 0;
|
|
1570
1575
|
const bufferedPercent = duration ? bufferedTime / duration * 100 : 0;
|
|
1571
1576
|
const destroyMediaEngines = useCallback(() => {
|
|
@@ -1813,7 +1818,9 @@ function Video({
|
|
|
1813
1818
|
}, 60 * 1e3);
|
|
1814
1819
|
}
|
|
1815
1820
|
};
|
|
1816
|
-
const onWaiting = () =>
|
|
1821
|
+
const onWaiting = () => {
|
|
1822
|
+
if (video.played.length > 0) setIsLoading(true);
|
|
1823
|
+
};
|
|
1817
1824
|
const onCanPlay = () => setIsLoading(false);
|
|
1818
1825
|
const onEnded = () => setControlsVisible(true);
|
|
1819
1826
|
video.addEventListener("timeupdate", syncTime);
|
|
@@ -2098,6 +2105,7 @@ function Video({
|
|
|
2098
2105
|
const HlsModule = await import('hls.js');
|
|
2099
2106
|
if (cancelled) return;
|
|
2100
2107
|
const Hls = HlsModule.default;
|
|
2108
|
+
console.debug("[Silo/hls] Hls.isSupported()=", Hls.isSupported());
|
|
2101
2109
|
if (Hls.isSupported()) {
|
|
2102
2110
|
const hls = new Hls({
|
|
2103
2111
|
enableWorker: true,
|
|
@@ -2106,10 +2114,12 @@ function Video({
|
|
|
2106
2114
|
maxBufferSize: 20 * 1e3 * 1e3
|
|
2107
2115
|
});
|
|
2108
2116
|
hlsRef.current = hls;
|
|
2117
|
+
console.debug("[Silo/hls] loadSource", activeSource.src);
|
|
2109
2118
|
hls.loadSource(activeSource.src);
|
|
2110
2119
|
hls.attachMedia(video);
|
|
2111
2120
|
hls.on(Hls.Events.MANIFEST_PARSED, (_, data) => {
|
|
2112
2121
|
const levels = data.levels ?? hls.levels ?? [];
|
|
2122
|
+
console.debug("[Silo/hls] MANIFEST_PARSED levels=", levels.length, "audioTracks=", hls.audioTracks?.length ?? 0);
|
|
2113
2123
|
setQualities([
|
|
2114
2124
|
AUTO_QUALITY,
|
|
2115
2125
|
...levels.map((level, index) => ({
|
|
@@ -2120,6 +2130,7 @@ function Video({
|
|
|
2120
2130
|
}))
|
|
2121
2131
|
]);
|
|
2122
2132
|
const tracks = hls.audioTracks ?? [];
|
|
2133
|
+
console.debug("[Silo/hls] audio tracks:", tracks.map((t) => ({ name: t.name, lang: t.lang, url: t.url })));
|
|
2123
2134
|
if (tracks.length > 1) {
|
|
2124
2135
|
setAudioTracks(
|
|
2125
2136
|
tracks.map((t, i) => ({
|
|
@@ -2133,6 +2144,7 @@ function Video({
|
|
|
2133
2144
|
});
|
|
2134
2145
|
hls.on(Hls.Events.AUDIO_TRACKS_UPDATED, (_, data) => {
|
|
2135
2146
|
const tracks = data.audioTracks ?? [];
|
|
2147
|
+
console.debug("[Silo/hls] AUDIO_TRACKS_UPDATED", tracks.length);
|
|
2136
2148
|
if (tracks.length > 1) {
|
|
2137
2149
|
setAudioTracks(
|
|
2138
2150
|
tracks.map((t, i) => ({
|
|
@@ -2142,18 +2154,41 @@ function Video({
|
|
|
2142
2154
|
);
|
|
2143
2155
|
}
|
|
2144
2156
|
});
|
|
2157
|
+
hls.on(Hls.Events.LEVEL_LOADED, (_, data) => {
|
|
2158
|
+
console.debug("[Silo/hls] LEVEL_LOADED level=", data.level, "fragments=", data.details?.fragments?.length);
|
|
2159
|
+
});
|
|
2160
|
+
hls.on(Hls.Events.AUDIO_TRACK_LOADED, (_, data) => {
|
|
2161
|
+
console.debug("[Silo/hls] AUDIO_TRACK_LOADED track=", data.id, "fragments=", data.details?.fragments?.length);
|
|
2162
|
+
});
|
|
2163
|
+
hls.on(Hls.Events.FRAG_LOADING, (_, data) => {
|
|
2164
|
+
console.debug("[Silo/hls] FRAG_LOADING", data.frag?.type, data.frag?.url?.slice(-60));
|
|
2165
|
+
});
|
|
2166
|
+
hls.on(Hls.Events.FRAG_LOADED, (_, data) => {
|
|
2167
|
+
console.debug("[Silo/hls] FRAG_LOADED", data.frag?.type, data.frag?.sn);
|
|
2168
|
+
});
|
|
2169
|
+
let mediaErrorAttempts = 0;
|
|
2145
2170
|
hls.on(Hls.Events.ERROR, (_, data) => {
|
|
2171
|
+
console.debug("[Silo/hls] ERROR fatal=", data.fatal, "type=", data.type, "details=", data.details, "url=", (data.frag?.url ?? data.url ?? "").slice(-80));
|
|
2146
2172
|
if (!data.fatal) return;
|
|
2147
|
-
if (data.type === Hls.ErrorTypes.MEDIA_ERROR) {
|
|
2173
|
+
if (data.type === Hls.ErrorTypes.MEDIA_ERROR && mediaErrorAttempts < 2) {
|
|
2174
|
+
mediaErrorAttempts += 1;
|
|
2175
|
+
console.debug("[Silo/hls] recoverMediaError attempt", mediaErrorAttempts);
|
|
2148
2176
|
hls.recoverMediaError();
|
|
2149
2177
|
return;
|
|
2150
2178
|
}
|
|
2151
|
-
console.error("[Silo] HLS playback failed");
|
|
2179
|
+
console.error("[Silo] HLS playback failed", data.details);
|
|
2180
|
+
hls.destroy();
|
|
2181
|
+
hlsRef.current = null;
|
|
2152
2182
|
setIsLoading(false);
|
|
2153
2183
|
});
|
|
2184
|
+
video.addEventListener("waiting", () => console.debug("[Silo/hls] video:waiting readyState=", video.readyState, "played=", video.played.length));
|
|
2185
|
+
video.addEventListener("canplay", () => console.debug("[Silo/hls] video:canplay readyState=", video.readyState));
|
|
2186
|
+
video.addEventListener("stalled", () => console.debug("[Silo/hls] video:stalled"));
|
|
2187
|
+
video.addEventListener("suspend", () => console.debug("[Silo/hls] video:suspend"));
|
|
2154
2188
|
return;
|
|
2155
2189
|
}
|
|
2156
2190
|
if (video.canPlayType("application/vnd.apple.mpegurl")) {
|
|
2191
|
+
console.debug("[Silo/hls] using native HLS (Safari)");
|
|
2157
2192
|
video.src = activeSource.src;
|
|
2158
2193
|
video.load();
|
|
2159
2194
|
setIsLoading(false);
|
|
@@ -2525,7 +2560,7 @@ function Video({
|
|
|
2525
2560
|
"video",
|
|
2526
2561
|
{
|
|
2527
2562
|
ref: videoRef,
|
|
2528
|
-
className:
|
|
2563
|
+
className: "h-full w-full object-contain",
|
|
2529
2564
|
playsInline: true,
|
|
2530
2565
|
preload: "metadata",
|
|
2531
2566
|
crossOrigin: "anonymous",
|