Methods & state

The imperative API and reactive state on a template ref.

A template ref on VideoPlayer, VideoCard, or VideoStage exposes the same handle - methods to drive playback, and live state to read:

<script setup>
import { ref } from 'vue'
const player = ref(null)
</script>

<template>
  <VideoPlayer ref="player" src="..." :controls="false" />
  <button @click="player.togglePlay()">{{ player?.isPlaying ? 'Pause' : 'Play' }}</button>
  <button @click="player.seek(30)">Jump to 0:30</button>
</template>

The same handle is available on a DOM reference to the custom-element form, via defineExpose:

await document.querySelector('ml-video-card').play()

Methods

MethodDescription
play()Start playback; resolves once playing, rejects on an autoplay block or media error
pause()Pause
togglePlay()Play/pause
replay()Back to the start and playing - what the HUD button does after ended
seek(seconds)Seek to an absolute time in seconds, clamped to the duration
toggleMute()Toggle mute
setVolume(level)Set volume, 0-1
toggleFullscreen()Enter/exit fullscreen
toggleLoop()Toggle loop - fires loopchange
setPlaybackRate(rate)Change speed - fires ratechange
setCaptionTrack(index)Select a caption track, or null for off - fires captionchange
setQuality(height)Select a quality level by height in pixels, nearest wins, or null for Auto - fires qualitychange
togglePip()Enter/exit Picture-in-Picture - fires pipchange
setClipRange(range, options?)Highlight { start, end } on the scrubber and pause, loop or play on at its end (options.end: 'pause', 'loop', 'continue'); null clears it. See clip ranges
setControls(value)Override the controls prop: false hides the HUD, true shows it, null gives the prop back its say. For a page tool that takes the picture over for a while, such as reel's clip editor
toggleAdMute()Toggle mute on the ad currently playing
retry()Re-attempt the current source after an error

State

All reactive - read them straight off the ref to drive your own HUD.

FieldTypeDescription
isPlaying / hasEndedbooleanPlayback status
hasStartedbooleanPlayback has begun at least once - most state-change types stay silent until it flips
hasFirstFrame / hasPlayedFramebooleanA frame has decoded / playback has produced a frame - the poster hides on hasPlayedFrame
isError / errorMessageboolean / stringError state, and the reason to show
isReady / isLoadedbooleanAdapter attached / duration known (or live). loaded fires when isLoaded flips
currentTime / durationnumberPosition and duration, in seconds
progressnumbercurrentTime as a percent (0-100) of duration
bufferedDisplaynumberPercent (0-100) buffered, never less than the current position - for a scrubber's buffered fill
isBufferingbooleanStalled long enough to warrant a spinner
isLivebooleanLive stream - seeking is hidden
isMuted / currentVolumeboolean / numberMute state and volume (0-1)
isAudiblebooleanFalse when muted or volume is dragged to 0 - the single "should this look silent" read
isFullscreen / isLoopingbooleanFullscreen and loop state
supportsPip / isPipActivebooleanPiP availability and state
supportsCaptions / captionTracks / activeCaptionIndexboolean / CaptionTrackInfo[] / number | nullCaption availability, the track list, and the active index (null = off)
supportsQuality / qualityLevels / currentQualityHeight / isAutoQualityboolean / QualityLevelInfo[] / number | null / booleanQuality availability, levels ({ index, height, bitrate, label }), and the selected height (null = Auto)
supportsPlaybackRate / currentPlaybackRateboolean / numberRate availability and current rate
isAdPlaying / isAdPaused / isAdMutedbooleanAd playback status, for driving a custom ad UI
adRemainingTimenumberSeconds left in the current ad
isNativeUibooleanThe platform's own chrome is in use rather than the built-in HUD
clipRange{ start: number; end: number | null } | nullThe clip range, set by setClipRange() or a deep link, highlighted on the scrubber
hasControlsbooleanWhether the HUD is rendered: the controls prop, unless setControls() overrode it
mediaElementHTMLVideoElement | nullThe <video> a native source (MP4, HLS, DASH) plays in, for reading time per frame (requestVideoFrameCallback); null for embeds and before the source mounts. Read it; drive playback through the methods

This is the PlayerHandle interface - a headless control's player prop accepts anything structurally matching it.

Per-component differences

  • VideoCard may still be showing its lazy placeholder - any control method mounts the real player first. With a VideoStage on the page the card hands playback off entirely: togglePlay() selects/toggles this video on the stage, and everything else is a no-op.
  • VideoStage also exposes playNext(), playPrevious(), hasNext and hasPrevious; without a playlist the two flags are false and the two methods do nothing. It can't auto-mount without a video selected, so control methods before that are a no-op.
munsonlabs · MIT licensed · © 2026