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 HlsVideo.
Import
import { HlsAudio } from '@videojs/react/media/hls-audio';import '@videojs/html/media/hls-audio';Or load it from the CDN:
<script type="module" src="https://cdn.jsdelivr.net/npm/@videojs/cdn@10.0.0-beta.32/media/hls-audio.js"></script>Examples
Basic Usage
import { HlsAudio } from '@videojs/react/media/hls-audio';
export default function BasicUsage() {
return <HlsAudio className="hls-audio" src="https://stream.mux.com/BV3YZtogl89mg9VcNBhhnHm02Y34zI1nlMuMQfAbl3dM.m3u8" controls />;
}
.hls-audio {
width: 100%;
height: 54px;
}
<hls-audio class="hls-audio" src="https://stream.mux.com/BV3YZtogl89mg9VcNBhhnHm02Y34zI1nlMuMQfAbl3dM.m3u8" controls></hls-audio>
.hls-audio {
width: 100%;
height: 54px;
}
import '@videojs/html/media/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:
| Attribute | Type | Default | Details |
|---|---|---|---|
stream-type | MediaStreamType | — | |
| |||
Properties
| Property | Type | Default | Details |
|---|---|---|---|
alternativeMediaSuggestion | string | undefined | — | |
| |||
contentData | MediaContentData | undefined | — | |
| |||
disableRemotePlayback | boolean | false | |
engine | { state: StateSignals<HlsAudioEngineState>; context: ContextSignals<HlsAudioEngineContext>; destroy(): Promise<void> } | — | |
| |||
error | { data?: unknown } | null | — | |
| |||
liveEdgeStart | number | — | |
| |||
preload | '' | 'none' | 'metadata' | 'auto' | '' | |
| |||
src | string | '' | |
streamType | MediaStreamType | — | |
| |||
targetLiveWindow | number | — | |
| |||
Also exposes these properties from the native media API. See HTMLAudioElement for details: autoplaybufferedcontrolscrossOrigincurrentSrccurrentTimedefaultMuteddefaultPlaybackRatedurationendedloopmutedpausedplaybackRateplayedreadyStateremoteseekableseekingtextTrackstitlevolume
Methods
Supports these media methods. See HTMLAudioElement for details: addTextTrackcanPlayTypeloadpauseplay
Events
Re-dispatches these standard media events from the internal media element: abortaddtrackcanplaycanplaythroughchangecontentdatachangedurationchangeemptiedendedloadeddataloadedmetadataloadstartpauseplayplayingprogressratechangeremovetrackseekedseekingstalledsuspendtimeupdatevolumechangewaiting
Also emits these Video.js-specific events:
| Event | Description |
|---|---|
error | Fired when a fatal condition is reported. Read `error` for it. Parallel to `HlsVideoMixin` with one substantive difference: the underlying engine is the audio-only variant (`createHlsAudioEngine`), which omits video and text-track behaviors. The src / preload / disableRemotePlayback / play() contract per the WHATWG HTML spec is identical to the default adapter. Selecting this adapter is the variant decision: instantiating `HlsAudioAdapterCore` opts the consumer into audio-only delivery even when the source is a mixed-AV HLS manifest. |