Player API details
Further customize your THEOlive player through API
A basic player API is made available in the THEOlive NPM player:
Properties
Property | Type | Description |
---|---|---|
muted | boolean | Get or set whether the audio is muted. |
paused | boolean | Returns whether the player is paused. |
volume | number | Get or set the current volume percentage as a floating point value between 0 and 1. (Not supported on iOS safari due to browser restrictions) |
presentation | Presentation | undefined | Returns the Presentation API. This value is undefined when using the version without UI. |
Methods
Method | Description |
---|---|
play(): void | Start or resume playback. |
pause(): void | Pause playback. |
destroy(): void | Destroy the player. This stops playback and releases all resources associated with this player. |
loadChannel(channelId: string): Promise | Load a channel. |
preloadChannels(channelIds: string[]): Promise | Fetch 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 name | Description |
---|---|
play | Fired when the player is no longer paused, when play() is called or autoplay is enabled. |
pause | Fired when the player is paused, when pause() is called. |
playing | Fired when the player is not paused and starts progressing playback, so initially when the player starts or when the player recovers from a stall. |
waiting | Fired when the player is not paused but stops progressing, when the buffer is empty. |
volumechange | Fired when either the volume or the muted property changes. (Not supported on iOS safari due to browser restrictions) |
channelloaded | Fired when the player has loaded a channel. |
intenttofallback | Fired 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. |
error | Fired when the player enters a state from which it cannot recover without a new loadChannel call. |
Presentation API
Property / Method | Return type | Description |
---|---|---|
currentMode | 'fullscreen' | 'inline' | Returns the current presentation mode. |
requestMode(mode) | void | Set the mode to 'fullscreen' or 'inline'. |
supportsMode(mode) | boolean | Returns whether the current platform supports the given mode. |
Updated 18 days ago