Player APIs (BrightScript & Ja...
...
Object Reference
Presentation and Widget Object...

roHtmlWidget

47min
this object embeds the chromium html rendering engine, which can be rendered at full screen or as a widget you can display multiple rohtmlwidget instances at the same time the javascript equivalent is htmlwidget docid\ pmpuh3a0vr8ohjopsjwo7 tip use the docid\ ghsznw9es8temurqxq du object to provide client certificates for websites use the docid\ m2dqxiy5mgoraosa8mvni object to set up a virtual memory repository for chromium object creation the rohtmlwidget object is initialized with an rorectangle object, which specifies the size and positioning of the widget on the screen, and an optional associative array, which defines properties for the widget createobject("rohtmlwidget", rect as rorectangle, properties as roassociativearray) the properties of an rohtmlwidget instance can be set with an associative array at initialization or with equivalent methods after initialization because many rohtmlwidget properties cannot be changed without reloading the page (and can produce unpredictable results if changed while the page is running), we recommend setting properties at initialization when possible, rather than using the equivalent methods defining initialization properties for an rohtmlwidget instance disables some methods for that instance (e g settransform() , addfont() , setuserstylesheet() ) see the “available methods with initialization” section below for a list of available methods initialization parameters the associative array passed during initialization can have the following parameters nodejs enabled bool bool enables node js docid\ vlskfvzequ04pd58rvxam ® on the widget this value is false by default reloading a page which has node js enabled can be classified as an undefined behavior the recommended method for restarting a node instance is to destroy and rebuild the rohtmlwidget focus enabled bool bool enables focus for mouse/touchscreen events this value is true by default mouse enabled bool bool enables mouse/touchscreen/usb keyboard events this value is false by default scrollbar enabled bool bool enables automatic scrollbars for content that does not fit into the viewport this value is false by default the browser defaults to desktop style scrollbars, but they can be displaying html without brightauthor docid\ qa8gmaiahgvg5gc6kdhf2 as well pinch to zoom enabled bool bool enables pinch to zoom functionality this value is false by default force gpu rasterization enabled bool bool enables gpu rasterization for html graphics by default, the decision to use gpu rasterization is based on internal chromium logic https //www chromium org/developers/design documents/chromium graphics/how to get gpu rasterization this setting has been deprecated as of os8, gpu rasterization is enabled by default and setting this property has no effect canvas 2d acceleration enabled bool bool enables 2d canvas acceleration this will improve the framerate of most html pages that use 2d animations, but can cause out of memory issues with pages that use a large number of off screen canvas surfaces this setting has been deprecated as of os8, canvas acceleration is enabled by default and can be disabled by setting this flag to false javascript enabled bool bool enables javascript on the widget this value is true by default brightsign js objects enabled bool bool enables brightscript javascript objects docid\ urrxhu7l v9ea zhy0jv3 this value is false by default in os 8 2 55 4 and later, html widgets that are loaded from http/https protocols do not share the same local storage database (html widgets that are loaded via file protocol act as they did in previous releases) these flags allow you to change the default behavior of widgets loaded through http/https from "unshared" to "shared", or to change the default behavior of widgets with locally loaded files to "unshared" from "shared" force shared storage bool bool allows html widgets loaded via http/https protocol to share local storage if they are loaded from the same domain force unshared storage bool bool prevents html widgets loaded via file protocol from sharing storage transform string string sets the screen orientation of content in the widget (note that the coordinates and dimensions of the rorectangle containing the widget are not affected by rotation) the following values are accepted "identity" there is no transform (i e the widget content is oriented as landscape) this is the default setting "rot90" the widget content is rotated to portrait at 90 degrees (clockwise) "rot180" the widget content is rotated to portrait at 180 degrees (clockwise) "rot270" the widget content is rotated to portrait at 270 degrees (clockwise) user agent string string modifies the default user agent string for the rohtmlwidget instance url string string the url to use for display see the rohtmlwidget docid\ xljq5 yhdma2ssmpzimtk entry below for more information on using uris to access files from local storage language string string specifies the language to load the web page in user stylesheet string string applies the specified user stylesheet to pages in the widget the parameter is a rohtmlwidget docid\ xljq5 yhdma2ssmpzimtk specifying any file resource in the storage, unless you are using a css stylesheet saved to the sd card, in which case you should use sd /path/filename css the stylesheet can also be specified as inline data hwz default string string specifies the default html video docid\ e6ujleh69q0jmmv8kytrp behavior this value is off by default to enable it, set it to on storage path string string creates a "local storage" subfolder in the specified directory this folder is used by local storage applications such as the javascript storage class storage quota string string or double double sets the total size (in bytes) allotted to all local storage applications (including indexeddb) a brightscript integer is only guaranteed to be able to represent a count of bytes up to 2gb so avoid using integers when calculating the size use float or double instead since they can represent values over 2gb (string can also be used but is not recommended) if the storage path is specified without a storage quota, chromium defaults to reserving 1gb plus 10% of the total size of the storage device port romessageport romessageport configures the message port to which the rohtmlwidget instance will send events when using initialization parameters, the port parameter should be used instead of the setport() method to ensure the script can catch load started , load finished , and load error events fonts roarray roarray specifies a list of font files that can be accessed by the webpage font files are specified as an array of string filenames supported font types include truetype font files ( ttf ) and web open font files ( woff , woff2 ) pcm audio outputs roarray roarray configures the pcm audio output for the html widget outputs are specified as an array of strings, each string being the name of an output (see documentation docid\ olycd6ije fnaxdzjhdkr for a list of acceptable names ) compressed audio outputs roarray roarray configures compressed audio output (e g dolby ac3 encoded audio) for the html widget outputs are specified as an array of roaudiooutput instances multi channel audio outputs roarray roarray configures multi channel audio output for the html widget outputs are specified as an array of roaudiooutput instances inspector server roassociativearray roassociativearray configures the debugging webpages docid 4qlk1krr1cnx7xypwxry5 for the widget starting in brightsign os 8 5 31 you will need to also set the enable web inspector registry key (in the "html" section) to enable the javascript console in “enable web inspector”, "1" will allow the inspector and "0" or not present will disable it a reboot will be needed for these changes to take effect (if you enable/disable this through the ldws ui it may trigger a reboot to apply the changes) ip addr string string the inspector ip address this value is useful if the player is assigned more than one ip address (i e there are multiple network interfaces) and you wish to limit the inspector server to one the default value is "0 0 0 0" , which allows the inspector to accept connections using either ip address port int int the port for the inspector server for security reasons, enable web inspector should only be used in non production presentations make sure to disable javascript console before publishing to a production environment in the chromium version found in bos 8 5 31 and beyond, the javascript console will log information in memory even when you are not connected to the inspector this will consume memory until the player runs out, which will result in a crash security params roassociativearray roassociativearray enables or disables chromium security checks for cross origin requests, local video playback from http, etc websecurity bool bool enables chromium security checks for cross origin requests camera enabled bool bool enables webpage access to usb cameras connected to the player (access is disabled by default) this allows support for webrtc applications insecure https enabled bool bool instructs the widget to ignore security errors when connecting to insecure https hosts (insecure https is disabled by default) enabling this feature makes the player insecure; it is not suitable for production environments and should only be used for testing ] audio capture enabled bool bool gives access to audio input devices and lets chromium enumerate all audio input and output devices with bos 8 2 and later (chromium69 and later), several new cors checks have been added security params websecurity or enablesecurity(false) do not disable all these checks use the following registry setting instead registry write html disable web security 1 to write this to the registry using roregistrysection docid\ ffm73tjd bthw4 p 0jvg reghtml = createobject("roregistrysection", "html") reghtml write("disable web security", "1") reghtml flush() this flag will take effect on all rohtmlwidget instances, as opposed to previous flags which are only effective on the instance they are called on the camera enabled parameter is currently supported on the xtx44/43, xdx34/33, hdx24/23, ls424/ls423, and 4kx42 models javascript injection roassociativearray roassociativearray specifies javascript code to inject at different initialization points (javascript code can also be injected during runtime using the injectjavascript() method) the associative array can contain three parameters (described below) each parameter value is an array of associative arrays, each containing a single key/value pair the array must contain a source key the source value is a string that can contain any of the following pure javascript code, a path to a javascript file, or a base64 encoded string (i e beginning with data\ text/javascript;charset=utf 8;base64, ) mutliple source keys can be included, but the load order will be unpredictable the array can also contain the optional world key, which can be assigned one of the following values "application" , "user" , or "main" (see this page http //doc qt io/archives/qt 5 6/qwebenginescript html#scriptworldid enum for more details); if the world parameter is not included in the array, "application" is selected by default document creation the script will run as soon as the document is created this behavior is not suitable for any dom operation document ready the script will run as soon as the dom is ready this behavior is equivalent to the domcontentloaded event firing in javascript deferred the script will run when the page load finishes config = { javascript injection { document creation \[{source "0 js" }], document ready \[{source "1a js" }, {source "1b js" }], deferred \[{source "2 js" }] }, url " " } assets roarray roarray allows the rohtmlwidget instance to rohtmlwidget docid\ xljq5 yhdma2ssmpzimtk if a file exists in multiple specified asset pools, the asset pool with the lowest index in the array has precedence each array entry is an associative array containing information about an asset pool pool roassetpool roassetpool an asset pool containing files collection roassetcollection roassetcollection a manifest identifying the files in the pool uri prefix string string the uri prefix of the webpage resources to retrieve from the pool pool prefix string string the pool prefix that will replace the uri prefix when looking up the resource in the pool ifhtmlwidget getfailurereason() as string gives more information when a member function returns false hide() as boolean hides the widget show() as boolean shows the widget raise() raises the html widget above all other graphical elements on screen (including other html widgets) lower() lowers the html widget below all graphical elements on screen setrectangle(r as rorectangle) as boolean changes the size and positioning of the widget rectangle using the passed rorectangle object seturl(url as string) as boolean displays content from the specified url when using this method to retrieve content from local storage, specify the file location as follows "file /\<drive> /\<directory>/\<filename>" for example, an index html file in the "content" folder on the sd card can be selected with the string "file /sd /content/index html" you can also omit the drive specification to select the currently active drive (i e whichever drive the current autorun as loaded from) addauthenticationcredentials (url as string, username as string, password as string) as boolean tells chromium to use the specified username and password when retrieving the given url mapfilesfromassetpool(asset pool as roassetpool, asset collection as roassetcollection, pool prefix as string, uri prefix as string) as boolean sets the mapping between the url space and the pool files html content that has been deployed via brightauthor will typically reside in the pool and have encrypted sha1 based filenames a mapping mechanism is required to allow any relative uris contained in the html content to continue working and to locate the appropriate resources in their respective pool locations you can use this method to bind part of the resource uri space onto pool locations this method accepts the following arguments an roassetpool object containing assets, an roassetcollection object identifying the assets, and two semi arbitrary strings (uri prefix and pool prefix) any uri in the form "file /\[uri prefix]\[resource id]" will be rewritten into the form "\[pool prefix]\[resource id]" it will then be located in the pool as if that name had been passed to the roassetpoolfiles getpoolfilepath() method this binding occurs for every instance of rohtmlwidget , so different mappings can be used for different bundles of content setzoomlevel(scale factor as float) as boolean adjusts the scale factor for the displayed page (the default equals 1 0) enablepinchtozoom(enable as boolean) as boolean enables or disables pinch to zoom functionality, which is disabled by default enablesecurity(enable as dynamic) as boolean deprecated use security params in initialization parameters instead enablemouseevents(enable as boolean) as boolean deprecated use mouse enabled in initialization parameters instead setportrait(portrait mode as boolean) as boolean deprecated use transform in initialization parameters instead settransform(transform as string) as boolean sets the screen orientation of content in the widget (note that the coordinates and dimensions of the rorectangle containing the widget are not affected by rotation) this method accepts the following strings "identity" there is no transform (i e the widget content is oriented as landscape) this is the default setting "rot90" the widget content is rotated to portrait at 90 degrees (clockwise) "rot270" the widget content is rotated to portrait at 270 degrees (counter clockwise) the javascript onload event will report landscape dimensions for a window that is rotated with the setportrait() or settransform() method if your application relies on the onload event to retrieve window dimensions, we recommend instead using the rohtmlwidget transform initialization parameter, which ensures the html window is initialized with portrait dimensions setalpha(alpha as integer) as boolean sets the overall alpha level for the widget (the default equals 255) enablescrollbars(scrollbars as boolean) as boolean deprecated use scrollbar enabled in initialization parameters instead addfont(filename as string) as boolean deprecated use fonts in initialization parameters instead setpcmaudiooutputs(outputs as roarray) as boolean deprecated use pcm audio outputs in initialization parameters instead setcompressedaudiooutputs(outputs as roarray) as boolean deprecated use compressed audio outputs in initialization parameters instead setmultichannelaudiooutputs(outputs as roarray) as boolean deprecated use multi channel audio outputs in initialization parameters instead sethwzdefault(default as string) as void deprecated use hwz default in initialization parameters instead setvideoplayerdefaults(defaults as roassociativearray) as boolean sets default playback settings for \<video> elements in the widget available parameters are identical to the rovideoplayer docid\ ztuz0ldazcml2kqmdbkcn method default settings will be overwritten by parameters specified in individual \<video> elements forcegpurasterization(enable as boolean) as boolean deprecated as of os8, gpu rasterization is enabled by default and calling this method has no effect enablecanvas2dacceleration(enable as boolean) as boolean deprecated use rohtmlwidget docid\ xljq5 yhdma2ssmpzimtk in initialization parameters instead setuserstylesheet(uri as string) as boolean deprecated use user stylesheet in initialization parameters instead flushcachedresources() as boolean discards any resources that chromium has cached in memory changing the storage path after an url is loaded can cause the storage database to be irretrievably lost and/or damaged users should avoid using setlocalstoragedir, setwebdatabasedir and setappcachedir apis when writing brightscript applications since the bos 6 0 release, brightsign uses a single storage path for webdatabase, localstorage and appcache this should be set by the storage path parameter in rohtmlwidget static initialization parameters with the bos 8 2 35 4 release, if setlocalstoragedir, setwebdatabasedir, or setappcachedir are called, rohtmlwidget will use the path as the first one that is set this directory will only set once and will be used for the subsequent use of rohtmlwidget as well setlocalstoragedir(file path as string) as boolean configures the html storage path this method takes effect when a new rohtmlwidget instance is created; it doesn't apply to the rohtmlwidget instance on which it is called as of os8, the setlocalstoragedir() , setwebdatabasedir() , and setappcachedir() methods all configure the same html database see the html storage docid\ ralvpeudeblvgwdjo6atl page for more details setwebdatabasedir(file path as string) as boolean configures the html storage path see the setlocalstoragedir() entry above for details this method takes effect when a new rohtmlwidget instance is created; it doesn't apply to the rohtmlwidget instance on which it is called setappcachedir(file path as string) as boolean configures the html storage path see the setlocalstoragedir() entry above for details this method takes effect when a new rohtmlwidget instance is created; it doesn't apply to the rohtmlwidget instance on which it is called setlocalstoragequota(maximum as dynamic) as boolean sets the total size (in bytes) for all persistent html storage on the player this method can accept a string, double, or integer a number literal can only represent byte numbers up to 2gb; use a string to specify larger amounts if the storage path is specified without a storage quota, chromium defaults to reserving 1gb plus 10% of the total size of the storage device this method takes effect when a new rohtmlwidget instance is created; it doesn't apply to the rohtmlwidget instance on which it is called as of os8, the setlocalstoragequota() , setwebstoragequota() , and setappcachequota() methods all configure a single storage quota, which applies to all persistent html storage on the player see html storage docid\ ralvpeudeblvgwdjo6atl for more details setwebdatabasequota(maximum as dynamic) as boolean sets the total size (in bytes) for all persistent html storage on the player see the setlocalstoragequota() entry above for details this method takes effect when a new rohtmlwidget instance is created; it doesn't apply to the rohtmlwidget instance on which it is called setappcachesize(maximum as integer) as boolean sets the maximum size (in bytes) for the application cache changing the storage size of the application cache will clear the cache and rebuild the cache storage depending on database specific attributes, you will only be able to set the size in units that are equal to the page size of the database, which is established at creation these storage units will occur only in the following increments 512, 1024, 2048, 4096, 8192, 16384, 32768 enablejavascript(enable as boolean) as boolean deprecated use javascript enabled in initialization parameters instead allowjavascripturls(url collection as roassociativearray) deprecated if javascript enabled is set to true in the initialization parameters, javascript objects are enabled for all sites postjsmessage(data as roassociativearray) as boolean posts a collection of key\ value pairs to the bsmessageport javascript class (see bsmessageport docid\ sln9xqgldm3dnfegf847b for more details) this method does not support passing nested associative arrays injectjavascript(code as string) as boolean immediately injects a user script into the javascript engine the passed string can contain any of the following pure javascript code, a path to a javascript file, or a base64 encoded string (i e beginning with data\ text/javascript;charset=utf 8;base64, ) this method can be used to simulate the bind ready option if type(event) = "rohtmlwidgetevent" then if event getdata() reason = "load finished" then h injectjavascript("fillpasswordfields()") end if end if changing the dom is only possible at bind dom loaded and bind ready also, since javascript is only guaranteed to be ready at bind ready , your callbacks must use this event if they invoke any global functions startinspectorserver(port as integer) as boolean deprecated use inspector server in initialization parameters instead setuseragent(user agent as string) as boolean deprecated use user agent in initialization parameters instead getuseragent() as string returns the currently active user agent string for the rohtmlwidget instance setuseragentsuffix(suffix as string) as boolean deprecated use user agent in initialization parameters instead setproxy(proxy as string) as boolean sets the name or address of the proxy server that the rohtmlwidget instance will use to make http requests this method takes effect immediately it does not affect network operations performed by other components in the firmware the string can be used to specify either the proxy url or the location of a pac proxy file proxy url the proxy address should be formatted as "http //user\ password\@hostname\ port" the hostname can contain up to four " " characters; each " " character can be used to replace one octet from the current ip address for example, if the ip address is currently 192 168 1 2, and the proxy is set to "proxy ", then the player will attempt to use a proxy named "proxy 192 168" proxy file the pac proxy file can be located on either the local file system or the network if the file is local, there are no file name restrictions; if the file is located on the network, the file name should have a pac extension if the url is a hostname only, it will be considered a proxy server address rather than a file url the following are examples of valid location formats for pac files file ///storage/sd/asset pool/a/b/ababababababa http //example 8080/setup/proxy pac https //example/encrypted/proxy pac https //example 433/encrypted/proxy pac ftp\ //example/files/proxy pac file ///storage/sd/myproxypac txt setproxybypass(hostnames as string) as boolean exempts the specified hosts from the proxy configuration on the rohtmlwidget instance the passed array should consist of one or more hostnames the player will attempt to reach the specified hosts directly rather than using the proxy that has been specified with the setproxy() method for example, the hostname "example com" would exempt "example com", "example com 80", and "www example com" from the proxy setting addproxyauthenticationcredentials(hostname as string, username as string, password as string) allows the user to set up one or more proxies if proxy pac files are included, this method must be used to specify authentication parameters rohtmlwidget acceptdialog(response as string) accept any dialog request with the given string, if there is any such request this parameter was added in bos 8 5 16 rohtmlwidget rejectdialog() reject any dialog request this parameter was added in bos 8 5 16 ifmessageport setport(port as romessageport) posts messages of type rohtmlwidgetevent to the attached message port ifuserdata setuserdata(user data as object) sets the user data that will be returned when events are raised getuserdata() as object returns the user data that has previously been set via setuserdata() it will return invalid if no data has been set available methods with initialization if the properties of an rohtmlwidget object are configured at initialization, most ifhtmlwidget methods will be disabled however, the following methods are still functional hide() show() enablepinchtozoom() flushcachedresources() setuseragent() getuseragent() setuseragentsuffix() postjsmessages() examples the following examples show how to use either an associative array or object methods to configure an rohtmlwidget instance using local storage to cache the files note that these techniques are mutually exclusive example (with initialization properties) x = 0 y = 0 width = 1920 height = 1080 url = "http //www brightsign biz" rect = createobject("rorectangle", x, y, width, height) config = { url url, mouse enabled true, storage path "/local/", } html = createobject("rohtmlwidget", rect, config) html show() example (with methods) x = 0 y = 0 width = 1920 height = 1080 url = "http //www brightsign biz" rect = createobject("rorectangle", x, y, width, height) html = createobject("rohtmlwidget", rect) html seturl(url) html enablemouseevents(true) html setlocalstoragedir("/local/") html show()