Getting Started
Installation
Install the package, mount your first video, and read the state-change stream.
Install
Add the package
npm install @munsonlabs/video-player
Mount a video
Import the CSS once alongside the component you use:
<script setup>
import { VideoCard } from '@munsonlabs/video-player'
import '@munsonlabs/video-player/style'
</script>
<template>
<VideoCard
label="Big Buck Bunny"
src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4"
poster="https://img.youtube.com/vi/aqz-KE-bpKQ/0.jpg"
/>
</template>
<script>
globalThis.__VUE_PROD_DEVTOOLS__ = false
</script>
<script type="module">
import 'https://esm.sh/@munsonlabs/video-player/element'
</script>
<ml-video-card
label="Big Buck Bunny"
src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4"
poster="https://img.youtube.com/vi/aqz-KE-bpKQ/0.jpg"
></ml-video-card>
No build step and no import map - see loading without a build step for what that one global is doing.
There's no platform prop - the platform is inferred from the shape of src. Swap in a YouTube, Vimeo, Brightcove, or .m3u8 URL and the same component plays it (all supported sources).
Listen for playback events
Every component emits state-change - one stream for everything the player does, including timeupdate (live position) and tap (the user tapped the video, even with controls="false"):
<template>
<VideoCard src="..." @state-change="(e) => console.log(e.type, e.currentTime)" />
</template>
See Events for every type.