← All Components
<mth-audio-player>
Accessible custom audio player bar with safe-URL validation, track metadata, seek slider, mute, and playback rate controls.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
Ready · interact with <mth-audio-player>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/audio-player"></script>
<mth-audio-player preload="metadata" playback-rate="1"></mth-audio-player>import '@methane-ui/ui/audio-player';
import '@methane-ui/react';
export function Example() {
return <mth-audio-player preload="metadata" playback-rate="1"></mth-audio-player>;
}<script setup lang="ts">
import '@methane-ui/ui/audio-player';
</script>
<template>
<mth-audio-player preload="metadata" playback-rate="1"></mth-audio-player>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/audio-player';
import { MthAudioPlayerDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthAudioPlayerDirective],
template: `<mth-audio-player preload="metadata" playback-rate="1"></mth-audio-player>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/audio-player';
import MthAudioPlayer from '@methane-ui/svelte/MthAudioPlayer.svelte';
</script>
<MthAudioPlayer preload="metadata" playback-rate="1"></MthAudioPlayer>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
src | src | string | "" | Audio source URL validated against safe protocols. |
title | title | string | "" | Track title shown in player bar. |
artist | artist | string | "" | Optional artist or subtitle. |
label | label | string | "" | Accessible region label. |
autoplay | autoplay | boolean | false | Requests automatic playback on load. |
loop | loop | boolean | false | Repeats playback when audio finishes. |
muted | muted | boolean | false | Starts or keeps audio output muted. |
preload | preload | 'metadata' | 'auto' | 'none' | "metadata" | Native audio preload hint. |
playbackRate | playback-rate | number | 1 | Playback speed multiplier. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-play | undefined | Fired when audio starts playing. |
mth-pause | undefined | Fired when audio pauses. |
mth-timeupdate | { currentTime: number; duration: number } | Fired when audio time changes. |
mth-ended | undefined | Fired when audio finishes playing. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| Enter / Space | both | play/mute/rate button focused | toggles playback, mute, or speed |
| ArrowLeft / ArrowRight | both | seek slider focused | scrubs audio position |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | delegatesFocus: true with zero host internals.role (ADR-014). | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 2 APG keyboard transitions across LTR/RTL. | mth-audio-player.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(playing), :state(paused), :state(muted). | Conformance suite |
| i18n | Routes 8 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |