SessionPlayer.TrackInfo

Added in 1.1.0
Deprecated in 1.3.0

public class SessionPlayer.TrackInfo implements VersionedParcelable

Known direct subclasses
MediaPlayer.TrackInfo

This class is deprecated.

androidx.media2 is deprecated.


Class for the player to return each audio/video/subtitle track's metadata.

Note: TrackInfo holds a MediaFormat instance, but only the following key-values will be supported when sending it over different processes:

See also
getTracks

Summary

Constants

static final int
static final int
static final int
static final int
static final int

Public constructors

TrackInfo(int id, int type, @Nullable MediaFormat format)

Constructor to create a TrackInfo instance.

TrackInfo(
    int id,
    int type,
    @Nullable MediaFormat format,
    boolean isSelectable
)

Constructor to create a TrackInfo instance.

Public methods

boolean
@Nullable MediaFormat

Gets the MediaFormat of the track.

int

Gets the id of the track.

@NonNull Locale

Gets the language code of the track.

int

Gets the track type.

int
boolean

Whether the current track can be selected via selectTrack or not.

@NonNull String

Constants

MEDIA_TRACK_TYPE_AUDIO

Added in 1.1.0
Deprecated in 1.3.0
public static final int MEDIA_TRACK_TYPE_AUDIO = 2

MEDIA_TRACK_TYPE_METADATA

Added in 1.1.0
Deprecated in 1.3.0
public static final int MEDIA_TRACK_TYPE_METADATA = 5

MEDIA_TRACK_TYPE_SUBTITLE

Added in 1.1.0
Deprecated in 1.3.0
public static final int MEDIA_TRACK_TYPE_SUBTITLE = 4

MEDIA_TRACK_TYPE_UNKNOWN

Added in 1.1.0
Deprecated in 1.3.0
public static final int MEDIA_TRACK_TYPE_UNKNOWN = 0

MEDIA_TRACK_TYPE_VIDEO

Added in 1.1.0
Deprecated in 1.3.0
public static final int MEDIA_TRACK_TYPE_VIDEO = 1

Public constructors

TrackInfo

Added in 1.1.0
Deprecated in 1.3.0
public TrackInfo(int id, int type, @Nullable MediaFormat format)

Constructor to create a TrackInfo instance. Note: The default value for isSelectable is false.

Parameters
int id

id of track unique across MediaItems

int type

type of track. Can be video, audio or subtitle

@Nullable MediaFormat format

format of track

TrackInfo

Added in 1.1.0
Deprecated in 1.3.0
public TrackInfo(
    int id,
    int type,
    @Nullable MediaFormat format,
    boolean isSelectable
)

Constructor to create a TrackInfo instance.

Parameters
int id

id of track unique across MediaItems

int type

type of track. Can be video, audio or subtitle

@Nullable MediaFormat format

format of track

boolean isSelectable

whether track can be selected via selectTrack.

Public methods

equals

public boolean equals(@Nullable Object obj)

getFormat

Added in 1.1.0
Deprecated in 1.3.0
public @Nullable MediaFormat getFormat()

Gets the MediaFormat of the track. If the format is unknown or could not be determined, null is returned.

getId

Added in 1.1.0
Deprecated in 1.3.0
public int getId()

Gets the id of the track. The id is used by selectTrack and deselectTrack to identify the track to be (de)selected. So, it's highly recommended to ensure that the id of each track is unique across MediaItems to avoid potential mis-selection when a stale TrackInfo is used.

Returns
int

id of the track

getLanguage

Added in 1.1.0
Deprecated in 1.3.0
public @NonNull Locale getLanguage()

Gets the language code of the track.

Returns
@NonNull Locale

Locale which includes the language information

getTrackType

Added in 1.1.0
Deprecated in 1.3.0
public int getTrackType()

Gets the track type.

Returns
int

MediaTrackType which indicates if the track is video, audio or subtitle

hashCode

public int hashCode()

isSelectable

Added in 1.1.0
Deprecated in 1.3.0
public boolean isSelectable()

Whether the current track can be selected via selectTrack or not.

Returns
boolean

true if the current track can be selected; false if otherwise.

toString

public @NonNull String toString()