Bind a VideoMedia handle to a caller-owned <video>
element.
Svelte idioms:
videoRef accepts a raw HTMLVideoElement, a $state binding,
or a getter. Use Svelte 5's bind:this to assign a template
reference and pass it via a getter so the composable re-binds
when the element first mounts:<script lang="ts">
let videoEl = $state<HTMLVideoElement>();
const player = useVideoPlayer(() => videoEl, () => media);
</script>
<video bind:this={videoEl} />
media changes) the composable
calls media.revoke() to free the object URL.useVideoPlayer(
videoRef: ValueOrGetter<HTMLVideoElement | null | undefined>,
media: ValueOrGetter<VideoMedia | undefined>,
options: UseVideoPlayerOptions
): VideoPlayerHandle| Name | Type | Description |
|---|---|---|
videoRef* | ValueOrGetter<HTMLVideoElement | null | undefined> | Reactive reference to the |
media* | ValueOrGetter<VideoMedia | undefined> | Video handle from |
options | UseVideoPlayerOptions | Auto-play toggle. |