fix: use playback selector in MediaPanel
This commit is contained in:
@@ -26,7 +26,7 @@ type SignedUrlResponse = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type PreviewUrlState = Record<string, string | undefined>;
|
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 }>;
|
type VariantsResponse = Array<{ kind: string; size: number; key: string }>;
|
||||||
|
|
||||||
function startOfDayUtc(iso: string) {
|
function startOfDayUtc(iso: string) {
|
||||||
@@ -113,10 +113,11 @@ export function MediaPanel(props: { selectedDayIso: string | null }) {
|
|||||||
| "thumb_med"
|
| "thumb_med"
|
||||||
| "poster"
|
| "poster"
|
||||||
| "video_mp4_720",
|
| "video_mp4_720",
|
||||||
|
sizeOverride?: number,
|
||||||
) {
|
) {
|
||||||
const url =
|
const url =
|
||||||
variant === "video_mp4_720"
|
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}`;
|
: `/api/assets/${assetId}/url?variant=${variant}`;
|
||||||
const res = await fetch(url, { cache: "no-store" });
|
const res = await fetch(url, { cache: "no-store" });
|
||||||
if (!res.ok) throw new Error(`presign_failed:${res.status}`);
|
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") {
|
if (picked?.kind === "video_mp4") {
|
||||||
const url = await loadSignedUrl(assetId, "video_mp4_720");
|
const url = await loadSignedUrl(assetId, "video_mp4_720", picked.size);
|
||||||
return { url, variant: { kind: "video_mp4", size: 720 } };
|
return { url, variant: { kind: "video_mp4", size: picked.size } };
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// fall through to original
|
// fall through to original
|
||||||
|
|||||||
Reference in New Issue
Block a user