Player APIs (BrightScript & Ja...

BrightScript-JavaScript Migration Guide

10min
this page describes the mapping between brightscript and javascript apis brightscript functionality is implemented in javascript using the javascript apis docid\ o2uiynvkbsyd1qxcvhvcn and the older brightscript javascript objects 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() math random() 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, cyclic object value https //developer mozilla org/en us/docs/web/javascript/reference/errors/cyclic object value or webreflection/flatted#flatted 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 javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators roassociativearray not applicable javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators roboolean not applicable javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators robytearray blob() (javascript now has typed arrays https //developer mozilla org/en us/docs/web/javascript/typed arrays for example, uint8array https //developer mozilla org/en us/docs/web/javascript/reference/global objects/uint8array ) rodouble not applicable javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators rofunction not applicable javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators roint, rofloat, rostring not applicable javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators rolist use javascript built in function javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators romessageport not applicable javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators roregex regexp() javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators roxmlelement domparser() javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators roxmllist domparser() javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators presentation objects brightscript api javascript equivalent library roaudioeventmx not available roaudiooutput audiooutput docid\ lxzj2b4solxtnxkxxkob5 roaudioplayer use html audio tag rocanvaswidget not applicable roclockwidget not applicable rohdmiinputchanged videoinput videoinputconfiguration hdmiinputchanged rohdmiinputchanged, rohdmioutputchanged docid\ xdorxw7wvzcnnu2 5upuy rohdmioutputchanged videooutput videooutputconfiguration hotplugevent rohdmiinputchanged, rohdmioutputchanged docid\ xdorxw7wvzcnnu2 5upuy rohtmlwidget htmlwidget 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() rotouchscreen docid\ wydfi oewp1uofqjvyhhu setmouserotation() not applicable enableserialtouchscreen() not available setserialtouchscreenconfiguration() not available getdiagnosticinfo() pointercalibration getdiagnosticinfohtml() rotouchscreen docid\ wydfi oewp1uofqjvyhhu startcalibration() pointercalibration startcalibration() rotouchscreen docid\ wydfi oewp1uofqjvyhhu getcalibrationstatus() pointercalibration getcalibrationstatus() rotouchscreen docid\ wydfi oewp1uofqjvyhhu clearstoredcalibration() pointercalibration clearstoredcalibration() rotouchscreen docid\ wydfi oewp1uofqjvyhhu starteventlogging() pointercalibration starteventlogging() rotouchscreen docid\ wydfi oewp1uofqjvyhhu stopeventlogging() pointercalibration stopeventlogging() rotouchscreen docid\ wydfi oewp1uofqjvyhhu cleareventlogs() not applicable (no information on the log) setcalibrationranges() pointercalibration setcalibrationranges() rotouchscreen docid\ wydfi oewp1uofqjvyhhu rovideoinput mediadevices getusermedia() web api rovideomode videomodeconfiguration docid\ uupzxkyflbsolyh8olces setmode() videomodeconfiguration setmode() rovideomode docid\ qq734nqz0hcwni0unsdmp setmodefornextboot() not applicable (use @brightsign/videomodeconfiguration setmode()) getmodefornextboot() not applicable (use @brightsign/videomodeconfiguration getactivemode()) getbestmode() videomodeconfiguration getbestmode() rovideomode docid\ qq734nqz0hcwni0unsdmp getmode() videomodeconfiguration getactivemode() rovideomode docid\ qq734nqz0hcwni0unsdmp getactivemode() videomodeconfiguration getactivemode() rovideomode docid\ qq734nqz0hcwni0unsdmp getavailablemodes() videomodeconfiguration getavailablemodes() rovideomode docid\ qq734nqz0hcwni0unsdmp getconfiguredmode() videomodeconfiguration getconfiguredmode() rovideomode docid\ qq734nqz0hcwni0unsdmp getfps videomodeconfiguration getactivemode() rovideomode docid\ qq734nqz0hcwni0unsdmp setdecodermode() decoderconfiguration applyconfig() rovideomode docid\ qq734nqz0hcwni0unsdmp getdecodermodes() decoderconfiguration getconfig() rovideomode docid\ qq734nqz0hcwni0unsdmp set3dmode() videooutput set3dmode() screenshot() screenshot synccapture()/asynccapture() rovideomode docid\ qq734nqz0hcwni0unsdmp getresx() videomodeconfiguration mode graphicsplanewidth rovideomode docid\ qq734nqz0hcwni0unsdmp getrexy() videomodeconfiguration mode graphicsplaneheight rovideomode docid\ qq734nqz0hcwni0unsdmp getvideoresx() videomodeconfiguration mode width rovideomode docid\ qq734nqz0hcwni0unsdmp getvideoresy() videomodeconfiguration mode height rovideomode docid\ qq734nqz0hcwni0unsdmp getoutputresx() videooutput size width rovideomode docid\ qq734nqz0hcwni0unsdmp getoutputresy() videooutput size height rovideomode 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() rovideomode docid\ qq734nqz0hcwni0unsdmp resumegraphics() compositor resume() rovideomode docid\ qq734nqz0hcwni0unsdmp setimagesizethreshold() system setimagesizethreshold() rovideomode docid\ qq734nqz0hcwni0unsdmp adjustgraphicscolor() videooutput adjustgraphiccolor() configurehdmiinput() videoinput applyconfig() rovideomode docid\ qq734nqz0hcwni0unsdmp sethdmimetadata() not available and possibly not applicable gethdmioutputstatus() videooutput getoutputstatus() rovideomode docid\ qq734nqz0hcwni0unsdmp gethdmiinputstatus() videoinput getstatus() rovideomode docid\ qq734nqz0hcwni0unsdmp getcompositorcrc() compositor getcrc() rovideomode docid\ qq734nqz0hcwni0unsdmp gettxhdcpstatus() videooutput gettxhdcpstatus() rovideomode docid\ qq734nqz0hcwni0unsdmp forcehdcpon() videooutput forcehdcpon() rovideomode docid\ qq734nqz0hcwni0unsdmp disablehdcprepeater() videooutput disablehdcprepeater() setbackgroundcolor() videooutput setbackgroundcolor() rovideomode docid\ qq734nqz0hcwni0unsdmp setpowersavemode() videooutput setpowersavemode() rovideomode docid\ qq734nqz0hcwni0unsdmp isattached() videooutput isattached() rovideomode docid\ qq734nqz0hcwni0unsdmp hdmiaudiodisable() videooutput disableaudio() rovideomode docid\ qq734nqz0hcwni0unsdmp setmultiscreenbezel() videooutput setmultiscreenbezel() rovideomode docid\ qq734nqz0hcwni0unsdmp saveedids() videooutput getedid() returns edid information as a hex encoded string getedididentity() videooutput getedididentity() rovideomode docid\ qq734nqz0hcwni0unsdmp setmpcdi() videooutput setmpcdi() setsyncdomain() videooutput setsyncdomain() rovideomode docid\ qq734nqz0hcwni0unsdmp rovideoplayer use \<video> elements with html video 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 registry docid\ txwoombd2 u12dfegx7ga getsectionlist() registry read() roregistry docid\ ytpsfntswyfmxx8pcqjlf delete() registry write() roregistry docid\ ytpsfntswyfmxx8pcqjlf flush() not applicable; registry writes are flushed implicitly roregistrysection registry docid\ txwoombd2 u12dfegx7ga read() registry read() roregistrysection docid\ ffm73tjd bthw4 p 0jvg write() registry write() roregistrysection 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 filesysteminfo docid\ qulnl7zrhwc5fgokcgai7 and storageinfo docid\ roz3o77euxtyzvj dspin getbytesperblock() filesysteminfo getstatistics() rostorageinfo docid\ bczooenmoifnrbeny6zki getsizeinmegabytes() filesysteminfo getstatistics() rostorageinfo docid\ bczooenmoifnrbeny6zki getusedinmegabytes() node js fs stat() getfreeinmegabytes() filesysteminfo getstatistics() rostorageinfo docid\ bczooenmoifnrbeny6zki getfilesystemtype() filesysteminfo getfilesystemtype() rostorageinfo docid\ bczooenmoifnrbeny6zki getstoragecardinfo() storageinfo getstoragecardinfo() rostorageinfo docid\ bczooenmoifnrbeny6zki rovirtualmemory not available content management objects brightscript api javascript equivalent library roassetcollection not available roassetfetcher assetfetcher docid\ hg03eush xkkpfofwdgcz roassetfetcher docid 1aqogvxana1wfjwf8thmd roassetpool assetpool docid\ ny8nhrk1 740wpryl p8d roassetpool docid\ dz9zc0ke6jlqnibunuq0n roassetpoolfiles assetpoolfiles docid\ nhocamfrj0avahj vearr roassetrealizer assetrealizer docid\ xnl0us14gwg7euiz2xsdm roassetrealizer 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 keystore docid 6alp0aixrzlhv4cbkebvz rokeystore docid\ ghsznw9es8temurqxq du romediaserver node media server romediastreamer not available romimestream not applicable ronetworkadvertisement not applicable (use node js) ronetworkconfiguration networkconfiguration docid 6ms7rdjwwhp21clmedrwv apply() networkconfiguration applyconfig() ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setupdws() dwsconfiguration ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs enableleds() networkconfiguration enableleds() ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setclientidentifier() networkconfiguration networkinterfaceconfig clientidentifier ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs getclientidentifier() networkconfiguration networkinterfaceconfig clientidentifier ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setloginpassword() hostconfiguration hostconfigwritable loginpassword ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setobfuscatedloginpassword() hostconfiguration hostconfigwritable obfuscatedloginpassword ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setinboundshaperrate() networkconfiguration networkinterfaceconfig inboundshaperrate ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setmtu() networkconfiguration networkinterfaceconfig mtu ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setroutingmetric() networkconfiguration networkinterfaceconfig metric ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setdhcp() networkconfiguration networkinterfaceconfig ipaddresslist ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setenabledprotocols() networkconfiguration networkinterfaceconfig enabledprotocollist ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setip4address() networkconfiguration networkinterfaceconfig ipaddresslist ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setip4netmask() networkconfiguration networkinterfaceconfig ipaddresslist ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setip4broadcast() networkconfiguration networkinterfaceconfig ipaddresslist ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setip4gateway() networkconfiguration networkinterfaceconfig ipaddresslist ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setvlanids() networkconfiguration networkinterfaceconfig vlanidlist ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setwifiessid()/ getwifiessid() networkconfiguration wifiinterfaceconfig essid ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setwifipassphrase() networkconfiguration wifiinterfaceconfig passphrase ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setwifipassphraseandobfuscate() networkconfiguration wifiinterfaceconfig obfuscatedpassphrase ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setwifiaccesspointmode() networkconfiguration wifiinterfaceconfig accesspointmode ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setaccesspointfrequencymhz() networkconfiguration wifiinterfaceconfig accesspointfrequency ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setwifiidentity() networkconfiguration wifiinterfaceconfig identity ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setwifieaptlsoptions() networkconfiguration wifiinterfaceconfig eaptlsoptions ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setwificacertificates() networkconfiguration wifiinterfaceconfig cacertificates ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setwificlientcertificate() networkconfiguration wifiinterfaceconfig clientcertificate ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setwifiprivatekey() networkconfiguration wifiinterfaceconfig privatekey ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setwifisecuritymode() networkconfiguration wifiinterfaceconfig securitymode ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs configuredhcpserver() networkconfiguration networkinterfaceconfig dhcpserverconfig ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setforwardingpolicy() not available setdnsservers()/ adddnsserver() networkconfiguration networkinterfaceconfig dnsserverlist ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs settimeserver() hostconfiguration hostconfig timeserverlist ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs settimeserverintervalseconds()/ gettimeserverintervalsecons() hostconfiguration hostconfig timeserverinterval ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs sethostname()/ gethostname() hostconfiguration hostconfig hostname ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setproxy()/ getproxy() hostconfiguration hostconfig proxy ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs setproxybypass()/ getproxybypass() hostconfiguration hostconfig proxybypasslist ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs getrecoveryurl() not available resetinterfacesettings() networkconfiguration applyconfig() ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs resethostsettings() hostconfiguration applyconfig() ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs getcurrentconfig() networkconfiguration getconfig()/hostconfiguration getconfig() ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs testinterface() networkdiagnostics testnetworkinterface() ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs testinternetconnectivity() networkdiagnostics testinternetconnectivity() ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs getneighborinformation() networkconfiguration getneighborinformation() ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs scanwifi() networkconfiguration scan() ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs ronetworkhotplug networkhotplug docid\ neizljqnwcice75ocwkol ronetworkattached networkhotplug docid\ neizljqnwcice75ocwkol ronetworkdetached networkhotplug docid\ neizljqnwcice75ocwkol ronetworkdiscovery not applicable (node js can be used instead) ronetworkstatistics not applicable (see node module net stat) roptp hostconfiguration 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 bssyncmanager 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 bsbtmanager docid\ cf7q7xsa9drtcq3btxv a bs javascript objects robtclientmanager/robtclient bsbtmanager docid\ cf7q7xsa9drtcq3btxv a rocecinterface bscectransmitter docid\ ma pnb9n4i6nin ixnr0r / bscecreceiver docid 1wzsjlvarrwoppr9c dye bs javascript objects rochannelmanager obsolete rocontrolport controlport docid\ n8yocsdagogqcp1oyuolw bs javascript objects rogpiocontrolport controlport docid\ n8yocsdagogqcp1oyuolw bs javascript objects roirreceiver bsirreceiver docid\ w5oqmftxhlg8lwiswtg7r bs javascript objects roirtransmitter bsirtransmitter docid\ og4yl3pefza5nkgkbgblv bs javascript objects roirremote bsirremote rokeyboard keyboard docid\ mnjv4rn7rm 2fslsjtqgc rokeyboard docid\ vnjf6gns75 lmizet3b1y rosequencemanager not applicable roserialport bsserialport docid\ zmqun8zm06aosrid6esfb bs javascript objects system objects brightscript api javascript equivalent library rodevicecustomization not available rodeviceinfo bsdeviceinfo docid\ s5s40p5kdirwx7eujzsba roresourcemanager not applicable rosystemlog not available date and time objects brightscript api javascript equivalent library rodatetime date javascript built in rosystemtime systemtime docid\ pwlrn rjihdhgwl2tbwc0 rosystemtime docid\ hwr0zojgtzxxnuhdlhlf9 rotimer settimeout()/ setinterval() web api rotimespan date javascript built in