The app using Player SDK has to be run inside of the Player's iframe to function properly as the SDK serves as a transport channel of the messages only. All commands are actually executed by the hosting Player. This means that running your app outside of the Player will not work. To run your app inside of the Player, you need to add it to the system. See Creating an App. After you create a new asset in the Dashboard part of the app and assign it to some Display Group, the app should start appearing in the Player.
Include the Player SDK script in your app, by adding the following code to the
<head> section of your app's HTML file:
This will create a global
window.enplug object providing various SDK methods for communicating with the hosting Player.
If you use TypeScript and would like to have the typings checked in your IDE you can load the following NPM package:
npm install @enplug/sdk-player --save-dev
"@enplug/sdk-player" to the
types array in your TypeScript config file. Make sure that
typeRoots array has the
"node_modules" entry, so that the whole path is available to the compiler.
After the Player SDK script gets loaded into your app, it will instantly create a global
window.enplug object which gives you the access to the methods provided by the Player.
enplug.appStatus to manage app's lifecycle.
enplug.appStatus.start()- app is ready
enplug.appStatus.error()- app has errored and cannot be displayed
enplug.appStatus.hide()- app should be hidden
enplug.appStatus.setCanInterrupt()- informs whether the app can be hidden
enplug.assets to fetch the value of the assets that is to be displayed or the selected theme.
enplug.assets.getNext()- fetch the value of the asset that is to be displayed
enplug.assets.getTheme()- get the currently selected theme
enplug.settings to fetch the settings of the device and the player.
enplug.settings.all- returns all device settings