fix: use playback selector in MediaPanel

This commit is contained in:
William Valentin
2026-02-01 16:52:34 -08:00
parent 4cd6dfef40
commit 691f5908d3

View File

@@ -26,7 +26,7 @@ type SignedUrlResponse = {
};
type PreviewUrlState = Record<string, string | undefined>;
type VideoPlaybackVariant = { kind: "original" } | { kind: "video_mp4"; size: 720 };
type VideoPlaybackVariant = { kind: "original" } | { kind: "video_mp4"; size: number };
type VariantsResponse = Array<{ kind: string; size: number; key: string }>;
function startOfDayUtc(iso: string) {
@@ -113,10 +113,11 @@ export function MediaPanel(props: { selectedDayIso: string | null }) {
| "thumb_med"
| "poster"
| "video_mp4_720",
sizeOverride?: number,
) {
const url =
variant === "video_mp4_720"
? `/api/assets/${assetId}/url?kind=video_mp4&size=720`
? `/api/assets/${assetId}/url?kind=video_mp4&size=${sizeOverride ?? 720}`
: `/api/assets/${assetId}/url?variant=${variant}`;
const res = await fetch(url, { cache: "no-store" });
if (!res.ok) throw new Error(`presign_failed:${res.status}`);
@@ -145,8 +146,8 @@ export function MediaPanel(props: { selectedDayIso: string | null }) {
});
if (picked?.kind === "video_mp4") {
const url = await loadSignedUrl(assetId, "video_mp4_720");
return { url, variant: { kind: "video_mp4", size: 720 } };
const url = await loadSignedUrl(assetId, "video_mp4_720", picked.size);
return { url, variant: { kind: "video_mp4", size: picked.size } };
}
} catch {
// fall through to original