Chapter 16. Speed Test

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).


Toolbox speed test utility

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.




void debug(String range);

Calls the speedtest profiler with a specific bitrate. If no range parameter 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 callback function with the results. The signature of the callback function is:

function callback(int bitrate, int end_time, int start_time, String testRange)

The profileConnection() parameter range allows specific bitrates to be tested. Valid values for the parameter range include: '102400', '512000', '1048576', '5242880', and '10485760'. The default value for range is '512000'.The given error_callback function is called if an error occurs. The signature of the error_callback function is:

function error_callback(XMLHttpRequest request, int end_time, int start_time, String testRange)

The profileConnection() parameter timeout is used to set the milliseconds timeout for the XMLHttpRequest. The default value for timeout is 5.

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:

Table of Contents