qhkr2z22o: Prefer hls.js and fall back to the thumbnail when video cannot play

This commit is contained in:
2026-10-19 17:05:16 -06:00
parent ab78a61851
commit fd760e610a
3 changed files with 44 additions and 28 deletions
+7 -3
View File
@@ -9,11 +9,15 @@ export interface PlaybackEnv {
hlsJsSupported: boolean;
}
/** No hlsUrl: thumbnail only. Native HLS wins; hls.js is the fallback. */
/**
* No hlsUrl: thumbnail only. hls.js (Media Source Extensions) is preferred
* because Chromium reports partial native HLS support it cannot honour; native
* HLS is only chosen where hls.js is unsupported (Safari on iOS).
*/
export function choosePlayback(hlsUrl: string | null | undefined, env: PlaybackEnv): Playback {
if (!hlsUrl) return "none";
if (env.nativeHls) return "native";
return env.hlsJsSupported ? "hlsjs" : "none";
if (env.hlsJsSupported) return "hlsjs";
return env.nativeHls ? "native" : "none";
}
export function supportsNativeHls(video: Pick<HTMLVideoElement, "canPlayType">): boolean {