Implementing the Settings Handler
To enable the Settings Handler from a custom Device Setup Package (not downloaded from BrightAuthor:connected):
- Include the autorun-setup.brs the code snippet in your Device Setup Package (see from the Example Script section, below), in your Device Setup Package.
- In BrightAuthor:connected, navigate to the player’s network (under the Network tab on the top right). In this section, the player settings are available in the Properties panel.
- Note: The script type would be "Setup" if the “setup script” comment in autorun-setup.brs is initialized as “setup” in order to support settings being applied from BrightAuthor:connected after the setup process is completed. The setup process is completed after the success splash screen is displayed on the player’s video HDMI output (if you are using the BrightAuthor:connected setup package, not a custom setup script).
To enable the Settings Handler from a custom presentation or custom application/plugin, include the either the autorun-custom.brs code snippet to your custom application/plugin/presentation or attach the plugin autorun-plugin-enableSettingsHandler.brs to the presentation
Once the device-side API is turned on, the player settings will be accessible in the Properties panel of BrightAuthor:connected (under the Network tab).
API Specification
This API specification is used by custom setup package scripts, custom presentation, or plugins, either invoked by BrightScript or JavaScript, to enable the “Settings Panel” (settings handler).
The base URL or player’s IPv4 IP address (the default port server is hosted on 8000) is http://localhost
GET /api/v1/system/supervisor/capabilities
Request Body
Code Block | ||
---|---|---|
| ||
{ "script": { “type”: “Custom” // Either “Custom” or “Setup”, “version”: “10.0.60” // Can be any version in a x.x.x format. Used to communicate script version to BSN.cloud, displayed in “Settings Panel” } } |
Response Body
Success: {"success":true}
Error: {"status”: <error status code>, “message”: <error message>}
Example Script
Partners who want to upgrade to use this feature must include the following code snippet in their BrightScript application/plugin.
Code Block | ||
---|---|---|
| ||
localBaseUrl = "http://localhost" supervisorApiV1Route = "/api/v1" supervisorCapabilitiesUrlXfer = CreateObject("roUrlTransfer") supervisorCapabilitiesUrlXfer$ = localBaseUrl + supervisorApiV1Route + "/system/supervisor/capabilities" supervisorCapabilitiesUrlXfer.SetUrl(supervisorCapabilitiesUrlXfer$) supervisorCapabilitiesUrlXfer.SetTimeout(15000) supervisorCapabilitiesUrlXfer.SetProxyBypass(["127.0.0.1", "localhost"]) supervisorCapabilitiesUrlXfer.addHeader("Content-type", "application/json") script = CreateObject("roAssociativeArray") scriptType$ = "Custom" ' script type would be "Setup" if it is setup script version$ = "10.0.60" ' current autorun script version script.AddReplace("type", scriptType$) script.AddReplace("version", version$) body = {} body.AddReplace("script", script) stringifiedJson = FormatJson(body) rc = supervisorCapabilitiesUrlXfer.PostFromString(stringifiedJson) if rc = 200 then print "===settings handler enabled" else print "===failed to start settings handler, error code:";rc end if |
Caveats
The settings handler can override custom settings applied by the setup script.
Edits to the property sheet settings in the interface will not be applied on the device side unless the code snippet in autorun-custom.brs above is added to the runtime application (not the setup application) or autorun-plugin-enableSettingsHandler.brs it is added as a plugin to the custom presentation (not the setup application).