@molecule/app-audio-player-vue
v1.1.0
Published
HTML5 audio player chrome — play/pause, scrub, time, mute toggle, optional visualizer slot
Readme
@molecule/app-audio-player-vue
Vue HTML5 audio player chrome — play/pause, scrub bar, elapsed/total time,
and a mute toggle, over a hidden <audio> element. Use for podcasts,
voice notes, music previews, narrated lessons.
Exports <AudioPlayer> — the Vue counterpart of
@molecule/app-audio-player-react: the same props (React names) and the
same DOM for the same input.
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
import { createApp, defineComponent, h } from 'vue'
import { AudioPlayer } from '@molecule/app-audio-player-vue'
const Player = defineComponent({
setup() {
return () =>
h(AudioPlayer, {
src: '/audio/episode-42.mp3',
title: 'Episode 42: Getting Started',
subtitle: 'The Molecule Podcast',
onPlay: () => console.log('playing'),
onEnded: () => console.log('finished'),
})
},
})
createApp(Player).mount('#app')Type
feature
Installation
npm install @molecule/app-audio-player-vue @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vueAPI
Interfaces
AudioPlayerProps
Props accepted by the {@link AudioPlayer} component.
interface AudioPlayerProps {
/** Audio source URL (a file, a stream or a data URI). */
src: string
/**
* Optional title / track name. Passed as a prop or as the same-named slot —
* both work.
*/
title?: VNodeChild
/**
* Optional artist / source label. Passed as a prop or as the same-named slot
* — both work.
*/
subtitle?: VNodeChild
/**
* Optional waveform / visualizer slot rendered above the controls. Passed as
* a prop or as the same-named slot — both work.
*/
visualizer?: VNodeChild
/**
* WebVTT captions file URL. When set, the player loads it on the media
* element's captions `<track>` and shows the current caption under the
* controls, in a polite live region that screen readers announce. Without
* it the track is empty and no caption line is shown.
*/
captions?: string
/** BCP 47 language of the captions (the track's `srclang`). */
captionsLang?: string
/**
* Human-readable name of the captions track. Defaults through i18n
* (`audio.captions`, English "Captions").
*/
captionsLabel?: string
/** Initial muted state. */
defaultMuted?: boolean
/** Autoplay (browser may block). Passed to the `<audio>` element. */
autoPlay?: boolean
/** Called when the media starts playing. */
onPlay?: () => void
/** Called when the media is paused. */
onPause?: () => void
/** Called when the media reaches its end. */
onEnded?: () => void
/** Extra classes on the outer wrapper. */
className?: string
}Constants
AudioPlayer
HTML5 audio player chrome — play/pause, scrub, time, mute, optional visualizer slot. Use for podcasts, voice notes, music previews, narrated lessons.
const AudioPlayer: DefineComponent<
ExtractPropTypes<{
src: { type: StringConstructor; required: true }
title: null
subtitle: null
visualizer: null
captions: StringConstructor
captionsLang: StringConstructor
captionsLabel: StringConstructor
defaultMuted: { type: PropType<boolean | undefined>; default: undefined }
autoPlay: { type: PropType<boolean | undefined>; default: undefined }
onPlay: PropType<AudioPlayerProps['onPlay']>
onPause: PropType<AudioPlayerProps['onPause']>
onEnded: PropType<AudioPlayerProps['onEnded']>
className: StringConstructor
}>,
() => VNode,
{},
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
{},
string,
PublicProps,
Readonly<
ExtractPropTypes<{
src: { type: StringConstructor; required: true }
title: null
subtitle: null
visualizer: null
captions: StringConstructor
captionsLang: StringConstructor
captionsLabel: StringConstructor
defaultMuted: { type: PropType<boolean | undefined>; default: undefined }
autoPlay: { type: PropType<boolean | undefined>; default: undefined }
onPlay: PropType<AudioPlayerProps['onPlay']>
onPause: PropType<AudioPlayerProps['onPause']>
onEnded: PropType<AudioPlayerProps['onEnded']>
className: StringConstructor
}>
> &
Readonly<{}>,
{ defaultMuted: boolean | undefined; autoPlay: boolean | undefined },
{},
{},
{},
string,
ComponentProvideOptions,
true,
{},
any
>props— Component props (see {@link AudioPlayerProps}).
Returns: The audio player component.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-ui^1.0.1@molecule/app-ui-vue^1.1.0@molecule/app-vue^3.5.0vue^3.4.0
Runtime Dependencies
@molecule/app-ui@molecule/app-ui-vue@molecule/app-vuevue
There is NO volume slider — only a mute toggle; and no playback-rate
or skip controls. The optional visualizer prop is a free-form node
slot rendered above the controls (bring your own waveform); it may be
passed as a prop or as the same-named slot. autoPlay is passed to the
<audio> element and is routinely blocked by browsers until user
interaction — never rely on it. Duration renders 0:00 until
loadedmetadata fires (preload="metadata"). Translations come from the
companion @molecule/app-locales-audio-player locale bond.
Translations
Translation strings are provided by @molecule/app-locales-audio-player.
