Skip to main content

Interface: enplug

The Player SDK can be accessed through the global enplug/window.enplug object in the app.

Most popular APIs exposed by the Player SDK:

Others:

Example usage of Player SDK
const asset = await enplug.assets.getNext();
note

To have these APIs available in your app, you need to install Player SDK into your project.

Properties#

appStatus#

appStatus: AppStatus


assets#

assets: Assets


cache#

cache: Cache


desktopAlerts#

desktopAlerts: DesktopAlerts


notifications#

notifications: Notifications


off#

off: (eventName: string, eventHandler: (...args: any[]) => any) => void

Type declaration#

▸ (eventName, eventHandler): void

Removes a handler function from listening to the event.

Can be used to attach a new handler for a specific event by that event’s name. If you wish to remove this event handler at any time, you will need to keep a reference to the handler function and pass it into the off function.

see on to add an event handler

Adding and removing event handler
function handler(eventData) {  // ...}enplug.on('my-event', handler);enplug.off('my-event', handler);
Parameters#
NameTypeDescription
eventNamestringName of the event.
eventHandler(...args: any[]) => anyHandler function to remove.
Returns#

void


on#

on: (eventName: string, eventHandler: (...args: any[]) => any) => Promise<void>

Type declaration#

▸ (eventName, eventHandler): Promise<void>

Lets apps listen for events. The events are triggered by messages with service == 'event' coming from the Player through the bridge.

Can be used to attach a new handler for a specific event by that event’s name.

Adding event handler
enplug.on('my-event', (eventData) => {  // ...});

If you wish to remove this event handler at any time, you will need to keep a reference to the handler function and pass it into the off function.

see off to remove an event handler

Parameters#
NameTypeDescription
eventNamestringName of the event.
eventHandler(...args: any[]) => anyAn event handler, called when the event occurs.
Returns#

Promise<void>


once#

once: (eventName: string, eventHandler: (...args: any[]) => any) => Promise<void>

Type declaration#

▸ (eventName, eventHandler): Promise<void>

Lets apps listen for an event. After it occurs once, it removes the listener.

The once function is a convenience function for adding an event handler that gets automatically removed after the first time it is fired. The code below is the functional equivalent of the once function’s functionality.

function handler(eventData) {  enplug.off('my-event', handler);  // your handler run here}enplug.on('my-event', handler);
Parameters#
NameTypeDescription
eventNamestringName of the event.
eventHandler(...args: any[]) => anyHandler function to fire once when the event occurs.
Returns#

Promise<void>


playRecorder#

playRecorder: PlayRecorder


settings#

settings: Settings


social#

social: Social