Skip to content

Player

Enumerations

Events

List of events.

Enumeration Members

Enumeration MemberValue
AUDIO_TRACKS_CHANGE"audioTracksChange"
AUTO_QUALITY_CHANGE"autoQualityChange"
PLAYHEAD_CHANGE"playheadChange"
QUALITIES_CHANGE"qualitiesChange"
READY"ready"
RESET"reset"
SUBTITLE_TRACKS_CHANGE"subtitleTracksChange"
TIME_CHANGE"timeChange"
VOLUME_CHANGE"volumeChange"

Classes

HlsFacade

A facade wrapper that simplifies working with HLS.js API.

Constructors

new HlsFacade()
ts
new HlsFacade(hls, userOptions?): HlsFacade
Parameters
ParameterType
hlsHls
userOptions?Partial<HlsFacadeOptions>
Returns

HlsFacade

Properties

PropertyType
hlsHls

Accessors

audioTracks
ts
get audioTracks(): AudioTrack[]

Audio tracks of the primary asset.

Returns

AudioTrack[]

autoQuality
ts
get autoQuality(): boolean

Whether auto quality is enabled for all assets.

Returns

boolean

cuePoints
ts
get cuePoints(): number[]

A list of ad cue points, can be used to plot on a seekbar.

Returns

number[]

duration
ts
get duration(): number

Duration of the primary asset.

Returns

number

interstitial
ts
get interstitial(): null | Interstitial

When currently playing an interstitial, this holds all the info from that interstitial, such as time / duration, ...

Returns

null | Interstitial

playhead
ts
get playhead(): Playhead

Returns the playhead, will preserve the user intent across interstitials. When we're switching to an interstitial, and the user explicitly requested play, we'll still return the state as playing.

Returns

Playhead

qualities
ts
get qualities(): Quality[]

Qualities list of the primary asset.

Returns

Quality[]

ready
ts
get ready(): boolean

We're ready when the master playlist is loaded.

Returns

boolean

started
ts
get started(): boolean

We're started when atleast 1 asset started playback, either the master or interstitial playlist started playing.

Returns

boolean

subtitleTracks
ts
get subtitleTracks(): SubtitleTrack[]

Subtitle tracks of the primary asset.

Returns

SubtitleTrack[]

time
ts
get time(): number

Time of the primary asset.

Returns

number

volume
ts
get volume(): number

Volume across all assets.

Returns

number

Methods

destroy()
ts
destroy(): void

Destroys the facade.

Returns

void

off()
ts
off<E>(event, listener): void
Type Parameters
Type Parameter
E extends keyof HlsFacadeListeners
Parameters
ParameterType
eventE
listenerHlsFacadeListeners[E]
Returns

void

on()
ts
on<E>(event, listener): void
Type Parameters
Type Parameter
E extends keyof HlsFacadeListeners
Parameters
ParameterType
eventE
listenerHlsFacadeListeners[E]
Returns

void

playOrPause()
ts
playOrPause(): void

Toggles play or pause.

Returns

void

seekTo()
ts
seekTo(targetTime): void

Seek to a time in primary content.

Parameters
ParameterTypeDescription
targetTimenumber
Returns

void

setAudioTrack()
ts
setAudioTrack(id): void

Sets audio by id. All audio tracks are defined in audioTracks.

Parameters
ParameterTypeDescription
idnumber
Returns

void

setQuality()
ts
setQuality(height): void

Sets quality by id. All quality levels are defined in qualities.

Parameters
ParameterTypeDescription
heightnull | number
Returns

void

setSubtitleTrack()
ts
setSubtitleTrack(id): void

Sets subtitle by id. All subtitle tracks are defined in subtitleTracks.

Parameters
ParameterTypeDescription
idnull | number
Returns

void

setVolume()
ts
setVolume(volume): void

Sets volume.

Parameters
ParameterTypeDescription
volumenumber
Returns

void

use()
ts
use(fn): void

Register a plugin. It'll be called when an asset is ready, and the return value when the asset should be resetted.

Parameters
ParameterTypeDescription
fnHlsFacadePluginFn
Returns

void

Type Aliases

AudioTrack

ts
type AudioTrack: object;

Defines an audio track.

Type declaration

NameType
activeboolean
idnumber
labelstring
trackMediaPlaylist

AudioTracksChangeEventData

ts
type AudioTracksChangeEventData: object;

Type declaration

NameType
audioTracksAudioTrack[]

AutoQualityChangeEventData

ts
type AutoQualityChangeEventData: object;

Type declaration

NameType
autoQualityboolean

CustomInterstitialType

ts
type CustomInterstitialType: "ad" | "bumper";

A custom type for each ASSET.


HlsFacadeListeners

ts
type HlsFacadeListeners: object;

List of events with their respective event handlers.

Type declaration

NameType
*() => void
audioTracksChange(data) => void
autoQualityChange(data) => void
playheadChange(data) => void
qualitiesChange(data) => void
ready() => void
reset() => void
subtitleTracksChange(data) => void
timeChange(data) => void
volumeChange(data) => void

HlsFacadeOptions

ts
type HlsFacadeOptions: object;

Type declaration

NameType
multipleVideoElementsboolean

HlsFacadePluginFn()

ts
type HlsFacadePluginFn: (facade) => () => void;

A plugin is a function that receives a facade instance, and expects a destroy function as return value.

Parameters

ParameterType
facadeHlsFacade

Returns

Function

Returns

void


Interstitial

ts
type Interstitial: object;

Defines an interstitial, which is not the primary content.

Type declaration

NameType
durationnumber
playerHlsAssetPlayer
timenumber
type?CustomInterstitialType

Playhead

ts
type Playhead: 
  | "idle"
  | "play"
  | "playing"
  | "pause"
  | "ended";

State of playhead across all assets.


PlayheadChangeEventData

ts
type PlayheadChangeEventData: object;

Type declaration

NameType
playheadPlayhead
startedboolean

QualitiesChangeEventData

ts
type QualitiesChangeEventData: object;

Type declaration

NameType
qualitiesQuality[]

Quality

ts
type Quality: object;

Defines a quality level.

Type declaration

NameType
activeboolean
heightnumber
levelsLevel[]

State

ts
type State: object;

State variables.

Type declaration

NameType
audioTracksAudioTrack[]
autoQualityboolean
durationnumber
playheadPlayhead
qualitiesQuality[]
startedboolean
subtitleTracksSubtitleTrack[]
timenumber
volumenumber

SubtitleTrack

ts
type SubtitleTrack: object;

Defines an in-band subtitle track.

Type declaration

NameType
activeboolean
idnumber
labelstring
trackMediaPlaylist

SubtitleTracksChangeEventData

ts
type SubtitleTracksChangeEventData: object;

Type declaration

NameType
subtitleTracksSubtitleTrack[]

TimeChangeEventData

ts
type TimeChangeEventData: object;

Type declaration

NameType
durationnumber
timenumber

VolumeChangeEventData

ts
type VolumeChangeEventData: object;

Type declaration

NameType
volumenumber

Released under the MPL-2.0 License.