Extensibility

Custom HUDs, custom actions, composables, and wrapping/exposing a player - the surfaces you build on without forking.

A fully custom HUD

Set controls="false" for a bare <video> with no built-in HUD, then build your own from the 13 headless controls - each a Vue component and an ml-video-* custom element - and the imperative API for anything they don't cover:

<script setup>
import { ref } from 'vue'
import { VideoPlayer, PlayButton, MuteButton, Scrubber } from '@munsonlabs/video-player'

const itemRef = ref(null)
function seekBy(seconds) {
  itemRef.value?.seek((itemRef.value.currentTime ?? 0) + seconds)
}
</script>

<template>
  <VideoPlayer ref="itemRef" src="..." :controls="false" />

  <PlayButton :player="itemRef" v-slot="{ isPlaying }">{{ isPlaying ? 'Pause' : 'Play' }}</PlayButton>
  <MuteButton :player="itemRef" v-slot="{ isMuted }">{{ isMuted ? 'Unmute' : 'Mute' }}</MuteButton>
  <button @click="seekBy(-10)">« 10s</button>
  <button @click="seekBy(10)">10s »</button>
  <Scrubber :player="itemRef" />
</template>

Loading player…

No built-in HUD - the bar and transcript below are the headless primitives, wired to the player by ref. Click a transcript line to seek.

Import @munsonlabs/video-player/style/controls instead of the full /style to skip CSS for a player HUD you never render.

Custom actions

action adds a button to the built-in HUD - a built-in behaviour or your own:

<VideoCard action="mute" src="..." />
<!-- also 'loop', 'autoplay' (stage auto-advance) -->
<VideoCard :action="{ icon: '<svg .../>', label: 'Save', onClick: save }" src="..." />

Composables

The logic behind the built-in controls is exported, so a custom control can reuse it rather than reimplement it:

ComposableReturns
useScrubber(playerRef){ scrubbing, displayPercent, previewSeconds, onInput, onChange, onTouchStart, onTouchEnd, onPointerCancel } - the full pause-on-drag, preview, commit-on-release dance. Bind every handler: without onTouchStart a tap after a drag is swallowed, and without onPointerCancel an interrupted drag leaves the preview stuck
cycleCaptionTrack(player) / captionTrackLabel(player)Step through the tracks and back to off, and the active track's label
cycleQuality(player) / qualityLabel(player)Step down the ladder and back to Auto, and the selected level's label
cyclePlaybackRate(player) / playbackRateLabel(rate)Step through the rates, and format one for display
useSpokenCues(player, cues, activeIndex, options?){ canSpeak, speechEnabled, toggleSpeech } - reads the active transcript cue aloud, borrowing the video's mute while it does. options takes pitch and rate

Wrapping and exposing a player

  • useForwardedPlayer forwards a wrapped VideoPlayer's full handle through your own component's defineExpose, with an optional guard to intercept calls.
  • useResolvedPlayer finds a player for a control of your own: resolves player, then for, then the enclosing VideoPlayer.
  • exposePlayerOnElement copies that handle onto a DOM element, so a third party's script or a separately-bundled <ml-video-*> element can drive a plain Vue player.
munsonlabs · MIT licensed · © 2026