This article describes how to select different tracks in the stream.

Track Types

There are three types of defined track types:

Working with Tracks in the SDK

There are two options for working with tracks in the SDK:

  • Using the HTML5 web view menus: In this case selection is done from the web layer using the tracks plugins.
  • Using native menus: In this case it is possible implement the following:
    • KTrackActions.EventListener
    • KTrackActions.VideoTrackEventListener
    • KTrackActions.AudioTrackEventListener
    • KTrackActions.TextTrackEventListener

Adding/Removing Listeners

  1. At the Player creation phase, you will need to add a call to set/removed for each event listener that you wish to receive during runtime:
  2. For each listener, you will need to implement the following:

     mPlayer.setTracksEventListener(this); // for a change in the tracks list upon media switching
     mPlayer.setVideoTrackEventListener(this); for a change in the video track index
     mPlayer.setAudioTrackEventListener(this); for a change in the audio tracks index
     mPlayer.setTextTrackEventListener(this);  for a change in the text track index
  3. For each listener, you will need to implement the following:

    public void onTracksUpdate(KTrackActions tracksManager) {
    Log.d(TAG, “** onTracksUpdate ** “);
    public void onVideoTrackChanged(int currentTrack) {
    Log.d(TAG, “** onVideoTrackChanged ** “ + currentTrack);
    public void onTextTrackChanged(int currentTrack) {
    Log.d(TAG, “** onTextTrackChanged ** “ + currentTrack);
    public void onAudioTrackChanged(int currentTrack) {
    Log.d(TAG, “** onAudioTrackChanged ** “ + currentTrack);

Enabling the Tracks Feature

To enable the Tracks feature, run the Tracks plugins as follows:

Video Tracks

config.addConfig(“sourceSelector.plugin”, “true”);
config.addConfig(“sourceSelector.displayMode”, “bitrate”);

Audio Tracks

config.addConfig(“audioSelector.plugin”, “true”);

Text Tracks

config.addConfig(“closedCaptions.plugin”, “true”);
config.addConfig(“closedCaptions.showEmbeddedCaptions”, “true”);

KTracksManager Available Operations

The following are the available operations when using the KTracksManager:

  • List getAudioTrackList();
  • List getTextTrackList();
  • List getVideoTrackList();
  • TrackFormat getCurrentTrack(TrackType trackType);
  • void switchTrack(TrackType trackType, int newIndex);

Attention! : the TracksManger is available only after PLAYING state is received in the activity. If you register to the onTracksUpdate will be able to have it right after it is populated

Getting Tracks

for (TrackFormat track : mPlayer.getTrackManager().getAudioTrackList()) {
      Log.d(TAG, track.toString());
for (TrackFormat track : mPlayer.getTrackManager().getVideoTrackList()) {
      Log.e(TAG, track.toString());
for (TrackFormat track : mPlayer.getTrackManager().getTextTrackList()) {
      Log.d(TAG, track.toString());

Switching Tracks


Disable Video/Audio/Text Tracks

mPlayer.getTrackManager().switchTrack(TrackType.TYPE_TEXT, -1);

Getting the Current Track Index by Track Type


Starting the Player with a Preferred Bitrate

The user may want to start the playback with a specific bitrate. This can be achieved using the following code in the player init or in the change configuration process:

String preferredBitrateMbit = "600";
config.addConfig("mediaProxy.preferredFlavorBR", preferredBitrateMbit);