The Speed Test class is used to support the KONtx.videoplayer and the KONtx.mediaoplayer classes by determining the appropriate bitrate for video playback. The speed test currently downloads videos, compressed with bitrates ranging from 100 kbps (kilobits per second) to 10 Mbps (megabits per second).
The KONtx.speedtest utility provides methods to determine the appropriate bitrate for video playback. Normally the speed test should occur once per app startup, for example in the handler for the onApplicationStartup event. The bitrate is calculated by downloading a file of known size and seeing how long it takes. The bitrate value is in kbps (kilobits per second). If you want to change the URLs used by the speedtest utility call the setSpeedTestURLs() method before calling the profileConnection() method. The mininum bitrate supported is 10 kbps. The maximum bitrate supported by the KONtx Framework is 25 Mbps (megabits per second). Current connected TV devices support approximately 2 Mbps.
Example
ExampleMethods
void debug(String range);Calls the speedtest profiler with a specific bitrate. If no
rangeparameter is passed, uses the default value'512000'.
void profileConnection(Function callback, String range, Function error_callback, int timeout);Determines the bitrate of the connection and calls the given
callbackfunction with the results. The signature of thecallbackfunction is:
function callback(int bitrate, int end_time, int start_time, String testRange)The
profileConnection()parameterrangeallows specific bitrates to be tested. Valid values for the parameterrangeinclude:'102400','512000','1048576','5242880', and'10485760'. The default value forrangeis'512000'.The givenerror_callbackfunction is called if an error occurs. The signature of theerror_callbackfunction is:
function error_callback(XMLHttpRequest request, int end_time, int start_time, String testRange)The
profileConnection()parametertimeoutis used to set the milliseconds timeout for theXMLHttpRequest. The default value for timeout is5.
void setSpeedTestURLs(Array newURLs);Sets the associative array of URLs to be used by the speed test. The keys of the associative array are strings of bitrates in bits per second for each video URL value. The default URLs array is: