Methane@methane-ui/*
CSS LayoutsComponentsSkillsTheme BuilderGitHub
← All Components

<mth-audio-player>

@methane-ui/ui~6.8 KB brotli (cold + Lit)~1.4 KB marginal

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

Interactive StageLive Custom Element · <mth-audio-player> (@methane-ui/ui)
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>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
srcsrcstring""Audio source URL validated against safe protocols.
titletitlestring""Track title shown in player bar.
artistartiststring""Optional artist or subtitle.
labellabelstring""Accessible region label.
autoplayautoplaybooleanfalseRequests automatic playback on load.
looploopbooleanfalseRepeats playback when audio finishes.
mutedmutedbooleanfalseStarts or keeps audio output muted.
preloadpreload'metadata' | 'auto' | 'none'"metadata"Native audio preload hint.
playbackRateplayback-ratenumber1Playback speed multiplier.

Events

EventDetail TypeDescription
mth-playundefinedFired when audio starts playing.
mth-pauseundefinedFired when audio pauses.
mth-timeupdate{ currentTime: number; duration: number }Fired when audio time changes.
mth-endedundefinedFired when audio finishes playing.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
Enter / Spacebothplay/mute/rate button focusedtoggles playback, mute, or speed
ArrowLeft / ArrowRightbothseek slider focusedscrubs audio position

Accessibility Checklist

CategoryRequirementVerified By
ariaAll aria-* IDREFs resolve within the same DOM root (ADR-003).scanSameRootAria
focusdelegatesFocus: true with zero host internals.role (ADR-014).lint-plugin & spec-compiler
contrastRenders legible borders, focus outlines, and selection indicators under forced-colors: active.Playwright forced-colors matrix
keyboardImplements all 2 APG keyboard transitions across LTR/RTL.mth-audio-player.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(playing), :state(paused), :state(muted).Conformance suite
i18nRoutes 8 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test