fix: use backend video preview urls
All checks were successful
Deploy to Frontend Servers / deploy (push) Successful in 37s
All checks were successful
Deploy to Frontend Servers / deploy (push) Successful in 37s
This commit is contained in:
@@ -8,8 +8,9 @@ import {
|
||||
const attachment: Attachment = {
|
||||
id: "att-1",
|
||||
kind: "video",
|
||||
url: "/uploads/desktop-preview.mp4",
|
||||
mobilePreviewUrl: "/uploads/mobile-540p-preview.mp4",
|
||||
url: "/uploads/legacy-preview.mp4",
|
||||
desktopUrl: "/uploads/desktop-preview.mp4",
|
||||
mobileUrl: "/uploads/mobile-540p-preview.mp4",
|
||||
mime: "video/mp4",
|
||||
filename: "original.mp4",
|
||||
sizeBytes: 1024,
|
||||
@@ -22,18 +23,27 @@ describe("videoPreviewSource", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("uses mobilePreviewUrl only when mobile preview is active", () => {
|
||||
it("uses mobileUrl only when mobile preview is active", () => {
|
||||
expect(videoPreviewSource(attachment, true)).toBe(
|
||||
"/uploads/mobile-540p-preview.mp4",
|
||||
);
|
||||
});
|
||||
|
||||
it("falls back to the desktop preview when mobilePreviewUrl is absent", () => {
|
||||
it("falls back to the desktop preview when mobileUrl is absent", () => {
|
||||
expect(
|
||||
videoPreviewSource({ ...attachment, mobilePreviewUrl: undefined }, true),
|
||||
videoPreviewSource({ ...attachment, mobileUrl: undefined }, true),
|
||||
).toBe("/uploads/desktop-preview.mp4");
|
||||
});
|
||||
|
||||
it("falls back to url when desktopUrl is absent", () => {
|
||||
expect(
|
||||
videoPreviewSource(
|
||||
{ ...attachment, desktopUrl: undefined, mobileUrl: undefined },
|
||||
false,
|
||||
),
|
||||
).toBe("/uploads/legacy-preview.mp4");
|
||||
});
|
||||
|
||||
it("adds a metadata seek fragment only when the URL has no fragment", () => {
|
||||
expect(videoMetadataPreviewSource("/uploads/video.mp4")).toBe(
|
||||
"/uploads/video.mp4#t=0.1",
|
||||
|
||||
@@ -6,10 +6,10 @@ export function videoPreviewSource(
|
||||
attachment: Attachment,
|
||||
useMobilePreview: boolean,
|
||||
): string {
|
||||
if (useMobilePreview && attachment.mobilePreviewUrl) {
|
||||
return attachment.mobilePreviewUrl;
|
||||
if (useMobilePreview && attachment.mobileUrl) {
|
||||
return attachment.mobileUrl;
|
||||
}
|
||||
return attachment.url;
|
||||
return attachment.desktopUrl || attachment.url;
|
||||
}
|
||||
|
||||
export function videoMetadataPreviewSource(url: string): string {
|
||||
|
||||
@@ -35,8 +35,13 @@ export type Attachment = {
|
||||
posterUrl?: string;
|
||||
thumbUrl?: string;
|
||||
thumbnailUrl?: string;
|
||||
/** Optional 540p/mobile-friendly preview video. Downloads still use the original endpoint. */
|
||||
mobilePreviewUrl?: string;
|
||||
/** 1080p/desktop-friendly preview video. Falls back to `url` when absent. */
|
||||
desktopUrl?: string;
|
||||
/** 540p/mobile-friendly preview video. Downloads still use the original endpoint. */
|
||||
mobileUrl?: string;
|
||||
/** Original uploaded video URL, for backend/admin reference only. */
|
||||
originUrl?: string;
|
||||
originSizeBytes?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user