Player APIs (BrightScript & Ja...
JavaScript APIs
ptp
7min
ptp allows you to retrieve information about the network ptp state of the player ptp idl interface ptpevent { attribute string type; }; callback ptpeventcallback = void (ptpevent event); interface ptp { promise\<ptpstatus> getstatus(); void addeventlistener(string type, ptpeventcallback callback); void removeeventlistener(string type, ptpeventcallback callback); }; interface ptpstatus { attribute long timestamp; attribute string state; }; object creation to create a ptp object, load the @brightsign/ptp module using the require() method var ptpclass = require('@brightsign/ptp'); var ptp = new ptpclass(); ptp getstatus() promise\<ptpstatus> getstatus() gets the status of a ptp network for a player ptpevent this event object is generated by the roptp object whenever the ptp status of the player changes type string string the name of the event ( which will always be ptpevent) ptpstatus timestamp long long the number of seconds since the ptp state was last changed this value can be compared against the total uptime of the player, which is retrieved by calling uptime(0) state string string indicates the current ptp state of the player values can be master, slave, or uncalibrated example // code placeholder var ptpclass = require('@brightsign/ptp'); var ptp = new ptpclass(); function main() { console log("starting ptp javascript api "); // ptp status test // two examples of result from getstatus() for master & slave player // {"state" "master","timestamp" 20} // {"state" "slave","timestamp" 24} var status = ptp getstatus(); status then( function(result) { console log(json stringify(result)); }) catch( function(err){ console log(json stringify(err)); }); // add event test if(ptp addeventlistener){ console log("adding test event"); ptp addeventlistener("ptpevent", eventhandler); } // remove event test // set 5 sec timeout for the purpose of testing removeeventlistener settimeout(function (){ console log("removing test event"); ptp removeeventlistener("ptpevent", eventhandler) }, 5000); } function eventhandler(event){ console log(json stringify(event)); } as of brightsignos 8 3 20, to get the current data set var ptpclass = require('@brightsign/ptp'); var ptp = new ptpclass(); var ds = ptp getcurrentdataset(); ds then( function(result) { console log(json stringify(result)); }) catch( function(err){ console log(json stringify(err)); } ); this will return a promise that, when successful, resolves to type type currentdataset { stepsremoved number; offsetfrommaster number; meanpathdelay number; }