Player APIs (BrightScript & Ja...
JavaScript APIs
assetfetcher
13min
the assetfetcher object allows for downloading files to an asset pool (which is represented in javascript as an docid\ ny8nhrk1 740wpryl p8d instance) assetfetcher idl interface assetpoolfetcher { assetpoolfetcher(assetpool pool); promise\<void> start(assetlist list, assetpoolfetcherparams assetpoolparams\[optional]); promise\<void> cancel(); }; interface fileevent { attribute string type; attribute string filename; attribute int index; attribute int responsecode; attribute string error; }; interface progressevent { attribute string type; attribute string filename; attribute int index; attribute int total; attribute long currentfiletransferred; \[optional] attribute long currentfiletotal; }; interface assetpoolfetcherparams { attribute authentication auth; attribute bool enableunsafeauthentication; attribute bool enableunsafeproxyauthentication; attribute bool enableencodings; attribute bool enablepeerverification; attribute bool enablehostverification; attribute string certificatesfile; attribute headerlist headers; attribute string proxy; attribute array\<string> proxybypasslist; attribute unsigned int progressinterval; attribute unsigned int fileretrycount; attribute string relativelinkprefix; attribute string interfacename; attribute mintransferrate minimumtransferrate; attribute double maximumtransferrate; attribute bool onlyrequestcache; }; interface authentication { attribute string username; attribute string password; }; interface header { attribute string value; }; interface mintransferrate { attribute int bytespersecond; attribute int periodinseconds; }; object creation to create an assetpoolfetcher object, you will first need to create an assetpool instance then, load the brightsign/assetpoolfetcher module using the require() method, and create an instance of the assetpoolfetcher class using the assetpool instance const assetpoolclass = require("@brightsign/assetpool"); let assetpool = new assetpoolclass("sd /pool"); const assetpoolfetcherclass = require("@brightsign/assetpoolfetcher"); let assetpoolfetcher = new assetpoolfetcherclass(assetpool); assetpoolfetcher this interface allows you start or stop the asset fetcher start() promise\<void> start(assetlist list, assetpoolfetcherparams assetpoolparams\[optional]) begins fetching the files specified in the passed docid\ ny8nhrk1 740wpryl p8d assetlist interface the fetching process is configured with the passed assetpoolfetcherparams interface the start() promise returns when the asset fetching process is complete alternatively, the promise will be rejected if the assetpoolfetcher instance has already been started this method may cause assets to be pruned cancel() promise\<void> cancel() cancels the asset fetching process the promise will not be resolved until cancellation is complete fileevent this interface contains information about a file transfer attempt type string string contains fileevent to indicate the type of the event filename string string the name of the asset being downloaded index int int the zero based index of the file in the docid\ ny8nhrk1 740wpryl p8d assetlist interface responsecode int int the protocol response code associated with the event the following codes indicate success 200 successful http transfer 226 successful ftp transfer 0 successful local file transfer there are also numerous error codes in case of failure; see roassetfetcherevent docid\ mta3k5raqthawk4u3ue3h for a non exhaustive list error string string a textual error message which may be more descriptive than the responsecode for local errors progressevent this interface contains information about the asset fetching process type string string contains progressevent to indicate the type of the event filename string string the name of the file currently being downloaded index int int the zero based index of the current file in the docid\ ny8nhrk1 740wpryl p8d assetlist interface total int int the total number of files in the assetlist object currentfiletransferred long long the number of bytes that have been downloaded so far for the current asset currentfiletotal long long optional optional if the size of the asset in bytes was known prior to the download starting then it is provided in this property if the size was not known then this property may not be present assetpoolfetcherparams this interface contains configuration parameters for the asset fetcher process auth authentication authentication an authentication interface specifying the credentials to use when downloading the asset enableunsafeauthentication bool bool a flag enabling basic http authentication http authentication uses an insecure protocol, which might allow others to easily determine the password the assetpoolfetcher object will still prefer the stronger digest http if it is supported by the server if this parameter is false (which is the default setting), it will refuse to provide passwords via basic http authentication, and any requests requiring this authentication will fail enableunsafeproxyauthentication bool bool a flag enabling basic http authentication against proxies http authentication uses an insecure protocol, which might allow others to easily determine the password if this parameter is false , it will refuse to provide the proxy password via basic http authentication, and any requests requiring this authentication type will fail unlike enableunsafeauthentication , this parameter is set to true by default enableencodings bool bool a flag enabling http compression, which communicates to the server that the system can accept any encoding that the assetpoolfetcher instance is capable of decoding by itself (this behavior is enabled by default) supported encodings currently include "deflate" and "gzip", which allow for transparent compression of responses clients of the assetpoolfetcher instance see only the decoded data and are unaware of the encoding being used enablepeerverification bool bool a flag that enables checking of tls/ssl certificates this parameter is set to true by default disabling peer verficiation allows you to bypass an expired certificate check enablehostverification bool bool a flag that enables checking of the tls/ssl certificate for the correct hostname this parameter is set to true by default disabling host verification allows you to accept a certificate being sent for the wrong hostname peer verification and host verification are important security checks that prevent "man in the middle" attacks these features should only be disabled after careful consideration of the security implications certificatesfile string string the filename of an alternative set of ca certificates for the connection this method is useful if the connection certificates are signed by a ca that is not on the the default trusted list (for example, if your organization uses a private ca hierarchy that is not signed by a well known root ca) this file replaces the default list, so the passed certificate file must contain all acceptable ca certificates required for the connection headers headerlist headerlist a list of headers that will be passed to http requests made by the assetpoolfetcher instance proxy string string the name or address of the proxy server that will be used by the assetpoolfetcher instance the proxy string should be formatted as "http //user\ password\@hostname\ port" it can contain up to four " " characters; each " " character can be used to replace one octet from the player's 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" if present, this setting overrides the player global proxy setting proxybypasslist array array \<string> \<string> a list of hosts to exempt from the proxy setting the list should consist of one or more hostnames (ip addresses cannot be used) the assetpoolfetcher instance will attempt to reach the specified hosts directly rather than using the proxy that has been specified with the proxy parameter for example, the hostname "example com" would exempt "example com", "example com 80", and "www example com" from the proxy setting if present, this setting overrides the global proxy bypass setting progressinterval unsigned int unsigned int the interval (in seconds) between progress events when an individual file is being downloaded setting the interval to null disables all progress events setting the interval to 0 specifies that events should be generated as often as possible, though this will slow down the transfer process if the interval is set to 0 or any positive integer, events will always be generated at the start and end of the file download irrespective of elapsed time the default interval is 300 seconds fileretrycount unsigned int unsigned int the maximum number of times each file download will be retried before moving on to the next file download the default retry count is five relativelinkprefix string string a prefix that will be prepended to links that lack a protocol in the assetlist object normally, this method is used to make file /// uris drive agnostic, but it can also be used to reduce the size of the sync spec if all files are stored in the same place links that have a protocol are not affected by this method interfacename string string a string specifying which network interface the assetpoolfetcher instance should try to use for network access, for example "eth0" for ethernet or "wlan0" for wifi the default behavior (indicated by a null value) is to send requests using the most appropriate network interface, which may depend on the routing metric configured via the networkconfiguration object if multiple interfaces are on the same layer 2 network, this method may not work as expected due to the linux weak host model minimumtransferrate mintransferrate mintransferrate a mintransferrate interface specifying the average minimum transfer rate for file downloads if a file transfer falls below this rate, it will be terminated maximumtransferrate long long the maximum transfer rate for file downloads the source data rate isn't under the direct control of the brightsign player, but download rates should average below the specified value over time onlyrequestcache bool bool a flag indicating that the player should disconnect shortly after beginning the asset download if the player is set to use a suitably configured proxy (either globally or via the assetpoolfetcherparams interface), then the proxy will continue to download the files, making them readily available for asset fetching calls in the future if this parameter is true , the fileevent will return response code 202 ("accepted") to indicate success other errors will be reported as usual the progressevent for the final all files complete event will always be 2 ("event all failed") because the download does not complete authentication this interface contains authentication information for downloading files username string string the user name for authentication password string string the password for authentication header this interface contains a list of headers to pass to a file download url each entry in the list contains the following parameters value string string the header value mintransferrate the values in this interface are used to calculate the minimum transfer rate bytespersecond int int the transfer rate below which, when it is averaged over the periodinseconds , the file transfer will be terminated periodinseconds int int the time frame over which the bytespersecond measurement is averaged if the transfer is over the internet, you may not want to set the periodinsseconds to a small number in case network problems cause temporary drops in performance for large file transfers and a small bytespersecond limit, averaging fifteen minutes or more may be appropriate