TrackInfo

public class TrackInfo

Represents information about tracks available in a media player instance.

This class encapsulates a list of tracks, the index of the currently selected track, and the type of tracks represented (video, audio, or text). Each track is stored as a Bundle containing track-specific metadata. For text tracks, the Bundle includes an "id" (the track's index) and a "sourceId" (a string description of the track's source). For video and audio tracks, the Bundle includes only an "id". The class ensures that the track list is never null by providing an empty list as a default when no tracks are available.

Example usage:


TrackInfo trackInfo = player.getTextTrackInfo(); // Could also be video or audio tracks
if (trackInfo != null) {
    List<Bundle> tracks = trackInfo.getTracks();
    int selectedIndex = trackInfo.getSelectedIndex();
    int trackType = trackInfo.getTrackType();
    Log.d("Client", "Selected track index: " + selectedIndex);
    Log.d("Client", "Number of tracks: " + tracks.size());
    String typeString = trackType == SandboxedPlayer.TRACK_TYPE_VIDEO ? "Video" :
                        trackType == SandboxedPlayer.TRACK_TYPE_AUDIO ? "Audio" : "Text";
    Log.d("Client", "Track type: " + typeString);
    for (Bundle track : tracks) {
        int id = track.getInt("id");
        if (trackType == SandboxedPlayer.TRACK_TYPE_TEXT) {
            String sourceId = track.getString("sourceId");
            Log.d("Client", "Text Track ID: " + id + ", Source: " + sourceId);
        } else {
            Log.d("Client", "Track ID: " + id);
        }
    }
}

See also

Constructors

Link copied to clipboard
public void TrackInfo(List<Bundle> tracks, int selectedIndex, int trackType)
Constructs a new TrackInfo instance with the specified track details.

Properties

Link copied to clipboard
public final int selectedIndex
Link copied to clipboard
public final List<Bundle> tracks
Link copied to clipboard
public final int trackType

Functions

Link copied to clipboard
public int getSelectedIndex()
Returns the index of the currently selected track.
Link copied to clipboard
public List<Bundle> getTracks()
Returns the list of tracks.
Link copied to clipboard
public int getTrackType()
Returns the type of tracks represented by this instance.