Player APIs (BrightScript & Ja...
BrightScript-JavaScript Migration Guide
10 min
this page describes the mapping between brightscript and javascript apis brightscript functionality is implemented in javascript using the docid\ o2uiynvkbsyd1qxcvhvcn and the older docid\ urrxhu7l v9ea zhy0jv3 ; brightscript apis are not ported when standard javascript libraries provide equivalent functionality if the javascript equivalent is "not available", the functionality is not currently implemented but should be in the future if the equivalent is "not applicable", the corresponding brightscript method would be meaningless in javascript or is otherwise unnecessary global functions brightscript api javascript equivalent library createobject() not applicable restartscript() not applicable restartapplication() process exit() node js® sleep() not applicable asc() string charcodeat() javascript built in chr() string fromcharcode() javascript built in len() string length javascript built in str() number tostring() javascript built in strl() number tostring() javascript built in val() number() javascript built in abs() math abs() javascript built in atn() math atan() javascript built in csng() not applicable cdbl() not applicable cint() not applicable cos() math cos() javascript built in exp() math exp() javascript built in fix() number tofixed() javascript built in int() math trunc() javascript built in log() math log() javascript built in sgn() math sign() javascript built in sgnl() math sign() javascript built in sin() math sin() javascript built in tan() math tan() javascript built in sqr() math sqrt() javascript built in left(target string, n) target string substr(0, n) javascript built in right(target string, n) target string substr(target string length n) target string substr( n) javascript built in stringi() string repeat() javascript built in mid(target string, start position, length target string substr(start position, length) javascript built in instr() string indexof() javascript built in getinterface() access object interfaces as strings wait() not applicable in javascript, unless the function is used without reference to ports, and merely to delay execution for a time, in which case, use settimeout() javascript built in readasciifile() readfilesync() node js® writeasciifile() fs writefile() node js® listdir() fs readdir() node js® matchfiles() fs readdir() additional javascript code is needed to complete matching node js® lcase() string tolowercase() javascript built in ucase() string touppercase() javascript built in deletefile() fs unlink() node js® deletedirectory() fs rmdir() node js® createdirectory() fs mkdir() node js® rebootsystem() system reboot() brightsign javascript api shutdownsystem() not available uptime() os uptime() node js® formatdrive() no exact equivalent ejectdrive() not available copyfile() fs copyfile() node js® movefile() fs rename() node js® mapfilenametonative() not applicable strtoi() parseint() strtoi() parses in base 10, whereas javascript supports any base javascript built in rnd() https //developer mozilla org/en us/docs/web/javascript/reference/global objects/math/random javascript built in rungarbagecollector() not applicable getdefaultdrive() not applicable node js® setdefaultdrive() process chdir() node js® enablezonesupport() not applicable enableaudiomixer() not applicable pi() math pi javascript built in parsejson() json parse() brightscript returns invalid in the case of problematic strings, whereas javascript throws an exception javascript built in formatjson() json stringify() json stringify must be invoked with a custom replacer, for example, https //developer mozilla org/en us/docs/web/javascript/reference/errors/cyclic object value or https //github com/webreflection/flatted#flatted javascript built in substr takes parameters as (from, length) substring takes parameters as (from, to) slice takes parameters as (from, to) async operations are always preferable core objects brightscript api javascript equivalent library roarray not applicable https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators roassociativearray not applicable https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators roboolean not applicable https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators robytearray blob() (javascript now has https //developer mozilla org/en us/docs/web/javascript/typed arrays for example, https //developer mozilla org/en us/docs/web/javascript/reference/global objects/uint8array ) rodouble not applicable https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators rofunction not applicable https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators roint, rofloat, rostring not applicable https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators rolist use javascript built in function https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators romessageport not applicable https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators roregex regexp() https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators roxmlelement domparser() https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators roxmllist domparser() https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators presentation objects brightscript api javascript equivalent library roaudioeventmx not available roaudiooutput docid\ lxzj2b4solxtnxkxxkob5 roaudioplayer use html audio tag rocanvaswidget not applicable roclockwidget not applicable rohdmiinputchanged videoinput videoinputconfiguration hdmiinputchanged docid\ xdorxw7wvzcnnu2 5upuy rohdmioutputchanged videooutput videooutputconfiguration hotplugevent docid\ xdorxw7wvzcnnu2 5upuy rohtmlwidget docid\ pmpuh3a0vr8ohjopsjwo7 roimagebuffer not applicable roimageplayer \<img> tag in html https //developer mozilla org/en us/docs/web/html/element/img roimagewidget \<img> tag in html https //developer mozilla org/en us/docs/web/html/element/img rorectangle not applicable rostreamqueue not available rotextfield not applicable rotextwidget not applicable rotouchevent touchevent() web api rotouchscreen not available setresolution() browser performs mapping addrectangle() map css cursor properties to hardware cursor addcircleregion() map css cursor properties to hardware cursor clearregions() not applicable getdevicename() not applicable setcursorposition() simulate mouse cursor events in javascript setcursorbitmap() map css cursor properties to hardware cursor enablecursor() map css cursor properties to hardware cursor enablerollover() not applicable enableregion() map css cursor properties to hardware cursor setrolloverorigin() map css cursor properties to hardware cursor ismousepresent() pointer ismousepresent() docid\ wydfi oewp1uofqjvyhhu setmouserotation() not applicable enableserialtouchscreen() not available setserialtouchscreenconfiguration() not available getdiagnosticinfo() pointercalibration getdiagnosticinfohtml() docid\ wydfi oewp1uofqjvyhhu startcalibration() pointercalibration startcalibration() docid\ wydfi oewp1uofqjvyhhu getcalibrationstatus() pointercalibration getcalibrationstatus() docid\ wydfi oewp1uofqjvyhhu clearstoredcalibration() pointercalibration clearstoredcalibration() docid\ wydfi oewp1uofqjvyhhu starteventlogging() pointercalibration starteventlogging() docid\ wydfi oewp1uofqjvyhhu stopeventlogging() pointercalibration stopeventlogging() docid\ wydfi oewp1uofqjvyhhu cleareventlogs() not applicable (no information on the log) setcalibrationranges() pointercalibration setcalibrationranges() docid\ wydfi oewp1uofqjvyhhu rovideoinput mediadevices getusermedia() web api rovideomode docid\ uupzxkyflbsolyh8olces setmode() videomodeconfiguration setmode() docid\ qq734nqz0hcwni0unsdmp setmodefornextboot() not applicable (use @brightsign/videomodeconfiguration setmode()) getmodefornextboot() not applicable (use @brightsign/videomodeconfiguration getactivemode()) getbestmode() videomodeconfiguration getbestmode() docid\ qq734nqz0hcwni0unsdmp getmode() videomodeconfiguration getactivemode() docid\ qq734nqz0hcwni0unsdmp getactivemode() videomodeconfiguration getactivemode() docid\ qq734nqz0hcwni0unsdmp getavailablemodes() videomodeconfiguration getavailablemodes() docid\ qq734nqz0hcwni0unsdmp getconfiguredmode() videomodeconfiguration getconfiguredmode() docid\ qq734nqz0hcwni0unsdmp getfps videomodeconfiguration getactivemode() docid\ qq734nqz0hcwni0unsdmp setdecodermode() decoderconfiguration applyconfig() docid\ qq734nqz0hcwni0unsdmp getdecodermodes() decoderconfiguration getconfig() docid\ qq734nqz0hcwni0unsdmp set3dmode() videooutput set3dmode() screenshot() screenshot synccapture()/asynccapture() docid\ qq734nqz0hcwni0unsdmp getresx() videomodeconfiguration mode graphicsplanewidth docid\ qq734nqz0hcwni0unsdmp getrexy() videomodeconfiguration mode graphicsplaneheight docid\ qq734nqz0hcwni0unsdmp getvideoresx() videomodeconfiguration mode width docid\ qq734nqz0hcwni0unsdmp getvideoresy() videomodeconfiguration mode height docid\ qq734nqz0hcwni0unsdmp getoutputresx() videooutput size width docid\ qq734nqz0hcwni0unsdmp getoutputresy() videooutput size height docid\ qq734nqz0hcwni0unsdmp getsafex() bsvideomode safex bs javascript objects getsafey() bsvideomode safey bs javascript objects safewidth() bsvideomode safewidth bs javascript objects safeheight() bsvideomode safeheight bs javascript objects setgraphicszorder not applicable pausegraphics() compositor pause() docid\ qq734nqz0hcwni0unsdmp resumegraphics() compositor resume() docid\ qq734nqz0hcwni0unsdmp setimagesizethreshold() system setimagesizethreshold() docid\ qq734nqz0hcwni0unsdmp adjustgraphicscolor() videooutput adjustgraphiccolor() configurehdmiinput() videoinput applyconfig() docid\ qq734nqz0hcwni0unsdmp sethdmimetadata() not available and possibly not applicable gethdmioutputstatus() videooutput getoutputstatus() docid\ qq734nqz0hcwni0unsdmp gethdmiinputstatus() videoinput getstatus() docid\ qq734nqz0hcwni0unsdmp getcompositorcrc() compositor getcrc() docid\ qq734nqz0hcwni0unsdmp gettxhdcpstatus() videooutput gettxhdcpstatus() docid\ qq734nqz0hcwni0unsdmp forcehdcpon() videooutput forcehdcpon() docid\ qq734nqz0hcwni0unsdmp disablehdcprepeater() videooutput disablehdcprepeater() setbackgroundcolor() videooutput setbackgroundcolor() docid\ qq734nqz0hcwni0unsdmp setpowersavemode() videooutput setpowersavemode() docid\ qq734nqz0hcwni0unsdmp isattached() videooutput isattached() docid\ qq734nqz0hcwni0unsdmp hdmiaudiodisable() videooutput disableaudio() docid\ qq734nqz0hcwni0unsdmp setmultiscreenbezel() videooutput setmultiscreenbezel() docid\ qq734nqz0hcwni0unsdmp saveedids() videooutput getedid() returns edid information as a hex encoded string getedididentity() videooutput getedididentity() docid\ qq734nqz0hcwni0unsdmp setmpcdi() videooutput setmpcdi() setsyncdomain() videooutput setsyncdomain() docid\ qq734nqz0hcwni0unsdmp rovideoplayer use \<video> elements with docid\ e6ujleh69q0jmmv8kytrp file objects use the node js file api hashing and storage objects brightscript api javascript equivalent library roblockcipher node js crypto api robrightpackage node js zlib api rodiskerrorevent not available rodiskmonitor not available rohashgenerator node js crypto api ropasskey node js crypto api roregistry docid\ txwoombd2 u12dfegx7ga getsectionlist() registry read() docid\ ytpsfntswyfmxx8pcqjlf delete() registry write() docid\ ytpsfntswyfmxx8pcqjlf flush() not applicable; registry writes are flushed implicitly roregistrysection docid\ txwoombd2 u12dfegx7ga read() registry read() docid\ ffm73tjd bthw4 p 0jvg write() registry write() docid\ ffm73tjd bthw4 p 0jvg exists() not applicable (use read followed by a truthy check on the registry key) getkeylist() not applicable (use read followed by object keys()) rosqlitedatabase use indexeddb rosqlitestatement use indexeddb rostorageattached node js fs watch() rostoragedetached node js fs watch() rostoragehotplug node js fs watch() rostorageinfo docid\ qulnl7zrhwc5fgokcgai7 and docid\ roz3o77euxtyzvj dspin getbytesperblock() filesysteminfo getstatistics() docid\ bczooenmoifnrbeny6zki getsizeinmegabytes() filesysteminfo getstatistics() docid\ bczooenmoifnrbeny6zki getusedinmegabytes() node js fs stat() getfreeinmegabytes() filesysteminfo getstatistics() docid\ bczooenmoifnrbeny6zki getfilesystemtype() filesysteminfo getfilesystemtype() docid\ bczooenmoifnrbeny6zki getstoragecardinfo() storageinfo getstoragecardinfo() docid\ bczooenmoifnrbeny6zki rovirtualmemory not available content management objects brightscript api javascript equivalent library roassetcollection not available roassetfetcher docid\ hg03eush xkkpfofwdgcz docid 1aqogvxana1wfjwf8thmd roassetpool docid\ ny8nhrk1 740wpryl p8d docid\ dz9zc0ke6jlqnibunuq0n roassetpoolfiles docid\ nhocamfrj0avahj vearr roassetrealizer docid\ xnl0us14gwg7euiz2xsdm docid\ yov qcutlenarbm fzmfv rosyncspec not applicable networking objects brightscript api javascript equivalent library rodatagramreceiver node js dgram api rodatagramsender node js dgram api rodatagramsocket node js dgram api rohttpserver node js rokeystore docid 6alp0aixrzlhv4cbkebvz docid\ ghsznw9es8temurqxq du romediaserver node media server romediastreamer not available romimestream not applicable ronetworkadvertisement not applicable (use node js) ronetworkconfiguration docid 6ms7rdjwwhp21clmedrwv apply() networkconfiguration applyconfig() docid\ u6zceyqddlz9xdakttmjs setupdws() dwsconfiguration docid\ u6zceyqddlz9xdakttmjs enableleds() networkconfiguration enableleds() docid\ u6zceyqddlz9xdakttmjs setclientidentifier() networkconfiguration networkinterfaceconfig clientidentifier docid\ u6zceyqddlz9xdakttmjs getclientidentifier() networkconfiguration networkinterfaceconfig clientidentifier docid\ u6zceyqddlz9xdakttmjs setloginpassword() hostconfiguration hostconfigwritable loginpassword docid\ u6zceyqddlz9xdakttmjs setobfuscatedloginpassword() hostconfiguration hostconfigwritable obfuscatedloginpassword docid\ u6zceyqddlz9xdakttmjs setinboundshaperrate() networkconfiguration networkinterfaceconfig inboundshaperrate docid\ u6zceyqddlz9xdakttmjs setmtu() networkconfiguration networkinterfaceconfig mtu docid\ u6zceyqddlz9xdakttmjs setroutingmetric() networkconfiguration networkinterfaceconfig metric docid\ u6zceyqddlz9xdakttmjs setdhcp() networkconfiguration networkinterfaceconfig ipaddresslist docid\ u6zceyqddlz9xdakttmjs setenabledprotocols() networkconfiguration networkinterfaceconfig enabledprotocollist docid\ u6zceyqddlz9xdakttmjs setip4address() networkconfiguration networkinterfaceconfig ipaddresslist docid\ u6zceyqddlz9xdakttmjs setip4netmask() networkconfiguration networkinterfaceconfig ipaddresslist docid\ u6zceyqddlz9xdakttmjs setip4broadcast() networkconfiguration networkinterfaceconfig ipaddresslist docid\ u6zceyqddlz9xdakttmjs setip4gateway() networkconfiguration networkinterfaceconfig ipaddresslist docid\ u6zceyqddlz9xdakttmjs setvlanids() networkconfiguration networkinterfaceconfig vlanidlist docid\ u6zceyqddlz9xdakttmjs setwifiessid()/ getwifiessid() networkconfiguration wifiinterfaceconfig essid docid\ u6zceyqddlz9xdakttmjs setwifipassphrase() networkconfiguration wifiinterfaceconfig passphrase docid\ u6zceyqddlz9xdakttmjs setwifipassphraseandobfuscate() networkconfiguration wifiinterfaceconfig obfuscatedpassphrase docid\ u6zceyqddlz9xdakttmjs setwifiaccesspointmode() networkconfiguration wifiinterfaceconfig accesspointmode docid\ u6zceyqddlz9xdakttmjs setaccesspointfrequencymhz() networkconfiguration wifiinterfaceconfig accesspointfrequency docid\ u6zceyqddlz9xdakttmjs setwifiidentity() networkconfiguration wifiinterfaceconfig identity docid\ u6zceyqddlz9xdakttmjs setwifieaptlsoptions() networkconfiguration wifiinterfaceconfig eaptlsoptions docid\ u6zceyqddlz9xdakttmjs setwificacertificates() networkconfiguration wifiinterfaceconfig cacertificates docid\ u6zceyqddlz9xdakttmjs setwificlientcertificate() networkconfiguration wifiinterfaceconfig clientcertificate docid\ u6zceyqddlz9xdakttmjs setwifiprivatekey() networkconfiguration wifiinterfaceconfig privatekey docid\ u6zceyqddlz9xdakttmjs setwifisecuritymode() networkconfiguration wifiinterfaceconfig securitymode docid\ u6zceyqddlz9xdakttmjs configuredhcpserver() networkconfiguration networkinterfaceconfig dhcpserverconfig docid\ u6zceyqddlz9xdakttmjs setforwardingpolicy() not available setdnsservers()/ adddnsserver() networkconfiguration networkinterfaceconfig dnsserverlist docid\ u6zceyqddlz9xdakttmjs settimeserver() hostconfiguration hostconfig timeserverlist docid\ u6zceyqddlz9xdakttmjs settimeserverintervalseconds()/ gettimeserverintervalsecons() hostconfiguration hostconfig timeserverinterval docid\ u6zceyqddlz9xdakttmjs sethostname()/ gethostname() hostconfiguration hostconfig hostname docid\ u6zceyqddlz9xdakttmjs setproxy()/ getproxy() hostconfiguration hostconfig proxy docid\ u6zceyqddlz9xdakttmjs setproxybypass()/ getproxybypass() hostconfiguration hostconfig proxybypasslist docid\ u6zceyqddlz9xdakttmjs getrecoveryurl() not available resetinterfacesettings() networkconfiguration applyconfig() docid\ u6zceyqddlz9xdakttmjs resethostsettings() hostconfiguration applyconfig() docid\ u6zceyqddlz9xdakttmjs getcurrentconfig() networkconfiguration getconfig()/hostconfiguration getconfig() docid\ u6zceyqddlz9xdakttmjs testinterface() networkdiagnostics testnetworkinterface() docid\ u6zceyqddlz9xdakttmjs testinternetconnectivity() networkdiagnostics testinternetconnectivity() docid\ u6zceyqddlz9xdakttmjs getneighborinformation() networkconfiguration getneighborinformation() docid\ u6zceyqddlz9xdakttmjs scanwifi() networkconfiguration scan() docid\ u6zceyqddlz9xdakttmjs ronetworkhotplug docid\ neizljqnwcice75ocwkol ronetworkattached docid\ neizljqnwcice75ocwkol ronetworkdetached docid\ neizljqnwcice75ocwkol ronetworkdiscovery not applicable (node js can be used instead) ronetworkstatistics not applicable (see node module net stat) roptp docid\ p1dkloqhlm9wxsswmpeek (see os 8 0 94 release note) rorssarticle/rorssparser not applicable rortspstream use \<video> elements rosnmpagent net snmp npm rostream not applicable rosyncmanager docid\ dqnx2ot2tdkxynmrglncp bs javascript objects rotcpserver/rotcpstream net socket node js® roupnp not applicable rourltransfer http node js® npm is a registered trademark of npm, inc input/output objects brightscript api javascript equivalent library robtmanager docid\ cf7q7xsa9drtcq3btxv a bs javascript objects robtclientmanager/robtclient docid\ cf7q7xsa9drtcq3btxv a rocecinterface docid\ ma pnb9n4i6nin ixnr0r / docid 1wzsjlvarrwoppr9c dye bs javascript objects rochannelmanager obsolete rocontrolport docid\ n8yocsdagogqcp1oyuolw bs javascript objects rogpiocontrolport docid\ n8yocsdagogqcp1oyuolw bs javascript objects roirreceiver docid\ w5oqmftxhlg8lwiswtg7r bs javascript objects roirtransmitter docid\ og4yl3pefza5nkgkbgblv bs javascript objects roirremote bsirremote rokeyboard docid\ mnjv4rn7rm 2fslsjtqgc docid\ vnjf6gns75 lmizet3b1y rosequencemanager not applicable roserialport docid\ zmqun8zm06aosrid6esfb bs javascript objects system objects brightscript api javascript equivalent library rodevicecustomization not available rodeviceinfo docid\ s5s40p5kdirwx7eujzsba roresourcemanager not applicable rosystemlog not available date and time objects brightscript api javascript equivalent library rodatetime date javascript built in rosystemtime docid\ pwlrn rjihdhgwl2tbwc0 docid\ hwr0zojgtzxxnuhdlhlf9 rotimer settimeout()/ setinterval() web api rotimespan date javascript built in