# <audio>

A compact audio player bar with play, a progress track and the track's title and artist.

Category: Media.

This tag needs a device to play sound, so try it on your phone.

```ham
<column style="gap-12">
    <text style="font-bold">Episode 42</text>
    <audio id="episode"
           src="https://example.com/podcast/episode-42.mp3"
           title="The quiet hour"
           artist="Morning Notes"
           controls="true"/>
</column>
```

How Hype Apps draws it on a phone: [light](https://hypeapps.dev/img/tags/audio-light.webp), [dark](https://hypeapps.dev/img/tags/audio-dark.webp).

## Attributes

| Name | What it does | Default |
|---|---|---|
| `artist` | Artist name |  |
| `autoplay` | Auto-play on load | `false` |
| `chapters` | Chapters to use instead of the file's own: a WebVTT (kind chapters) or Podcasting 2.0 JSON URL, inline JSON, or "0:00 Intro; 12:30 Part two". none: no chapters, the file is never read for them. |  |
| `color` | Accent color (slider, icon) | `white` |
| `controls` | Show player controls | `true` |
| `cues` | A cue track, the timed lines spoken in the media (a transcript, captions, lyrics): a WebVTT or JSON URL, or JSON in place ([[start, end, text], ...]). The player follows it and publishes the line (and word) being spoken; fetched once, only when something reads it. |  |
| `id` | Media command registry ID for remote control |  |
| `loop` | Loop playback | `false` |
| `muted` | Start muted | `false` |
| `preload` | Load immediately vs defer until play | `true` |
| `speed` | Playback speed | `1.0` |
| `src` | Audio URL (https://, file:/) |  |
| `title` | Track title |  |
| `volume` | Volume 0.0-1.0 | `1.0` |

## Commands

| Name | What it does |
|---|---|
| `chapter` | Seek to a chapter's start: the next, the previous (or the start of this one when more than 3 s in), the first, the last, or chapter N (from 1). |
| `cue` | Seek to a cue's start: the next, the previous (or the start of this one when more than 3 s in), the first, the last, or cue N (from 1). |
| `mute` | Toggle mute. |
| `pause` | Pause playback. |
| `play` | Start playback. |
| `seek` | Jump to a position. |
| `speed` | Playback rate. |
| `src` | Load a different source and play it. |
| `stop` | Stop and rewind. |
| `toggle` | Play/pause. |
| `volume` | Volume 0.0–1.0. |

## Readings

| Name | What it does |
|---|---|
| `chapter` | The chapter playing, as one entry of chapters, following the play position; index 0 and an empty title before the first, or with none. |
| `chapters` | The chapters, a list of {index, title, start, end} (seconds; index from 1; url and image when the source has them), empty when there are none. Read from the file itself (MP4/M4A/M4B, MP3, Ogg, Opus, FLAC, Matroska/WebM) or chapters=, only once something reads it. |
| `cue` | The cue being spoken, as one entry of cues plus speaking (false in the silence after it, until the next starts), following the play position. It changes only when the line does; index 0 and an empty text before the first, or with no track. |
| `cues` | The cue track (cues=), a list of {index, id, start, end, text} (seconds; index from 1; id the source's own, else the index), empty without one. Read once, only when something reads it. |
| `duration` | Length in whole seconds, once known. |
| `playing` | Whether it is playing. |
| `position` | Play position in whole seconds. |
| `speed` | Playback speed (1 is normal). |
| `word` | The word being spoken in the current cue, {index, text, start, end} (index from 1), when the track times its words; index 0 and an empty text otherwise. |

Any tag also takes gestures: `@on.tap`, `@on.longpress`, `@on.doubletap` and `@on.swipeleft` (and right, up and down). `@click` runs on a tap too.

## Related tags

- [`<column>`](https://hypeapps.dev/docs/reference/column.md): Stacks its children top to bottom, with a gap between them and an alignment across.
- [`<text>`](https://hypeapps.dev/docs/reference/text.md): A run of text; with @text it shows an expression that updates as its variables change.
- [`<camera>`](https://hypeapps.dev/docs/reference/camera.md): A live camera viewfinder with a shutter; the photo's path goes into a variable.
- [`<canvas>`](https://hypeapps.dev/docs/reference/canvas.md): A drawing surface for finger or stylus, with a pen, eraser and color toolbar; it saves as a PNG.
- [`<file-picker>`](https://hypeapps.dev/docs/reference/file-picker.md): Opens the device's photo, video or file picker (or the camera) and puts the chosen file in a variable.
- [`<img>`](https://hypeapps.dev/docs/reference/img.md): Shows a picture from a URL or the app's files, sized and cropped by its style.
- [`<layer>`](https://hypeapps.dev/docs/reference/layer.md): Declares one layer of a drawing surface: a locked picture to trace over, and a layer to paint on.
- [`<lottie>`](https://hypeapps.dev/docs/reference/lottie.md): Plays a Lottie vector animation from a JSON file; taps and media commands control it.

All tags: https://hypeapps.dev/docs/reference.md · The full reference: https://hypeapps.dev/llms.txt
