Reference

Audio

Audio player. transcript links what was said, which is what a reader who cannot hear it needs.

Audio(src: String, controls: Bool, autoplay: Bool, …)

Before 5.0

controls

autoplay

loop

No preview for this one: the example below shows how it is written.

Example

wf

Stack(gap: .sm) { Heading("Episode 12: Shipping 7.0").h3 Text("Forty minutes on types, results and what changed.").muted Audio(src: "/media/episode-12.mp3", transcript: "/media/episode-12.txt").controls }

Background music that loops

wf

Audio(src: "/media/ambient.mp3", transcript: "/media/ambient.txt").controls.loop

Props

Props of Audio
PropTypeUnsetMeaning

src:

String

none

The audio's address

controls:

Bool

false

The browser's playback controls; without them the player shows nothing. Written as a flag, .controls, or controls: true.

autoplay:

Bool

false

Start playing when shown; most browsers refuse until the reader has interacted with the page. Written as a flag, .autoplay, or autoplay: true.

loop:

Bool

false

Start again when it ends. Written as a flag, .loop, or loop: true.

transcript:

String

none

The address of what was said, linked as Read the transcript beneath the player; without it, A09

Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.

Flags and cases

A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.

.controls

.autoplay

.loop

Events

The DOM events it is drawn to answer. Any other DOM event works too, in an on … { } handler.

DOM events Audio answers
EventSendsMeaning
on playDOMA video or audio started playing
on pauseDOMA video or audio paused
on endedDOMA video or audio reached its end
on timeupdateDOMA playing video or audio moved on

Every element also takes the props, the events and the attribute families listed on every element.

Slots

It takes no slots.

Renders with the class wf-audio, stable across releases, so a stylesheet may target it.

These controls list the props' cases; the example below shows them written.