35 行
985 B
TypeScript
35 行
985 B
TypeScript
import { ENV } from "./_core/env";
|
|
|
|
export type RemoteMediaSession = {
|
|
id: string;
|
|
userId: string;
|
|
title: string;
|
|
archiveStatus: "idle" | "queued" | "processing" | "completed" | "failed";
|
|
playback: {
|
|
webmUrl?: string;
|
|
mp4Url?: string;
|
|
webmSize?: number;
|
|
mp4Size?: number;
|
|
ready: boolean;
|
|
previewUrl?: string;
|
|
};
|
|
lastError?: string;
|
|
};
|
|
|
|
function getMediaBaseUrl() {
|
|
if (!ENV.mediaServiceUrl) {
|
|
throw new Error("MEDIA_SERVICE_URL is not configured");
|
|
}
|
|
return ENV.mediaServiceUrl.replace(/\/+$/, "");
|
|
}
|
|
|
|
export async function getRemoteMediaSession(sessionId: string) {
|
|
const response = await fetch(`${getMediaBaseUrl()}/sessions/${sessionId}`);
|
|
if (!response.ok) {
|
|
const message = await response.text().catch(() => response.statusText);
|
|
throw new Error(`Media service request failed (${response.status}): ${message}`);
|
|
}
|
|
const payload = await response.json() as { session: RemoteMediaSession };
|
|
return payload.session;
|
|
}
|