- Version
- 1.0.0
- License
- MIT
- Requires
- ExtendedMediaError
- Source
- Dash.js, line 15
Constructor
new Dash(player, mediaComponent, apiKey)
Members
private #config :Object
The dash configuration, containing debug and optional DRM details.
| Name | Type | Attributes | Default | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
lazyLoadLib
|
boolean | optional | true | If |
||||||||||||||||
libUrl
|
string | optional | Custom URL for the Dash.js library. Defaults to CDN URL if not specified. |
|||||||||||||||||
debug
|
Object | boolean | optional | false | Debug settings or boolean to enable debug logs.
|
private #player :Player
private #subscriptions :Array<number>
Subscriptions to various player events that we handle specifically for dash.
private #apiKey :symbol
Secret key only known to the player instance and initialized components. Used to be able to restrict access to API methods in conjunction with secure mode.
private #mediaComponent :Media
private #dash :Object
private #availableTracks :Object
private #loadTask :AsyncTask
Reference to the Async Task instance. Used to handle async tasks, which can be cancelled, resolved or rejected.
private #metaData :Media~metaData
Holds metadata information provided by media.load and loaded metadata.
- Type
- Media~metaData
- Source
- Dash.js, line 84
private #loadDashPromise :Promise
private, static #dashProtectionEventNames :Array<string>
Methods
canPlay(metaData) → 'probably'|'maybe'|''
Tells whether this plugin can handle the given mimeType and optional DRM system.
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
metaData |
Media~metaData |
The data to test.
|
async load(metaData, optionsopt) → Promise|undefined
Initializes the dash.js MediaPlayer with the given source.
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
metaData |
Media~metaData |
Source Object (currentSource).
|
|||||||||
options |
Object | optional |
Additional options.
|
private #loadDashJs() → Promise<void>
Loads dash.js via CDN if not present. Ensures only one load attempt per instance.
onLoaded(metaData)
Called by the media component when metadata has loaded, but before the media/ready event has been sent.
Allows the plugin to add additional metadata to the mediaSource object.
| Name | Type | Description |
|---|---|---|
metaData |
Media~metaData |
The updated meta data object. |
private #onMetaDataLoaded()
Handler for dash.js PLAYBACK_METADATA_LOADED event. Sets up track lists, languages, qualities.
- Fires
- quality/update
- language/update
- subtitles/update
- Listens
- dashjs.MediaPlayer.events.event:PLAYBACK_METADATA_LOADED
- Source
- Dash.js, line 366
private #onSubtitlesSelected(selected)
Handler for 'subtitles/selected' event. Matches the track to dash, calls dash.setTextTrack.
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
selected |
Object |
Object containing information about the selected Subtitle.
|
- Listens
- subtitles/selected
- Source
- Dash.js, line 385
private #onLanguageSelected(langObj)
Handler for 'language/selected' event. Chooses the matching audio track in dash.
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
langObj |
Language~langObj |
Object containing selected language information.
|
- Listens
- language/selected
- Source
- Dash.js, line 401
private #onQualitySelected(selected)
Handler for 'quality/selected' event. If the user picks a specific resolution, use it; else 'auto'.
| Name | Type | Description |
|---|---|---|
selected |
string |
The chosen resolution in the format ' |
- Listens
- quality/selected
- Source
- Dash.js, line 450
private #onQualityResize(size)
Handler for 'quality/resize' event. Caps the max bitrate if display size is small.
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
size |
Object |
Object containing size information.
|
- Listens
- quality/resize
- Source
- Dash.js, line 481
private #onTrackChangeRendered(mediaInfo)
Handler for dash.js TRACK_CHANGE_RENDERED event. If it's audio, update the player's language state.
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
mediaInfo |
Object |
The media info object with the changed settings.
|
- Fires
- language/active
- Listens
- dashjs.MediaPlayer.events.event:TRACK_CHANGE_RENDERED
- Source
- Dash.js, line 511
private #onQualityChangeRendered(mediaInfo)
Handler for dash.js QUALITY_CHANGE_RENDERED event. Publishes 'quality/active' with the current resolution.
| Name | Type | Description |
|---|---|---|
mediaInfo |
Object |
The media info object with the changed settings. |
- Fires
- quality/active
- Listens
- dashjs.MediaPlayer.events.event:QUALITY_CHANGE_RENDERED
- Source
- Dash.js, line 524
private #onDrmKeyStatus(event)
Handler for dash.js 'INTERNAL_KEY_STATUS_CHANGED' event. If a key is restricted or expired, send a media error.
| Name | Type | Description |
|---|---|---|
event |
Object |
The event coming from dash. |
private #onDashError(event)
Handler for dash.js ERROR event. Maps dash error codes to simulated media errors, publishes 'media/error'.
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
event |
Object |
The dahs event object.
|
- Fires
- media/error
- Source
- Dash.js, line 568
private #onProtectionEvent(event)
Handler for dash protection events if debug is enabled.
| Name | Type | Description |
|---|---|---|
event |
Object |
Event data from dash.js protection. |
private #onDashEvent(event)
Generic handler for dash.js events when debug mode is enabled. Filters out noisy or frequent events and logs others to the console. This helps with development and troubleshooting by surfacing meaningful events only.
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
event |
Object |
The event object emitted by dash.js.
|
private #removeDash()
Handler for removing dash when 'data/ready' triggers a new media load. Cleans up subscriptions and dash instance.
- Listens
- data/ready
- Source
- Dash.js, line 654