Skip to content

VideoPlayer ​

The main component. Wraps <video> with controls, overlays, and adaptive streaming support.

Import ​

ts
import { VideoPlayer } from '@vue-player/vue'

Props ​

Source ​

PropTypeDefaultDescription
srcstring—Single video URL. Accepts .mp4, .webm, .m3u8
posterstring—Poster image URL shown before playback

Playback ​

PropTypeDefaultDescription
autoplaybooleanfalseStart playing on mount. Use with muted to satisfy browser autoplay policies
loopbooleanfalseLoop playback
mutedbooleanfalseStart muted
volumenumber1Initial volume 0–1
playbackRatenumber1Initial playback speed
playbackRatesnumber[][0.25, 0.5, 0.75, 1, 1.25, 1.5, 2]Speed options shown in settings menu
livebooleanfalseForce-show the LIVE badge (auto-detected from stream duration)

Features ​

PropTypeDefaultDescription
keyboardbooleantrueEnable keyboard shortcuts
pipbooleantrueShow PiP button when browser supports it
tracksTrack[]—Subtitle / caption tracks
chaptersChapter[]—Timeline chapter markers
thumbnailsstring—URL of a WebVTT thumbnail file

Events ​

EventPayloadDescription
play—Playback started
pause—Playback paused
ended—Reached end of video
time-updatetime: numberCurrent time changed (fires frequently)
bufferingvalue: booleanBuffering started / stopped
speed-changerate: numberPlayback speed changed
track-changetrack: Track | nullActive subtitle track changed
fullscreen-changevalue: booleanEntered / exited fullscreen
errorerror: PlayerErrorPlayback error occurred

Slots ​

controls ​

Replaces the default controls row. Receives state and player as slot props:

vue
<template #controls="{ state, player }">
  <button @click="state.isPlaying ? player.pause() : player.play()">
    {{ state.isPlaying ? 'Pause' : 'Play' }}
  </button>
</template>

See Custom Controls for the full slot props reference.

loading ​

Custom content inside the loading overlay:

vue
<template #loading>
  <span>Loading…</span>
</template>

error ​

Custom content inside the error overlay. Receives { error: PlayerError }:

vue
<template #error="{ error }">
  <p>{{ error.message }}</p>
</template>

Full Example ​

vue
<script setup lang="ts">
import { VideoPlayer } from '@vue-player/vue'
import type { Track, Chapter } from '@vue-player/core'

const tracks: Track[] = [
  { src: '/en.vtt', label: 'English', language: 'en', default: true },
]

const chapters: Chapter[] = [
  { time: 0,  label: 'Intro' },
  { time: 60, label: 'Main' },
]
</script>

<template>
  <VideoPlayer
    src="https://example.com/stream.m3u8"
    poster="https://example.com/poster.jpg"
    thumbnails="https://example.com/thumbs.vtt"
    :tracks="tracks"
    :chapters="chapters"
    :muted="true"
    :autoplay="true"
    @play="() => console.log('playing')"
    @error="(e) => console.error(e.message)"
  />
</template>

Released under the MIT License.