How to programmatically select a video track quality on Web
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 property
of a MediaTrack to a single quality, to an array of qualities, or to null.
const videoTrack = player.videoTracks[0];
// enable a specific video track quality
videoTrack.targetQuality = videoTrack.qualities[indexOfRequestedVideoTrackQuality];
// do ABR on a set of qualities
videoTrack.targetQuality = [videoTrack.qualities[indexOfRequestedVideoTrackQuality1], videoTrack.qualities[indexOfRequestedVideoTrackQuality2]];
// set to default ABR algorithm
videoTrack.targetQuality = null;