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 code snippet in your Device Setup Package (see the example below).
- In BrightAuthor:connected, navigate to the player’s “Network” (under the top right dropdown). The player settings are accessible in the Properties panel of BrightAuthor:connected (under the Network tab).
- 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.
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).
ThebaseURLorplayer’sIPv4IPAddress(thedefaultportserverishostedon8000): 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
|