Skip to main content
미디어는 재사용 가능한 파일(비디오 배경, 정적 이미지, 로고, 인트로/아웃트로 클립)로, 프리셋이나 프로젝트 설정에서 참조할 수 있습니다. 한 번 업로드하면 여러 프로젝트에서 재사용할 수 있습니다.

미디어 유형

유형설명
video반복 재생되는 배경 비디오.
image정적 배경 이미지.
logo로고 오버레이.
intro-video노래방이 시작되기 전에 재생됨.
outro-video노래방이 끝난 후에 재생됨.

client.media.list(options?)

인증된 계정이 소유한 모든 재사용 미디어 항목을 나열합니다.
const media = await client.media.list();

client.media.get(mediaId, options?)

단일 미디어 항목을 가져옵니다.
const media = await client.media.get("bg_abc123");

client.media.create(body, options?)

로컬 경로, 바이트, 또는 이미 업로드된 inputFileId로 새 미디어 항목을 생성합니다. 로컬 경로와 바이트의 경우 SDK가 업로드를 준비하고, 업로드 URL로 파일 바이트를 전송한 다음, 업로드된 파일을 재사용 가능한 미디어로 등록합니다.
const media = await client.media.create({
  type: "video",
  source: {
    type: "path",
    path: "./background.mp4",
    contentType: "video/mp4",
  },
});
type
'video' | 'image' | 'logo' | 'intro-video' | 'outro-video'
required
이 미디어 항목이 렌더링에서 담당하는 역할입니다.
source
object
파일 소스입니다. 로컬 파일에는 { type: "path", path }를, Blob, File, ArrayBuffer 또는 typed array 데이터에는 { type: "bytes", data, filename }를, 이미 업로드 ID가 있는 경우에는 { type: "inputFile", inputFileId }를 사용하세요.
inputFileId
string
고급 로우레벨 옵션: source 대신 client.uploads.create(...)가 반환한 ID를 전달합니다.

client.media.delete(mediaId, options?)

미디어 항목을 삭제합니다.
await client.media.delete("bg_abc123", {
  idempotencyKey: "delete-bg_abc123",
});
미디어를 삭제해도 이전에 해당 미디어로 렌더링된 프로젝트나 내보내기 결과에는 영향을 주지 않습니다. 삭제된 미디어를 참조하는 이후 렌더링은 기본 배경으로 대체됩니다.

엔드-투-엔드 예제

import { YoukaClient } from "@youka/sdk";

const client = new YoukaClient({ apiKey: process.env.YOUKA_API_KEY! });

async function uploadBackground(path: string, contentType: string) {
  return client.media.create({
    type: "video",
    source: {
      type: "path",
      path,
      contentType,
    },
  });
}

const media = await uploadBackground("./loop.mp4", "video/mp4");
console.log("Media ID:", media.id);

배경 적용하기

프리셋에서, 또는 프로젝트 설정에서 직접 업로드된 미디어를 참조하세요:
const media = await uploadBackground("./loop.mp4", "video/mp4");

await client.projects.updateSettings("prj_abc123", {
  settings: {
    style: {
      background: {
        type: "video",
        url: media.url,
        objectFit: "cover",
      },
    },
  },
});
background 아래에서 허용되는 전체 필드 집합을 보려면, 프로젝트 설정 스키마를 JSON으로 변환하세요:
import { RestUpdateProjectSettingsRequestSchema } from "@youka/sdk";

const schema = RestUpdateProjectSettingsRequestSchema.toJSONSchema();

다음 단계