Skip to content

ReferenceMedia

hls-audio

Audio-only HLS element that plays the audio rendition of an HLS stream

Audio-only HLS element that plays just the audio rendition of an HLS stream — even when the source is a mixed audio/video manifest. Useful for audio podcast players, background audio, and bandwidth-constrained contexts where downloading video data would be wasted. For full audio/video HLS playback, see the HLS video component.

Import

import '@videojs/html/media/hls-audio';

Or load it from the CDN:

<script type="module" src="https://cdn.jsdelivr.net/npm/@videojs/cdn@10.5.0/media/hls-audio.js"></script>

Load a source

src takes an HLS manifest URL. A mixed audio/video manifest works too: the audio component loads only the audio rendition.

<hls-audio src="https://example.com/playlist.m3u8"></hls-audio>

The structured source object takes the same shape as the HLS video component’s, so one object can serve either. source.drm is accepted but unused, because this component composes no EME.

Examples

Basic Usage

<hls-audio class="hls-audio" src="https://stream.mux.com/BV3YZtogl89mg9VcNBhhnHm02Y34zI1nlMuMQfAbl3dM.m3u8" controls></hls-audio>

API Reference

Attributes

Forwards these standard media attributes to the internal <audio>. See the MDN media element reference: autopictureinpictureautoplaycontrolscontrolslistcrossorigindisablepictureinpicturedisableremoteplaybackloadingloopmutedplaysinlineposterpreloadsrc

These Video.js-specific attributes configure media behavior:

AttributeTypeDefaultDetails
stream-type'on-demand' | 'live' | 'unknown''unknown'

Properties

PropertyTypeDefaultDetails
contentDataMediaContentData | undefined—
crossOrigin'anonymous' | 'use-credentials' | nullnull
disableRemotePlaybackbooleanfalse
errorobject—
liveEdgeStartnumber—
preload'' | 'none' | 'metadata' | 'auto'''
sourceobjectnull
srcstring''
streamType'on-demand' | 'live' | 'unknown''unknown'
targetLiveWindownumber—

Also exposes these properties from the native media API. See HTMLAudioElement for details: autoplaybufferedcontrolscurrentSrccurrentTimedefaultMuteddefaultPlaybackRatedurationendedloopmutedpausedplaybackRateplayedreadyStateremoteseekableseekingtextTrackstitlevolume

Methods

Supports these media methods. See HTMLAudioElement for details: addTextTrackcanPlayTypeloadpauseplayremoveTextTrack

Events

Re-dispatches these standard media events from the internal media element: abortaddtrackcanplaycanplaythroughchangecontentdatachangedurationchangeemptiedendedloadeddataloadedmetadataloadstartpauseplayplayingprogressratechangeremovetrackseekedseekingstalledsuspendtimeupdatevolumechangewaiting

Also emits these Video.js-specific events:

EventDescription
errorFired when a fatal condition is reported. Read error for it.
sourcechangeFired when source changes. Read source for the new value.
streamtypechangeFired when the detected stream type changes. Read streamType for the new value.
targetlivewindowchangeFired when the target live window changes. Read targetLiveWindow for the new value.