Wrapping a player
useForwardedPlayer
Build your own wrapper the same way VideoCard does - a curated forward of a wrapped VideoPlayer's handle, so consumers of your component get the identical API:
<script setup>
import { VideoPlayer, useForwardedPlayer } from '@munsonlabs/video-player'
const { playerRef, forwarded } = useForwardedPlayer()
defineExpose(forwarded)
</script>
<template>
<VideoPlayer ref="playerRef" v-bind="$attrs" />
</template>
It owns the ref - bind playerRef on the wrapped player and pass forwarded to defineExpose. A guard callback intercepts a call before it reaches the player: return false to swallow it, or run a side effect (mounting a lazy placeholder, say) before returning true.
useResolvedPlayer
useResolvedPlayer(props) finds a player for a control or panel built outside the package: it resolves props.player, then props.for (the id of an <ml-video-player>), then the enclosing VideoPlayer, and returns a ref to its handle. It is what the headless controls and @munsonlabs/reel's picker use; ResolvedPlayerProps is the type of the props it reads.
exposePlayerOnElement
Copies a plain Vue player's handle onto a real DOM element, so code with no access to your Vue app - a third party's script, <ml-video-*> elements from a separate bundle - can read and call it like a genuine custom element:
<script setup>
import { ref, onMounted } from 'vue'
import { VideoPlayer, exposePlayerOnElement } from '@munsonlabs/video-player'
const playerRef = ref(null)
const wrapperEl = ref(null)
onMounted(() => exposePlayerOnElement(wrapperEl.value, playerRef.value))
</script>
<template>
<div id="my-player" ref="wrapperEl">
<VideoPlayer ref="playerRef" src="..." />
</div>
</template>
<!-- a separate script/bundle, no Vue involved -->
<script type="module">
import '@munsonlabs/video-player/element/controls'
</script>
<ml-video-transcript for="my-player" cues='[{"time":0,"text":"..."}]'></ml-video-transcript>
State is copied as live getters, not snapshots, so el.currentTime keeps tracking the real player. The element needn't be the player's root - any element works. This is unrelated to the /element bundles: you're still rendering a plain Vue player, just making it reachable from outside.