Esta página se muestra en inglés. Una traducción al español está en curso.
ScriptsMay 20, 2026·3 min de lectura

HLS.js — HTTP Live Streaming Client for the Web

A JavaScript library that implements an HLS client, enabling playback of HTTP Live Streaming content in any browser with MediaSource Extensions support.

Listo para agents

Este activo puede ser leído e instalado directamente por agents

TokRepo expone un comando CLI universal, contrato de instalación, metadata JSON, plan según adaptador y contenido raw para que los agents evalúen compatibilidad, riesgo y próximos pasos.

Stage only · 17/100Stage only
Superficie agent
Cualquier agent MCP/CLI
Tipo
CLI Tool
Instalación
Stage only
Confianza
Confianza: Established
Entrada
HLS.js Overview
Comando CLI universal
npx tokrepo install 2e872258-548a-11f1-9bc6-00163e2b0d79

Introduction

HLS.js is a JavaScript library that brings HTTP Live Streaming (HLS) playback to browsers via the MediaSource Extensions API. It parses M3U8 playlists, manages segment fetching, handles adaptive bitrate switching, and feeds media data into a standard HTML5 video element without requiring native HLS support.

What HLS.js Does

  • Parses M3U8 master and variant playlists for multi-quality streams
  • Downloads and demuxes MPEG-TS and fMP4 segments in a web worker
  • Implements adaptive bitrate (ABR) switching based on bandwidth and buffer
  • Supports live, event, and VOD stream types with DVR window management
  • Handles DRM via Encrypted Media Extensions for protected content

Architecture Overview

HLS.js runs a loader pipeline that fetches playlist manifests and media segments over HTTP. A transmuxer in a Web Worker converts MPEG-TS containers to fragmented MP4 on the fly. Parsed media is appended to a MediaSource SourceBuffer, and the ABR controller monitors download speed and buffer levels to select the optimal quality level. The entire pipeline is event-driven and modular.

Self-Hosting & Configuration

  • Install from npm or load the UMD bundle from a CDN
  • Create an Hls instance and call loadSource() with your M3U8 URL
  • Attach to any HTML5 video element with attachMedia()
  • Tune ABR behavior with config options like maxBufferLength and abrBandWidthFactor
  • Enable low-latency mode with lowLatencyMode: true for LL-HLS streams

Key Features

  • Works in any browser that supports MediaSource Extensions
  • Adaptive bitrate switching with configurable bandwidth estimation
  • Web Worker-based transmuxing keeps the main thread responsive
  • Low-latency HLS (LL-HLS) support with partial segment loading
  • Subtitle and alternative audio track selection

Comparison with Similar Tools

  • dash.js — MPEG-DASH reference player; HLS.js focuses exclusively on the HLS protocol
  • Shaka Player — Supports both DASH and HLS with DRM; HLS.js is lighter and HLS-specific
  • Video.js + videojs-http-streaming — Full player with HLS plugin; HLS.js is the standalone engine
  • Native HLS (Safari) — Built into WebKit; HLS.js brings the same capability to Chrome and Firefox

FAQ

Q: Does HLS.js work in Safari? A: Safari has native HLS support. HLS.js detects this and can optionally fall back to native playback.

Q: Can I use HLS.js with a custom player UI? A: Yes. It only handles streaming logic and attaches to a plain video element. Pair it with Plyr or any UI layer.

Q: Does it support DRM-protected streams? A: Yes, via the Encrypted Media Extensions API. Configure emeEnabled and provide license server URLs.

Q: How do I handle live streams with DVR? A: HLS.js exposes a seekable range. Set liveSyncDuration and liveMaxLatencyDuration to control DVR window behavior.

Sources

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados