Home Reference Source
import Hls from 'hls.js/src/hls.ts'
public class | source

Hls

Static Member Summary

Static Public Members
public static get

DefaultConfig: HlsConfig

public static set

DefaultConfig: HlsConfig

public static get
public static get
public static get

Events: *

public static

defaultConfig: HlsConfig

public static get

Static Method Summary

Static Public Methods
public static

Constructor Summary

Public Constructor
public

constructor(config: HlsConfig)

Creates an instance of an HLS client that can attach to exactly one HTMLMediaElement.

Member Summary

Public Members
public
public get

index of the selected audio track (index in audio track lists)

public set

selects an audio track, based on its index in audio track lists

public
public get

audioTracks: AudioTrack[]

public get

Capping/max level value that should be used by automatic level selection algorithm (ABRController)

public set

Capping/max level value that should be used by automatic level selection algorithm (ABRController)

public get

True when automatic level selection enabled

public get

get bandwidth estimate

public
public
public get

Get the current setting for capLevelToPlayerSize

public set

set dynamically set capLevelToPlayerSize against (CapLevelController)

public
public

config: HlsConfig

public
public get

Index of quality level currently played

public set

Set quality level index immediately .

public get

drift: *

the rate at which the edge of the current live playlist is advancing or 1 if there is none

public
public get

Return "first level": like a default level, if not set, falls back to index of first level referenced in manifest

public set

Sets "first-level", see getter.

public get

set to true when startLoad is called before MANIFEST_PARSED event

public get

latency: *

estimated position (in seconds) of live edge (ie edge of live playlist plus time sync playlist advanced) returns 0 before first playlist is loaded

public
public
public get
public get

position (in seconds) of live sync point (ie edge of live position minus safety delay defined by hls.config.liveSyncDuration)

public get

Return the quality level of the currently or last (of none is loaded currently) segment

public set

Set quality level index for next loaded data in a conservative way.

public get

get mode for Low-Latency HLS loading

public set

Enable/disable Low-Latency HLS part playlist and segment loading, and start live streams at playlist PART-HOLD-BACK rather than HOLD-BACK.

public get
public get

Level set manually (if any)

public get

max level selectable in auto mode according to autoLevelCapping

public get

maxHdcpLevel: HdcpLevel

public set

maxHdcpLevel: HdcpLevel

public get

maximum distance from the edge before the player seeks forward to hls.liveSyncPosition configured using liveMaxLatencyDurationCount (multiple of target duration) or liveMaxLatencyDuration returns 0 before first playlist is loaded

public get

media: *

public get

min level selectable in auto mode according to config.minAutoBitrate

public
public get

next automatically selected quality level

public set

this setter is used to force next auto level.

public get

Index of next quality level loaded as scheduled by stream controller.

public set

Set quality level index for next loaded data.

public get

get next quality level loaded

public set

Set quality level of next loaded segment in a fully "non-destructive" way.

public get

get the datetime value relative to media.currentTime for the active level Program Date Time if present

public get

Return start level (level of first fragment that will be played back) if not overrided by user, first level appearing in manifest will be used as start level if -1 : automatic start level selection, playback will start from level matching download bandwidth (determined from download of first segment)

public set

set start level (level of first fragment that will be played back) if not overrided by user, first level appearing in manifest will be used as start level if -1 : automatic start level selection, playback will start from level matching download bandwidth (determined from download of first segment)

public
public get
public set

Enable/disable subtitle display rendering

public get

index of the selected subtitle track (index in subtitle track lists)

public set

select an subtitle track, based on its index in subtitle track lists

public
public get

get alternate subtitle tracks list from playlist

public get

target distance from the edge as calculated by the latency controller

public get

get time to first byte estimate

public

url: *

public

userConfig: Partial

Private Members
private
private

_emitter: HlsEventEmitter

private

_maxHdcpLevel: HdcpLevel

private

_media: *

Method Summary

Public Methods
public

attachMedia(media: HTMLMediaElement)

Attaches Hls.js to a media element

public

createController(ControllerClass: undefined, components: undefined): *

public

Dispose of the instance

public

Detach Hls.js from the media

public

emit(event: E, name: E, eventObject: undefined): boolean

public

listenerCount(event: E): number

public

listeners(event: E): *

public

Set the source URL.

public

off(event: E, listener: undefined, context: Context, once: undefined)

public

on(event: E, listener: undefined, context: Context)

public

once(event: E, listener: undefined, context: Context)

public

When the media-element fails, this allows to detach and then re-attach it as one call (convenience method).

public
public

removeLevel(levelIndex: undefined, urlId: undefined)

public

startLoad(startPosition: number)

Start loading data from the stream source.

public

Stop loading of any stream data.

public

Swap through possible audio codecs in the stream (for example to switch from stereo to 5.1)

public

trigger(event: E, eventObject: undefined): boolean

Static Public Members

public static get DefaultConfig: HlsConfig source

public static set DefaultConfig: HlsConfig source

public static get ErrorDetails: * source

public static get ErrorTypes: * source

public static get Events: * source

public static defaultConfig: HlsConfig source

public static get version: string source

Static Public Methods

public static isSupported(): boolean source

Return:

boolean

Public Constructors

public constructor(config: HlsConfig) source

Creates an instance of an HLS client that can attach to exactly one HTMLMediaElement.

Params:

NameTypeAttributeDescription
config HlsConfig

Public Members

public abrController: AbrController source

public get audioTrack: number source

index of the selected audio track (index in audio track lists)

public set audioTrack: number source

selects an audio track, based on its index in audio track lists

public audioTrackController: AudioTrackController source

public get audioTracks: AudioTrack[] source

public get autoLevelCapping: number source

Capping/max level value that should be used by automatic level selection algorithm (ABRController)

public set autoLevelCapping: number source

Capping/max level value that should be used by automatic level selection algorithm (ABRController)

public get autoLevelEnabled: boolean source

True when automatic level selection enabled

public get bandwidthEstimate: number source

get bandwidth estimate

public bufferController: BufferController source

public capLevelController: CapLevelController source

public get capLevelToPlayerSize: boolean source

Get the current setting for capLevelToPlayerSize

public set capLevelToPlayerSize: boolean source

set dynamically set capLevelToPlayerSize against (CapLevelController)

public cmcdController: CMCDController source

public config: HlsConfig source

public coreComponents: * source

public get currentLevel: number source

Index of quality level currently played

public set currentLevel: number source

Set quality level index immediately . This will flush the current buffer to replace the quality asap. That means playback will interrupt at least shortly to re-buffer and re-sync eventually.

public get drift: * source

the rate at which the edge of the current live playlist is advancing or 1 if there is none

public emeController: EMEController source

public get firstLevel: number source

Return "first level": like a default level, if not set, falls back to index of first level referenced in manifest

public set firstLevel: number source

Sets "first-level", see getter.

public get forceStartLoad: boolean source

set to true when startLoad is called before MANIFEST_PARSED event

public get latency: * source

estimated position (in seconds) of live edge (ie edge of live playlist plus time sync playlist advanced) returns 0 before first playlist is loaded

public latencyController: LatencyController source

public levelController: LevelController source

public get levels: Level[] source

public get liveSyncPosition: * source

position (in seconds) of live sync point (ie edge of live position minus safety delay defined by hls.config.liveSyncDuration)

public get loadLevel: number source

Return the quality level of the currently or last (of none is loaded currently) segment

public set loadLevel: number source

Set quality level index for next loaded data in a conservative way. This will switch the quality without flushing, but interrupt current loading. Thus the moment when the quality switch will appear in effect will only be after the already existing buffer.

public get lowLatencyMode: * source

get mode for Low-Latency HLS loading

public set lowLatencyMode: boolean source

Enable/disable Low-Latency HLS part playlist and segment loading, and start live streams at playlist PART-HOLD-BACK rather than HOLD-BACK.

public get mainForwardBufferInfo: * source

public get manualLevel: number source

Level set manually (if any)

public get maxAutoLevel: number source

max level selectable in auto mode according to autoLevelCapping

public get maxHdcpLevel: HdcpLevel source

public set maxHdcpLevel: HdcpLevel source

public get maxLatency: number source

maximum distance from the edge before the player seeks forward to hls.liveSyncPosition configured using liveMaxLatencyDurationCount (multiple of target duration) or liveMaxLatencyDuration returns 0 before first playlist is loaded

public get media: * source

public get minAutoLevel: number source

min level selectable in auto mode according to config.minAutoBitrate

public networkControllers: * source

public get nextAutoLevel: number source

next automatically selected quality level

public set nextAutoLevel: number source

this setter is used to force next auto level. this is useful to force a switch down in auto mode: in case of load error on level N, hls.js can set nextAutoLevel to N-1 for example) forced value is valid for one fragment. upon successful frag loading at forced level, this value will be resetted to -1 by ABR controller.

public get nextLevel: number source

Index of next quality level loaded as scheduled by stream controller.

public set nextLevel: number source

Set quality level index for next loaded data. This will switch the video quality asap, without interrupting playback. May abort current loading of data, and flush parts of buffer (outside currently played fragment region).

public get nextLoadLevel: number source

get next quality level loaded

public set nextLoadLevel: number source

Set quality level of next loaded segment in a fully "non-destructive" way. Same as loadLevel but will wait for next switch (until current loading is done).

public get playingDate: * source

get the datetime value relative to media.currentTime for the active level Program Date Time if present

public get startLevel: number source

Return start level (level of first fragment that will be played back) if not overrided by user, first level appearing in manifest will be used as start level if -1 : automatic start level selection, playback will start from level matching download bandwidth (determined from download of first segment)

public set startLevel: number source

set start level (level of first fragment that will be played back) if not overrided by user, first level appearing in manifest will be used as start level if -1 : automatic start level selection, playback will start from level matching download bandwidth (determined from download of first segment)

public streamController: StreamController source

public get subtitleDisplay: boolean source

public set subtitleDisplay: boolean source

Enable/disable subtitle display rendering

public get subtitleTrack: number source

index of the selected subtitle track (index in subtitle track lists)

public set subtitleTrack: number source

select an subtitle track, based on its index in subtitle track lists

public subtitleTrackController: SubtitleTrackController source

public get subtitleTracks: Array source

get alternate subtitle tracks list from playlist

public get targetLatency: * source

target distance from the edge as calculated by the latency controller

public get ttfbEstimate: number source

get time to first byte estimate

public url: * source

public userConfig: Partial source

Private Members

private _autoLevelCapping: number source

private _emitter: HlsEventEmitter source

private _maxHdcpLevel: HdcpLevel source

private _media: * source

Public Methods

public attachMedia(media: HTMLMediaElement) source

Attaches Hls.js to a media element

Params:

NameTypeAttributeDescription
media HTMLMediaElement

public createController(ControllerClass: undefined, components: undefined): * source

Params:

NameTypeAttributeDescription
ControllerClass undefined
components undefined

Return:

*

public destroy() source

Dispose of the instance

public detachMedia() source

Detach Hls.js from the media

public emit(event: E, name: E, eventObject: undefined): boolean source

Params:

NameTypeAttributeDescription
event E
name E
eventObject undefined

Return:

boolean

public listenerCount(event: E): number source

Params:

NameTypeAttributeDescription
event E

Return:

number

public listeners(event: E): * source

Params:

NameTypeAttributeDescription
event E

Return:

*

public loadSource(url: string) source

Set the source URL. Can be relative or absolute.

Params:

NameTypeAttributeDescription
url string

public off(event: E, listener: undefined, context: Context, once: undefined) source

Params:

NameTypeAttributeDescription
event E
listener undefined
context Context
once undefined

public on(event: E, listener: undefined, context: Context) source

Params:

NameTypeAttributeDescription
event E
listener undefined
context Context

public once(event: E, listener: undefined, context: Context) source

Params:

NameTypeAttributeDescription
event E
listener undefined
context Context

public recoverMediaError() source

When the media-element fails, this allows to detach and then re-attach it as one call (convenience method).

Automatic recovery of media-errors by this process is configurable.

public removeAllListeners(event: undefined) source

Params:

NameTypeAttributeDescription
event undefined

public removeLevel(levelIndex: undefined, urlId: undefined) source

Params:

NameTypeAttributeDescription
levelIndex undefined
urlId undefined

public startLoad(startPosition: number) source

Start loading data from the stream source. Depending on default config, client starts loading automatically when a source is set.

Params:

NameTypeAttributeDescription
startPosition number

public stopLoad() source

Stop loading of any stream data.

public swapAudioCodec() source

Swap through possible audio codecs in the stream (for example to switch from stereo to 5.1)

public trigger(event: E, eventObject: undefined): boolean source

Params:

NameTypeAttributeDescription
event E
eventObject undefined

Return:

boolean