katanakit-js / useParseMediaSource
Function: useParseMediaSource()
ts
function useParseMediaSource(input): {
id: string;
provider: "unknown" | "file" | "youtube" | "vimeo";
raw: string;
};Defined in: src/core/services/media.service.ts:121
Normalizes any supported input into a MediaSource. Pure and SSR-safe: no DOM, no fetch.
Parameters
| Parameter | Type | Description |
|---|---|---|
input | string | YouTube/Vimeo URL or id, or direct video file URL. |
Returns
Normalized { provider, id, raw }.
id
ts
id: string;Video id for youtube/vimeo, full URL for file.
provider
ts
provider: "unknown" | "file" | "youtube" | "vimeo" = MediaProviderSchema;raw
ts
raw: string;Original input (URL or bare id).
Example
ts
useParseMediaSource("https://youtu.be/dQw4w9WgXcQ");
// { provider: "youtube", id: "dQw4w9WgXcQ", raw: "…" }