# Audio

## Audio cards with a cover picture, a heading, text and a built-in player.

## Basics: what module-audio is

**module-audio** is a blocks variant that presents audio content in cards with a cover image, heading, body text and a built-in player.

Technically, the module uses the same base renderer as `module-blocks`, but focuses on `items[].audio` for playback. That gives you a consistent structure for design and layout while the content is tailored to audio use cases.

It works well for podcast clips, explanatory voice-overs, customer testimonials or any other audio where each card needs clear context.

## Option 1: data model and core keys

The top level is `blocks` with `module_type: module-audio`. Common section fields are `section_title`, `section_description`, `columns`, `id`, `aria_label` and the background object.

The cards mainly use:

- `items[].title` and `items[].text_html` for copy
- `items[].image.*` for the cover
- `items[].audio.*` for the audio source and a11y label
- `items[].display` and `display_below_desktop_class` for visibility

The compiler normalises `items[]` into `block1..blockN`, so the template can render up to twelve blocks consistently.

## Option 2: media in the card (audio, image, video)

The primary variant is `audio.src` (without a file extension). The template then renders an `<audio>` element with two source formats: `.m4a` and `.mp3`.

`image.src` is used as the cover. Image fields automatically get `srcset`, `sizes` and a fallback from the image manifest, while `alt` and `title` control accessibility and metadata.

Because module-audio shares the blocks renderer, `video` fields can coexist as well. The overlay/play button reads both video and audio labels for a consistent media UI.

## Option 3: layout, tabs/slider and appearance

As part of the blocks family, module-audio supports three layout modes: `flow`, `tabs` and `slider`. If no layout is given, it is normalised to `flow`.

With `tabs`, `tabs_settings` is used (position, mobile position, start index). With `slider`, `slider_settings` is used (loop, arrows, pagination, autoplay, interval).

Design and customisation happen through `appearance` tokens at section and card level. These become `auto_class`/ `auto_style` in the build and can be combined with global design variables without manual CSS per card.

## Option 4: compiler and player behaviour

The build step sets `blocks.is_one_column` based on `columns`, which affects how video sources are chosen and how media handling behaves in the cards.

The client script `initBlockMedia()` connects the overlay/play button to the audio player. Clicking the button or the card's media area toggles play/pause, and the card changes state once playback has started.

An important implementation detail: the current template hard-codes `<audio preload="none">`. The field `items[].audio.preload` exists in the docs model but is not used directly in rendering at the moment.

## Option 5: schema, SEO and AI optimisation

The recommended schema structure for module-audio is `ItemList` for the section and `AudioObject` per track. For podcast feeds you can switch to `PodcastSeries`/ `PodcastEpisode`.

Keep stable `@id` patterns, for example `#audios` and `#audio-...`. Always match the card's `title`/ `text_html` with schema fields such as `name` and `description`.

For a stronger AI/SEO signal, use clear alt texts on cover images, and consider adding transcripts in nearby text sections when the content matters for discoverability.
