Player API details

Further customize your THEOlive player through API

A basic player API is made available in the THEOlive NPM player:

Properties

PropertyTypeDescription
mutedbooleanGet or set whether the audio is muted.
pausedbooleanReturns whether the player is paused.
volumenumberGet or set the current volume percentage as a floating point value between 0 and 1.
presentationPresentation | undefinedReturns the Presentation API. This value is undefined when using the version without UI.

Methods

MethodDescription
play(): voidStart or resume playback.
pause(): voidPause playback.
destroy(): voidDestroy the player. This stops playback and releases all resources associated with this player.
loadChannel(channelId: string): PromiseLoad a channel.
preloadChannels(channelIds: string[]): PromiseFetch the metadata of a list of THEOlive channels. This API method is used for smooth zapping so all channel metadata is loaded up front.
addEventListener(type: string, listener: (event: Event) => void)Add a event listener for the given event type.
removeEventListener(type: string, listener: (event: Event) => void)Remove a previously registered event listener.

Events

Event nameDescription
playFired when the player is no longer paused, when play() is called or autoplay is enabled.
pauseFired when the player is paused, when pause() is called.
playingFired when the player is not paused and starts progressing playback, so initially when the player starts or when the player recovers from a stall.
waitingFired when the player is not paused but stops progressing, when the buffer is empty.
volumechangeFired when either the volume or the muted property changes.
channelloadedFired when the player has loaded a channel.
intenttofallbackFired when the player notices its channel is not in a healthy state. When a fallback channel is configured, the player will automatically fallback to that channel. Expert users can listen to this event to have full control over how to fallback to an alternative.
errorFired when the player enters a state from which it cannot recover without a new loadChannel call.

Presentation API

Property / MethodReturn typeDescription
currentMode'fullscreen' | 'inline'Returns the current presentation mode.
requestMode(mode)voidSet the mode to 'fullscreen' or 'inline'.
supportsMode(mode)booleanReturns whether the current platform supports the given mode.