Internet Speed Test
The Quickplay SDK enables speed measurement on a device, providing real-time progress and final results. It supports both suspending functions (Kotlin) and callback interfaces (Java). This information can also be reported to analytics and used to enhance playback strategies based on network conditions.
Measure Speed
Use the SpeedAnalyser
class to measure the average download speed and DNS resolution time.
Test URLs are provided in the QualityURLSet
class, which includes three URLs with varying quality levels:
Attribute | Description |
---|---|
low | The URL intended for low-bandwidth or low-quality testing. |
medium | The URL intended for medium-bandwidth or medium-quality testing. |
high | The URL intended for high-bandwidth or high-quality testing. |
- Kotlin
- Java
SpeedAnalyser.measureSpeed(
urls = QualityURLSet, // your set of test URLs
onProgress = { instantaneousMbps, elapsedMs ->
// Called with the instantaneous download speed in Mbps and elapsed time in ms
},
onComplete = { result: SpeedTestResult ->
// Called with test result on completion
},
onError = { error: Error ->
// Called on error
}
)
SpeedAnalyser.measureSpeed(
new QualityURLSet(lowUrl, mediumUrl, highUrl), // your set of test URLs
new SpeedTestProgressListener() {
@Override public void onProgress(double instantaneousMbps, long elapsedMs) {
// Called with the instantaneous download speed in Mbps and elapsed time in ms
}
@Override public void onComplete(SpeedTestResult result) {
// Called with test result on completion
}
@Override public void onError(Error error) {
// Called on error
}
}
);
The SpeedTestResult object contains the following fields:
Attribute | Description |
---|---|
averageSpeedMbps | The average download speed in Mbps |
avgDNSResolutionTimeMs | Average DNS resolution time (ms) |
timeTakenForTestMs | Total time taken (ms) to complete the speed test |