HLS.js is a JavaScript library that plays HLS streams in browsers via HTML5 video and Media Source Extensions, including live, VOD, and low-latency modes.
Overview
HLS.js implements an HTTP Live Streaming client for web pages. Playback uses an HTML video element with Media Source Extensions, and on Safari iOS where MSE is unavailable it can use Managed Media Source for supported versions.
The client handles VOD, live, and low-latency HLS with fragmented MP4, MPEG-2 transport streams, and packed audio segments. It can transmux MPEG-2 TS and packed audio into fMP4, optionally in a Web Worker. Control flows through the standard HTMLMediaElement API while the library loads playlists, selects quality levels and audio tracks, and exposes streaming events.
Feature coverage in the documentation includes adaptive bitrate switching modes, DVR on live playlists, partial segments and blocking playlist reload for low latency, DRM via EME for several CDMs, captions and subtitles in multiple formats, AES decryption, interstitials for ad breaks, and recovery from network or media errors. Builds ship as full and light UMD and ESM bundles for embedding or bundler import.
Compatibility notes list desktop and mobile browsers that support MSE with MP4 inputs, including Chrome, Firefox, Edge, Safari, and Android variants. Node.js requires only export a stub object and does not run playback server-side.
Key features
- VOD, live, and low-latency HLS
- Adaptive manual and auto quality switching
- fMP4 and MPEG-2 TS segment support
- Web Worker transmuxing
- EME DRM for common CDMs
- Alternate audio and subtitle tracks
- Built-in streaming analytics events
- Error retry and recovery hooks
Use cases
- In-browser live event streaming
- Adaptive VOD playback in web apps
- Low-latency HLS demos and products
- Custom player UI on HTML video
- DRM-protected stream playback