Stage & playlists
VideoStage is a sticky, full-width player fed by any VideoCard on the page. There's only ever one per page.
Cards reach it over window events rather than props, which is what lets a card anywhere on the page - inside an article, a sidebar, a grid - take over the stage without being wired to it.
Loading stage…
Playlists
Pass playlist - an array of the same props each card takes - and the stage tracks the current video's position within it:
<script setup>
import { VideoStage, VideoCard } from '@munsonlabs/video-player'
const videos = [
{ src: 'https://www.youtube.com/watch?v=UnktCDi-BVs', label: 'Oh my gah!' },
{ src: 'https://vimeo.com/347119375', label: 'Tears of Steel' },
]
</script>
<template>
<VideoStage :playlist="videos" />
<VideoCard v-for="video in videos" :key="video.src" v-bind="video" />
</template>
<ml-video-stage id="stage"></ml-video-stage>
<ml-video-card src="https://www.youtube.com/watch?v=UnktCDi-BVs" label="Oh my gah!"></ml-video-card>
<ml-video-card src="https://vimeo.com/347119375" label="Tears of Steel"></ml-video-card>
<script type="module">
// `playlist` is an array, so it goes through the property rather than an attribute.
document.getElementById('stage').playlist = [
{ src: 'https://www.youtube.com/watch?v=UnktCDi-BVs', label: 'Oh my gah!' },
{ src: 'https://vimeo.com/347119375', label: 'Tears of Steel' },
]
</script>
Playlist entries take everything a VideoCard does - ad tags, tracks, poster, payload.
Navigating
A template ref (or the element itself) exposes playNext(), playPrevious(), hasNext and hasPrevious:
<VideoStage ref="stage" :playlist="videos" />
<button :disabled="!stage?.hasNext" @click="stage.playNext()">Next</button>
const stage = document.querySelector('ml-video-stage')
if (stage.hasNext) stage.playNext()
Skipping carries the outgoing video's mute and volume forward rather than following the shared preference.
Auto-advance to the next entry on ended is built in, persisted per browser and toggled from the controls popup's "Auto" button - there's no prop for it.
Stage-specific events
stageopen and stageclose arrive on the usual state-change stream when the stage mounts its inner player (the first video arrives) and when it tears it down again.
VideoCard hands playback off entirely: togglePlay() selects or toggles that video on the stage, and its other control methods become no-ops, since the stage owns the player.