About
Track labels are the names viewers see in the player when they choose a video quality, an audio language, or a caption language, such as 360p or English. You can change these labels to make them clearer for your viewers, for example to show High and Low instead of resolutions, or full language names instead of language codes.
To change track labels, add callback functions to the customLabels object in the player's root-level configuration. The player shows the label that each function returns.
For the complete API reference, see the Kaltura player configuration guide and the PlayKit core configuration guide.
This example sets custom labels for video qualities, captions, and audio tracks.
customLabels: {
//qualities: translateVideoQuality,
qualities: function (videoTrack) {
if (videoTrack.height > 500) {
return 'High';
}
return 'Low';
},
captions: translateLangCode,
audio: translateLangCode
}
Video track labels
Each video track has the following properties, which you can use in your label logic.
{
"active": false,
"label": "360p",
"language": "",
"index": 1,
"available": true,
"bandwidth": 719794,
"width": 640,
"height": 360
}
This function labels video tracks taller than 500 pixels as High, and all other video tracks as Low.
const translateVideoQuality = (track) => {
if (track.height > 500) {
return 'High';
}
return 'Low';
};
Change the Auto quality label
The customLabels.qualities function only changes the labels of individual video tracks, such as 360p, 720p, and 1080p. It doesn't change the label of the adaptive Auto option.
To change or translate the Auto label, use the translations setting in the ui section of the player configuration, with the settings.qualityAuto key.
const config = {
targetId: 'player-placeholder',
provider: { partnerId: YOUR_PARTNER_ID },
ui: {
translations: {
en: {
settings: {
qualityAuto: 'Automatic (ABR)' // Customizes the 'Auto' label
}
}
}
},
customLabels: {
qualities: translateVideoQuality
}
};
You can also change the Auto label without code, in the player's Advanced Settings in Player Studio. For more information, see Customize player text labels.
Audio and text track labels
Audio and text tracks have the following properties, which you can use in your label logic. This is the structure of an audio track.
{
"id": 0,
"active": false,
"label": "English",
"language": "en",
"index": 0,
"available": true
}
This is the structure of a text track.
{
"id": 1,
"active": true,
"label": "Esp",
"language": "es",
"index": 1,
"available": true,
"kind": "subtitles",
"default": false
}
This function shows full language names for Spanish and English tracks, and keeps the original label for all other languages.
const translateLangCode = (track) => {
if (track.language === "es" || track.language === "spa") {
return 'Spanish';
}
else if (track.language === "en" || track.language === "eng") {
return 'English';
}
return track.label;
};
Where viewers see track labels
Viewers change video tracks from the settings icon, and audio and text tracks from the globe icon.
More information
For more information about managing tracks, see Managing tracks on the player in the Kaltura player documentation on GitHub.