AudioPlayer
A themed audio player with play/pause, scrub bar, time display, volume, optional cover art, and download.
When to Use
- Embed a single audio track inline with metadata (title, artist, cover) instead of the unstyled native
<audio>element - Provide consistent playback controls in podcast, music, or voice-memo features
- Offer a download affordance for hosted media when licensing allows
- Auto-loop short ambient or ringtone-style clips
- React to playback events (play / pause / ended / timeupdate) from C# code
Piano sampleCool Edit demo
Piano sampleCool Edit demo
Tracked sampleCool Edit demo
Last event: (none)
API Reference
AudioPlayer
| Property | Type | Default | Description |
|---|---|---|---|
| Src | string? | — | Required. URL of the audio file to play. |
| Title | string? | null | Track title rendered next to the playback controls. |
| Artist | string? | null | Secondary artist / source label rendered beneath the title. |
| Cover | RenderFragment? | null | Optional cover art slot. Use an Avatar or Image to display album art. |
| Autoplay | bool | false | Starts playback automatically when the component mounts. Browsers may block autoplay for non-muted audio. |
| Loop | bool | false | When true, the track restarts from the beginning after it ends. |
| ShowDownload | bool | false | Renders a download button that lets the user save the source file. |
| PreloadMode | string? | "metadata" | Mirrors the HTML5 preload attribute. Values: "none", "metadata", "auto". |
| OnTimeUpdate | EventCallback<double> | — | Fires while playback progresses with the current time in seconds. |
| OnPlay | EventCallback | — | Fires when playback starts. |
| OnPause | EventCallback | — | Fires when playback pauses. |
| OnEnded | EventCallback | — | Fires when the track reaches the end (does not fire on looped tracks). |
| Class | string? | null | Additional CSS classes appended to the root element. |
| AdditionalAttributes | Dictionary<string, object>? | null | Splatted onto the root element for arbitrary HTML attributes. |
Related Components
- FileUpload — Capture an audio file from the user before playing it back
- Image — Pair with AudioPlayer's
Coverslot for static album art - Avatar — Compact cover-art fallback for podcast hosts or speakers