Class: AppStatus
AppStatus API is a part of the Player SDK used for managing app's lifecycle and state.
Use global enplug.appStatus
object to access these methods.
await enplug.appStatus.start();
Useful commands:
enplug.appStatus.start()
- app is readyenplug.appStatus.error()
- app has errored and cannot be displayedenplug.appStatus.hide()
- app should be hiddenenplug.appStatus.setCanInterrupt()
- informs whether the app can be hidden
#
Accessors#
canInterrupt• get
canInterrupt(): Promise
<boolean
>
Checks whether the app can be taken offscreen by the Player.
see
setCanInterrupt
const canInterrupt = await enplug.appStatus.canInterrupt;// here the value of canInterrupt will be true or false// depending on the previously set value// this value always initializes as true
#
ReturnsPromise
<boolean
>
Promise resolving to true if the app had requested not to be interrupted and false otherwise.
#
Methods#
error▸ error(errorMessage?
): Promise
<boolean
>
Informs the Player about an error with the app.
It is important to notify the Player if your application has reached an unresolvable error.
Calling the error function will notify the Player that your application is not operating properly
and should be removed from the current rotation of Player Applications.
Calling error
will typically end up with your application being disposed and destroyed from working memory.
enplug.appStatus.error('Could not preload resources');
#
ParametersName | Type | Description |
---|---|---|
errorMessage? | string | Error message to be passed to the logs. |
#
ReturnsPromise
<boolean
>
Resolves to true if the operation has completed successfully.
#
getTrigger▸ getTrigger(): Promise
<Trigger
>
Returns the reason why an app was rendered on-screen.
It is used for Social CMS apps. The response will contain a reason and data property. Check the value of the reason property to determine if this is a new item (reason === 'event').
For example, a response to getTrigger()
from a social app will contain the following:
{ reason: 'schedule' | 'event', data: { Id, SocialNetwork, SocialItemId, FeedId, CreatedTime, LastSavedTime, CreatedTime, ProfanityCount, ProfaneWords, IsApproved, IsAllowed, SecondaryText, ImageLocalPath, UserImageLocalPath }}
#
ReturnsPromise
<Trigger
>
Reason why an app was rendered on-screen.
#
hide▸ hide(): Promise
<boolean
>
Informs the Player that the app should be hidden.
If ever you want to hide your application the hide
function can be called to do so.
Calling this function will hide your application until it comes up in the normal application rotation cycle.
note
This will inform the Player that the app should be hidden as soon as possible. It might not happen immediately as the Player might need some time to prepare and get another app ready.
enplug.appStatus.hide();
caution
If your app is the only app playing on the display it will not be hidden.
#
ReturnsPromise
<boolean
>
Resolves to true when the app has been hidden from the screen.
#
registerServiceWorker▸ registerServiceWorker(appId?
, swFilePath?
): Promise
<string
>
Registers a service worker to enable offline support for the app.
#
ParametersName | Type | Description |
---|---|---|
appId? | string | Optional app ID. Appended to logs for easier debugging. |
swFilePath? | string | Optional path to the service worker file. Defaults to Enplug apps' 'enplug-offline-worker.js' |
#
ReturnsPromise
<string
>
Promise resolves when service worker registration was a success. It rejects when it was a failure.
#
setCanInterrupt▸ setCanInterrupt(canInterrupt
): Promise
<boolean
>
Informs the Player whether the app can be taken offscreen.
Sometimes your app will be displaying a video or some other content that should not be interrupted.
If you wish to stop the Player from replacing your app on screen,
use the canInterrupt property and setCanInterrupt
function.
The canInterrupt
property is returned as a Promise resolving to a boolean value.
The setCanInterrupt
function takes the new boolean value and returns a Promise resolving to the new value.
It is safe to assume that this value takes hold as soon as it is set.
Typically you will only set the value when needed.
myVideo.addEventListener('play', (playEvent) => { enplug.appStatus.setCanInterrupt(false);});myVideo.addEventListener('ended', (endEvent) => { enplug.appStatus.setCanInterrupt(true);});myVideo.play();
#
ParametersName | Type | Description |
---|---|---|
canInterrupt | boolean | true - the Player should be able to take the app offscreen,false - the app should not be taken offscreen. |
#
ReturnsPromise
<boolean
>
Resolves to the provided canInterrupt
state after Player confirms this change.
#
start▸ start(): Promise
<boolean
>
Informs the Player that the app is ready to be shown on screen.
When an app is first started by the Player it will not be shown on screen until it explicitly tells the Player that it is ready to be rendered.
Note that initially apps are loaded off screen so they can be given time to properly initialize. Your app can set up itself, preload resources and calculate layout, so there is not flickering or loading visible when the app gets shown on the screen.
When the app is ready to be shown, call the start
function to be entered into the current
rotation of active Player Applications.
enplug.appStatus.start();
note
Calling start
informs the Player that the app is ready to be displayed,
however it does not guarantee that it will be displayed immediately.
The returned Promise will resolve after the app gets shown on screen.
#
ReturnsPromise
<boolean
>
Resolves to true if the operation has completed successfully and the app is presented on screen.
#
toggleSound▸ toggleSound(enabled
): Promise
<void
>
Handles enplug.status.toggleSound()
calls.
#
ParametersName | Type |
---|---|
enabled | boolean |
#
ReturnsPromise
<void
>