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:
enplug.appStatus
- managing apps's lifecycle and settingsenplug.assets
- fetching asset and themeenplug.settings
- fetching device's settings
Others:
enplug.cache
- loading file into cacheenplug.desktopAlerts
- Desktop Alerts dedicated commandsenplug.notifications
- launching alerts to the Playerenplug.playRecorder
- allows to record how long a particular screen was shownenplug.social
- social media related commands
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
function handler(eventData) { // ...}enplug.on('my-event', handler);enplug.off('my-event', handler);
#
ParametersName | Type | Description |
---|---|---|
eventName | string | Name of the event. |
eventHandler | (...args : any []) => any | Handler function to remove. |
#
Returnsvoid
#
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.
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
#
ParametersName | Type | Description |
---|---|---|
eventName | string | Name of the event. |
eventHandler | (...args : any []) => any | An event handler, called when the event occurs. |
#
ReturnsPromise
<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);
#
ParametersName | Type | Description |
---|---|---|
eventName | string | Name of the event. |
eventHandler | (...args : any []) => any | Handler function to fire once when the event occurs. |
#
ReturnsPromise
<void
>
#
playRecorder• playRecorder: PlayRecorder
#
settings• settings: Settings
#
social• social: Social