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
| Method | Description |
|---|---|
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.
| Field | Type | Description |
|---|---|---|
isPlaying / hasEnded | boolean | Playback status |
hasStarted | boolean | Playback has begun at least once - most state-change types stay silent until it flips |
hasFirstFrame / hasPlayedFrame | boolean | A frame has decoded / playback has produced a frame - the poster hides on hasPlayedFrame |
isError / errorMessage | boolean / string | Error state, and the reason to show |
isReady / isLoaded | boolean | Adapter attached / duration known (or live). loaded fires when isLoaded flips |
currentTime / duration | number | Position and duration, in seconds |
progress | number | currentTime as a percent (0-100) of duration |
bufferedDisplay | number | Percent (0-100) buffered, never less than the current position - for a scrubber's buffered fill |
isBuffering | boolean | Stalled long enough to warrant a spinner |
isLive | boolean | Live stream - seeking is hidden |
isMuted / currentVolume | boolean / number | Mute state and volume (0-1) |
isAudible | boolean | False when muted or volume is dragged to 0 - the single "should this look silent" read |
isFullscreen / isLooping | boolean | Fullscreen and loop state |
supportsPip / isPipActive | boolean | PiP availability and state |
supportsCaptions / captionTracks / activeCaptionIndex | boolean / CaptionTrackInfo[] / number | null | Caption availability, the track list, and the active index (null = off) |
supportsQuality / qualityLevels / currentQualityHeight / isAutoQuality | boolean / QualityLevelInfo[] / number | null / boolean | Quality availability, levels ({ index, height, bitrate, label }), and the selected height (null = Auto) |
supportsPlaybackRate / currentPlaybackRate | boolean / number | Rate availability and current rate |
isAdPlaying / isAdPaused / isAdMuted | boolean | Ad playback status, for driving a custom ad UI |
adRemainingTime | number | Seconds left in the current ad |
isNativeUi | boolean | The platform's own chrome is in use rather than the built-in HUD |
clipRange | { start: number; end: number | null } | null | The clip range, set by setClipRange() or a deep link, highlighted on the scrubber |
hasControls | boolean | Whether the HUD is rendered: the controls prop, unless setControls() overrode it |
mediaElement | HTMLVideoElement | null | The <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
VideoCardmay still be showing its lazy placeholder - any control method mounts the real player first. With aVideoStageon the page the card hands playback off entirely:togglePlay()selects/toggles this video on the stage, and everything else is a no-op.VideoStagealso exposesplayNext(),playPrevious(),hasNextandhasPrevious; without aplaylistthe two flags arefalseand the two methods do nothing. It can't auto-mount without a video selected, so control methods before that are a no-op.