Skip to main content

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.

Example usage of the AppStatus API
await enplug.appStatus.start();

Useful commands:



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



Promise resolving to true if the app had requested not to be interrupted and false otherwise.



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.

Informing the Player that there was an unresolvable error
enplug.appStatus.error('Could not preload resources');


errorMessage?stringError message to be passed to the logs.



Resolves to true if the operation has completed successfully.


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  }}



Reason why an app was rendered on-screen.


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.


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.

Informing the Player that the app should be hidden

If your app is the only app playing on the display it will not be hidden.



Resolves to true when the app has been hidden from the screen.


registerServiceWorker(appId?, swFilePath?): Promise<string>

Registers a service worker to enable offline support for the app.


appId?stringOptional app ID. Appended to logs for easier debugging.
swFilePath?stringOptional path to the service worker file. Defaults to Enplug apps' 'enplug-offline-worker.js'



Promise resolves when service worker registration was a success. It rejects when it was a failure.


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.

Connecting the setCanInterrupt call to video events
myVideo.addEventListener('play', (playEvent) => {  enplug.appStatus.setCanInterrupt(false);});myVideo.addEventListener('ended', (endEvent) => {  enplug.appStatus.setCanInterrupt(true);});;


canInterruptbooleantrue - the Player should be able to take the app offscreen,
false - the app should not be taken offscreen.



Resolves to the provided canInterrupt state after Player confirms this change.


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.

Informing the Player that the app is ready

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.



Resolves to true if the operation has completed successfully and the app is presented on screen.


toggleSound(enabled): Promise<void>

Handles enplug.status.toggleSound() calls.