import type { MediaContext, PlaybackSession } from "../types.js"; /** * Simplest strategy: hand the source to the browser. Works for any * MP4/WebM/MP3/etc. that the user agent already plays. * * The only complexity is that the source might be a `File`/`Blob` (use * `URL.createObjectURL`), an `ArrayBuffer`/`Uint8Array` (wrap in a Blob first), * or a string URL (assign directly). */ export async function createNativeSession( context: MediaContext, video: HTMLVideoElement, ): Promise { const { url, revoke } = sourceToVideoUrl(context.source); video.src = url; // Wait for metadata so the player resolves only once playback is actually // ready. We expose errors via the player's "error" event, not by throwing // here, because failure here often means we should escalate to remux. await new Promise((resolve, reject) => { const onMeta = () => { cleanup(); resolve(); }; const onError = () => { cleanup(); reject(new Error(`