Skip to main content

Internet speed test

The Quickplay SDK enables download speed measurement on a device, providing real-time progress and final results. This information can also be reported to analytics and used to enhance playback strategies based on network conditions.

Measure Download Speed

Test URLs are to be provided in the QualityURLSet class, which includes three URLs with varying quality levels:

AttributeDescription
lowThe URL intended for low-bandwidth or low-quality testing.
mediumThe URL intended for medium-bandwidth or medium-quality testing.
highThe URL intended for high-bandwidth or high-quality testing.

Below is the sample snippet for the network speed detection integration.

onNetworkSpeedDetectionInProgress callback gives the current speed and elapsed time since the start of the test.

AttributeDescription
speedThe current download speed in megabits per second (Mbps)
elapsedThe elapsed time in milliseconds since the start of the test.

onNetworkSpeedDetectionComplete callback gives SpeedTestResult object contains the following fields:

AttributeDescription
averageSpeedMbpsThe average download speed in Mbps
avgDNSResolutionTimeMsAverage DNS resolution time (ms)
timeTakenForTestMsTotal time taken (ms) to complete the speed test

onError callback to receive any error in the process of network speed detection.

const urls: QualityURLSet = {
low: 'https://storage.googleapis.com/gvabox/media/samples/stock.mp4',
medium: 'https://storage.googleapis.com/exoplayer-test-media-0/shorts_android_developers/shorts_1.mp4',
high: 'https://storage.googleapis.com/gvabox/media/samples/stock.mp4',
};

const listener = {
onNetworkSpeedDetectionInProgress(speed: number, elapsed: number): void {
console.log('### in progress values', speed, elapsed);
},
onNetworkSpeedDetectionComplete(speedTestResult: SpeedTestResult): void {
console.log(
'### on complete values',
speedTestResult.averageSpeedMbps,
speedTestResult.averageDnsResolutionTimeMs,
speedTestResult.totalTestDurationMs,
);
},
onNetworkSpeedDetectionError(error: PlatformError): void {
console.log('network detection error', error);
},
};

networkSpeedDetector.addListener(listener);
networkSpeedDetector.measureNetworkSpeed(urls);