useVideoPlayer(
videoRef: ValueOrGetter<HTMLVideoElement | null | undefined>,
media: ValueOrGetter<VideoMedia | undefined>,
| Name | Type | Description |
|---|---|---|
videoRef* | ValueOrGetter<HTMLVideoElement | null | undefined> | |
media* | ValueOrGetter<VideoMedia | undefined> | |
options | UseVideoPlayerOptions |
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.Reactive reference to the <video> element.
Video handle from useVideo.
Auto-play toggle.