Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

data-audio-playlist

Turns a native audio element and a list of track links into a playlist: click a track to play it, finished tracks are marked, and playback moves to the next track.

Overview

data-audio-playlist goes on a container that holds a native <audio controls> and an <ol class="track-list"> of links to audio files. Clicking a track loads it into the player and plays it. When a track ends it is marked as played and the next track in the list starts. Playback stops after the last track.

Without JavaScript each track is an ordinary link to its audio file, which the browser plays or downloads.

The script ships with the full bundle (vanilla-breeze.js); the core and autoload bundles load it on demand when a [data-audio-playlist] container first appears.

For a custom player UI with shuffle and loop, use <audio-player>. It shares the same track-list markup and track states.

Options

Attribute or class On Description
data-audio-playlist the container Boolean. Turns on the playlist. The container must hold an <audio> and a .track-list; otherwise it is left alone.
.track-list <ol> or <ul> The track list. Each <li> holds an <a href> to an audio file; the link's href becomes the player's source.
data-audio-active <li> The current track. Author it on the track the <audio> starts with; the script moves it on click and when a track ends.
data-audio-played <li> (Set by the script.) The track has played to the end. Played tracks that are not active are dimmed.
data-audio-favorite <li> Styling only: marks a favourite track with a heart.
data-audio-playlist-init the container (Set by the script.) Marks an enhanced container so it is not enhanced twice. Do not author it.

Styling

The track list styles live with the native audio styles (src/native-elements/audio/styles.css): a <details> that contains a .track-list gets a bordered summary, the active track is highlighted, played tracks are muted and favourites get a heart. .track-meta holds a duration or other detail at the end of the row.

Accessibility

  • The tracks are real links in a real list, so they are announced as "list, 3 items" and reachable with the keyboard.
  • The native <audio controls> provides the play, pause, seek and volume controls, with the browser's own keyboard support and accessible names.
  • Clicking a track starts playback. That is a user action, so it is allowed by autoplay rules; nothing plays on page load.

Gotchas

  • loop repeats one track. A native <audio loop> never fires ended, so the playlist does not advance.
  • The first source comes from the markup. Keep the <audio>'s <source> and the track marked data-audio-active in step.
  • Not for <audio-player>. The component handles its own playlist; do not add the attribute to it.

Related

  • <audio> — the native element, captions and track lists.
  • <audio-player> — a full custom player with the same track-list markup.
  • controls — the native attribute that gives the player its UI.
↑