Skip to main content
Version: 11.7.0

How to programmatically select a video track quality on Android

This article describes how you can use the VideoTrack API, a sub-API of the MediaTrack API, to select a video track quality. If you select a specific quality, you overrule the ABR algorithm.

Implementing this functionality is a common use-case for developers who want to build their own UI to toggle a specific video quality.

Usage

Set the targetQuality or targetQualities of a MediaTrack.

val videoTrack = player.videoTracks.getItem(0)

// enable a specific video track quality
videoTrack.targetQuality = videoTrack.qualities.getItem(indexOfRequestedVideoTrackQuality)

// do ABR on a set of qualities:
// the ABR algorithm only selects qualities belonging to the given list
videoTrack.targetQualities = listOf(
videoTrack.qualities.getItem(0),
videoTrack.qualities.getItem(1),
)

// set to default ABR algorithm
videoTrack.targetQualities = emptyList()