Veil UI
Components

Media Player

A single player that renders video or audio by kind.

Installation

$ npx veil-ui@latest add media-player

Usage

import { MediaPlayer } from "@/components/ui/media-player";

<MediaPlayer kind="video" src="/clip.mp4" poster="/poster.jpg" title="Spring in motion" />;

Examples

Basic

Spring in motion

Audio

Release notes

Veil team

API reference

The package exports media-player along with its composable parts. It forwards standard attributes to its root element; see the examples above for the component-specific props.

Accessibility

  • Media players use native <video> and <audio> controls with accessible labels.
  • Images require meaningful alt text; clickable thumbnails are buttons named Play <title>.
  • Decorative play overlays, durations and icons are hidden from assistive technology.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add media-player --framework vue or switch the framework in components.json.

<script setup lang="ts">
import { cn } from "@/lib/utils";

import { AudioPlayer } from "@/components/ui/audio-player";
import { VideoPlayer } from "@/components/ui/video-player";

const props = withDefaults(
  defineProps<{
    kind?: "video" | "audio";
    src: string;
    poster?: string;
    title?: string;
    artist?: string;
    caption?: string;
    class?: string;
  }>(),
  { kind: "video" },
);
</script>

<template>
  <div data-slot="media-player" :class="cn('w-full max-w-xl', props.class)">
    <AudioPlayer
      v-if="kind === 'audio'"
      :src="src"
      :title="title"
      :artist="artist"
      class="max-w-none"
    />
    <VideoPlayer
      v-else
      :src="src"
      :poster="poster"
      :caption="caption ?? title"
    />
  </div>
</template>

On this page