Player
Enumerations
Events
List of events.
Enumeration Members
Enumeration Member | Value |
---|---|
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()
new HlsFacade(hls, userOptions?): HlsFacade
Parameters
Parameter | Type |
---|---|
hls | Hls |
userOptions ? | Partial <HlsFacadeOptions > |
Returns
Properties
Property | Type |
---|---|
hls | Hls |
Accessors
audioTracks
get audioTracks(): AudioTrack[]
Audio tracks of the primary asset.
Returns
autoQuality
get autoQuality(): boolean
Whether auto quality is enabled for all assets.
Returns
boolean
cuePoints
get cuePoints(): number[]
A list of ad cue points, can be used to plot on a seekbar.
Returns
number
[]
duration
get duration(): number
Duration of the primary asset.
Returns
number
interstitial
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
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
qualities
get qualities(): Quality[]
Qualities list of the primary asset.
Returns
Quality
[]
ready
get ready(): boolean
We're ready when the master playlist is loaded.
Returns
boolean
started
get started(): boolean
We're started when atleast 1 asset started playback, either the master or interstitial playlist started playing.
Returns
boolean
subtitleTracks
get subtitleTracks(): SubtitleTrack[]
Subtitle tracks of the primary asset.
Returns
time
get time(): number
Time of the primary asset.
Returns
number
volume
get volume(): number
Volume across all assets.
Returns
number
Methods
destroy()
destroy(): void
Destroys the facade.
Returns
void
off()
off<E>(event, listener): void
Type Parameters
Type Parameter |
---|
E extends keyof HlsFacadeListeners |
Parameters
Parameter | Type |
---|---|
event | E |
listener | HlsFacadeListeners [E ] |
Returns
void
on()
on<E>(event, listener): void
Type Parameters
Type Parameter |
---|
E extends keyof HlsFacadeListeners |
Parameters
Parameter | Type |
---|---|
event | E |
listener | HlsFacadeListeners [E ] |
Returns
void
playOrPause()
playOrPause(): void
Toggles play or pause.
Returns
void
seekTo()
seekTo(targetTime): void
Seek to a time in primary content.
Parameters
Parameter | Type | Description |
---|---|---|
targetTime | number |
Returns
void
setAudioTrack()
setAudioTrack(id): void
Sets audio by id. All audio tracks are defined in audioTracks
.
Parameters
Parameter | Type | Description |
---|---|---|
id | number |
Returns
void
setQuality()
setQuality(height): void
Sets quality by id. All quality levels are defined in qualities
.
Parameters
Parameter | Type | Description |
---|---|---|
height | null | number |
Returns
void
setSubtitleTrack()
setSubtitleTrack(id): void
Sets subtitle by id. All subtitle tracks are defined in subtitleTracks
.
Parameters
Parameter | Type | Description |
---|---|---|
id | null | number |
Returns
void
setVolume()
setVolume(volume): void
Sets volume.
Parameters
Parameter | Type | Description |
---|---|---|
volume | number |
Returns
void
use()
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
Parameter | Type | Description |
---|---|---|
fn | HlsFacadePluginFn |
Returns
void
Type Aliases
AudioTrack
type AudioTrack: object;
Defines an audio track.
Type declaration
Name | Type |
---|---|
active | boolean |
id | number |
label | string |
track | MediaPlaylist |
AudioTracksChangeEventData
type AudioTracksChangeEventData: object;
Type declaration
Name | Type |
---|---|
audioTracks | AudioTrack [] |
AutoQualityChangeEventData
type AutoQualityChangeEventData: object;
Type declaration
Name | Type |
---|---|
autoQuality | boolean |
CustomInterstitialType
type CustomInterstitialType: "ad" | "bumper";
A custom type for each ASSET
.
HlsFacadeListeners
type HlsFacadeListeners: object;
List of events with their respective event handlers.
Type declaration
Name | Type |
---|---|
* | () => 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
type HlsFacadeOptions: object;
Type declaration
Name | Type |
---|---|
multipleVideoElements | boolean |
HlsFacadePluginFn()
type HlsFacadePluginFn: (facade) => () => void;
A plugin is a function that receives a facade instance, and expects a destroy function as return value.
Parameters
Parameter | Type |
---|---|
facade | HlsFacade |
Returns
Function
Returns
void
Interstitial
type Interstitial: object;
Defines an interstitial, which is not the primary content.
Type declaration
Name | Type |
---|---|
duration | number |
player | HlsAssetPlayer |
time | number |
type ? | CustomInterstitialType |
Playhead
type Playhead:
| "idle"
| "play"
| "playing"
| "pause"
| "ended";
State of playhead across all assets.
PlayheadChangeEventData
type PlayheadChangeEventData: object;
Type declaration
Name | Type |
---|---|
playhead | Playhead |
started | boolean |
QualitiesChangeEventData
type QualitiesChangeEventData: object;
Type declaration
Name | Type |
---|---|
qualities | Quality [] |
Quality
type Quality: object;
Defines a quality level.
Type declaration
Name | Type |
---|---|
active | boolean |
height | number |
levels | Level [] |
State
type State: object;
State variables.
Type declaration
Name | Type |
---|---|
audioTracks | AudioTrack [] |
autoQuality | boolean |
duration | number |
playhead | Playhead |
qualities | Quality [] |
started | boolean |
subtitleTracks | SubtitleTrack [] |
time | number |
volume | number |
SubtitleTrack
type SubtitleTrack: object;
Defines an in-band subtitle track.
Type declaration
Name | Type |
---|---|
active | boolean |
id | number |
label | string |
track | MediaPlaylist |
SubtitleTracksChangeEventData
type SubtitleTracksChangeEventData: object;
Type declaration
Name | Type |
---|---|
subtitleTracks | SubtitleTrack [] |
TimeChangeEventData
type TimeChangeEventData: object;
Type declaration
Name | Type |
---|---|
duration | number |
time | number |
VolumeChangeEventData
type VolumeChangeEventData: object;
Type declaration
Name | Type |
---|---|
volume | number |