Interacting with Tracks

Text tracks

Get all Text tracks programmatically
This is the main interface into the text tracks of the player. It return a TextTrackList which lists all the tracks on the player.

  player.textTracks();

Text track Attributes

// A unique id for this TextTrack.
track.id

// Only support for subtitles
track.kind {"Subtitles", "captions", "chapters", "descriptions", "metadata"}

// The label for the track that will be show to the user, 
// for example in a menu that list the different languages available for subtitles.
track.label

// Language code
track.language

// The mode can be one of three values disabled, hidden, and showing.
track.mode

Showing Text track programmatically

Some of you would want to turn captions on and off programmatically rather than just forcing the user to do so themselves. This can be easily achieved by use empPlayer track method's:

Set selected Text track, kind is optional

player.selectTextTrack(languageCode, kind);

Get selected Text track, return language code or null if no/hidden Text track

player.getSelectedTextTrack();

Hide or Show Text tracks programmatically

player.textTrackVisible(visible);

Check if Text track is visible

player.isTextTrackVisible()

Get all text track language codes

player.getTextTracksLanguages();

Audio tracks

Get all Audio tracks programmatically
This is the main interface into the audio tracks of the player. It returns an AudioTrackList which is an array like object that contains all the AudioTrack on the player.

  player.audioTracks();

Audio track Attributes

// A unique id for this AudioTrack.
track.id

// Only support for main
track.kind {"alternative", "descriptions", "main", "translation", "commentary"}

// The label for the track that will be show to the user, 
// for example in a menu that list the different languages available for audio tracks.
track.label

// Language code
track.language

// If this track should be playing or not. 
// We only allow one track to be enabled at a time. 
// So if you enable more than one the last one to be enabled will end up being the only one.
track.enabled

Change Audio track programmatically

Some of you would want to change audio language programmatically rather than just forcing the user to do so themselves. This can be easily achieved by use empPlayer track method's:

Get selected Audio track, kind is optional

player.selectAudioTrack(language, kind);

Get selected Audio track, return language code or null if no Audio track

function getSelectedAudioTrack();

Get all Audio track language codes

player.getAudioTracksLanguages();