Architecture
dash.js is organized in layers with a strict direction of dependencies: the streaming/ layer implements the playback engine and the public API, the dash/ layer encapsulates everything MPD-related, and the core/ layer provides the infrastructure both build on. Smooth Streaming (mss/) and offline playback (offline/) are optional satellites with their own bundles.
The layers
core/— dependency injection (FactoryMaker), the EventBus,Settings,Debug/logging and the error definitions. No media logic.dash/— the MPD world: manifest parsing (parser/),DashAdapter(the facade the streaming layer uses to query the manifest — see Manifest Handling),DashHandler(segment request generation) andDashMetrics.streaming/— the playback engine and the entire public API surface (MediaPlayer.js). Contains the playback pipeline, the controllers, the ABR rules (see Adaptive Bitrate Streaming), the EME/DRM stack (protection/) and the HTTP loading stack (net/).mss/— Microsoft Smooth Streaming support, shipped as a separate bundle (dash.mss.min.js).offline/— offline download and playback.
Data flow at a glance
- The application calls
player.initialize(video, url, autoPlay). - The manifest is loaded and parsed; the streaming layer queries it exclusively through
DashAdapter. StreamControllercreates oneStreamper period; the activeStreamcreates oneStreamProcessorper media type (video, audio, text).- Each
StreamProcessorruns a schedule/load/append loop:DashHandlergenerates segment requests, thenet/stack loads them,SourceBufferSinkappends them to the Media Source Extensions buffers. - Metrics from every step feed the ABR rules, which adjust the selected Representation continuously.
Entry points
dash.js ships two entry points:
index.js(full build,dash.all.min.js) — everything: DRM (Protection), metrics reporting, text/subtitle support,MediaPlayerFactoryfor declarative setup.index_mediaplayerOnly.js(dash.mediaplayer.min.js) — the lightweight core:MediaPlayer,FactoryMakerand version info only. DRM, offline and text modules can be added at runtime as needed.
The following pages describe the individual building blocks in detail:
- Dependency Injection - the FactoryMaker pattern and per-player contexts
- Event Bus & Wiring - how modules communicate
- Playback Pipeline - from schedule decision to appended segment
- Manifest Handling - loading, parsing and the DashAdapter facade
- Error Model - error events vs. synchronous throws
