Player APIs (BrightScript & Ja...
JavaScript APIs
6min
the brightsign api for javascript allows you to interface with the brightsign player firmware to configure the player, retrieve system data, and interface with peripheral devices this api allows for operation of a digital signage platform–including playback, scheduling, diagnostics, and network configuration–using html/javascript, without the need for extensive coding in brightscript javascript apis replace previous “brightscript javascript objects” this api replaces the brightscript javascript objects docid\ urrxhu7l v9ea zhy0jv3 those older javascript objects are still offered for backwards compatibility purposes see the brightscript javascript migration guide docid 2kewwxlmpycwu8tffuf2z for the mapping between brightscript and javascript apis javascript objects are embedded into the browser runtime they only exist in the global javascript namespace, and can only be used with rohtmlwidget thus javascript api uses node modules it works seamlessly with docid\ xljq5 yhdma2ssmpzimtk and docid\ x9c4jhn6rnqgryfly1wdq it is a superset of legacy javascript objects brightsign has not added new features to the legacy brightscript javascript objects for several years, and all of our current development efforts go into javascript apis the legacy brightscript javascript objects exist to support customers who use them in deployed software, and to maintain that support during os upgrades unlike the legacy brightscript javascript objects, there is no one to one relationship between brightscript objects and objects in the new javascript api many brightscript functions (e g http server and file storage capabilities) are not exposed in the new api because javascript and node js® expose standardized, popular equivalents enabling the javascript api the brightsign api for javascript is implemented with the node js module, which is included with the chromium engine on the player to use the brightsign api with an rohtmlwidget instance, you must enable node js when creating the widget example r=createobject("rorectangle",0,0,1920,1080) aa=createobject("roassociativearray") aa url="http //test server/index html" aa nodejs enabled=true bb=createobject("roassociativearray") bb port=3000 aa inspector server=bb h=createobject("rohtmlwidget",r,aa) h show() in the above example, node js is enabled by including the nodejs enabled\ true entry in the associative array that is passed during creation of the rohtmlwidget instance loading brightsign modules the brightsign api does not exist in the global (window) namespace of the javascript runtime instead, like node js objects, brightsign modules are loaded using the require() function (i e require("@brightsign/\<module name>") ) brightsign modules are actually part of the firmware, but in terms of usage, they are identical to other node js modules example var networkconfigclass = require("@brightsign/networkconfiguration"); // call the class constructor for the networkconfiguration object var wifi = new networkconfigclass("ethernet"); // create an instance of the networkconfiguration class synchronous and asynchronous methods brightsign modules contain both synchronous and asynchronous methods synchronous methods return an object that can be used immediately, while asynchronous methods return a promise object, which will itself return the object data when the operation is resolved scripts must handle these delayed returns (typically using the then() and catch() methods available on the promise object) example var networkconfigclass = require("@brightsign/networkconfiguration"); var wifi = new networkconfigclass("wlan0"); wifi scan() then( // call the scan() method, which returns a promise 	 function(data){console log(json stringify(data));}) // the resolve/success case, which prints the scan results 	 catch( 	 function(data){console log(json stringify(data));}) // the reject/failure case, which prints the failure reason