Play a sound track

audio

The audio element allows a browser to play and pause a media file containing a sound track.

Support for multiple CODECs is provided by specifying alternate versions of the soundtrack in descendant "source" elements.

Properties

src
Use sourceref notation to identify the media file containing the soundtrack.
controls
Display a user interface to allow the sound volume to be adjusted and to allow the track to be paused, resumed or skipped.
autoplay
Begin playing the soundtrack immediately, even before the entire file is downloaded.
loop
Play the soundtrack in a continuous loop.
muted
Mute the sound until the user explicitly turns it on.
preload
Should the entire soundtrack be downloaded before starting?
auto Download the entire media file, even if the user may not play it.
metadata Only download the soundtrack's length.
none Do not preload.
crossorigin
Use this to fetch the media file using CORS.
anonymous Simply send a request for the image with an "Origin" header.
use-credentials Send a rquest with "Origin" header and credentials.

Examples

audio `/media/lion-king-soundtrack.mp3` *controls
Simple soundtrack with controls

audio `/media/ear-worm.mp3` *autoplay *loop
Soundtrack playing immediately and endlessly

audio *controls {
source `roar.mp3` *type="audio/mpeg"
source `roar.ogg` *type="audio/ogg"
}
Supporting multiple CODECs

Descendents

source
Each source element provides one version of a media file, allowing the browser to negotiate which one to use.
track
The track element references an external document containing information about the separate tracks of a video or audio file.

semantax > media-embed > audioPlay a sound track

Q