public class

SessionPlayer.TrackInfo

extends CustomVersionedParcelable

 java.lang.Object

androidx.versionedparcelable.CustomVersionedParcelable

↳androidx.media2.common.SessionPlayer.TrackInfo

Subclasses:

MediaPlayer.TrackInfo

Overview

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:

Summary

Fields
public static final intMEDIA_TRACK_TYPE_AUDIO

public static final intMEDIA_TRACK_TYPE_METADATA

public static final intMEDIA_TRACK_TYPE_SUBTITLE

public static final intMEDIA_TRACK_TYPE_UNKNOWN

public static final intMEDIA_TRACK_TYPE_VIDEO

Constructors
publicTrackInfo(int id, int type, MediaFormat format)

Constructor to create a TrackInfo instance.

publicTrackInfo(int id, int type, MediaFormat format, boolean isSelectable)

Constructor to create a TrackInfo instance.

Methods
public booleanequals(java.lang.Object obj)

public MediaFormatgetFormat()

Gets the of the track.

public intgetId()

Gets the id of the track.

public java.util.LocalegetLanguage()

Gets the language code of the track.

public intgetTrackType()

Gets the track type.

public inthashCode()

public booleanisSelectable()

Whether the current track can be selected via SessionPlayer.selectTrack(SessionPlayer.TrackInfo) or not.

public voidonPostParceling()

Called immediately after this object has been deserialized, can be used to handle any custom fields that cannot be easily annotated.

public voidonPreParceling(boolean isStream)

public java.lang.StringtoString()

from java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, wait

Fields

public static final int MEDIA_TRACK_TYPE_UNKNOWN

public static final int MEDIA_TRACK_TYPE_VIDEO

public static final int MEDIA_TRACK_TYPE_AUDIO

public static final int MEDIA_TRACK_TYPE_SUBTITLE

public static final int MEDIA_TRACK_TYPE_METADATA

Constructors

public TrackInfo(int id, int type, MediaFormat format)

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

Parameters:

id: id of track unique across MediaItems
type: type of track. Can be video, audio or subtitle
format: format of track

public TrackInfo(int id, int type, MediaFormat format, boolean isSelectable)

Constructor to create a TrackInfo instance.

Parameters:

id: id of track unique across MediaItems
type: type of track. Can be video, audio or subtitle
format: format of track
isSelectable: whether track can be selected via SessionPlayer.selectTrack(SessionPlayer.TrackInfo).

Methods

public int getTrackType()

Gets the track type.

Returns:

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

public java.util.Locale getLanguage()

Gets the language code of the track.

Returns:

java.util.Locale which includes the language information

public MediaFormat getFormat()

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

public int getId()

Gets the id of the track. The id is used by SessionPlayer.selectTrack(SessionPlayer.TrackInfo) and SessionPlayer.deselectTrack(SessionPlayer.TrackInfo) 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 SessionPlayer.TrackInfo is used.

Returns:

id of the track

public boolean isSelectable()

Whether the current track can be selected via SessionPlayer.selectTrack(SessionPlayer.TrackInfo) or not.

Returns:

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

public java.lang.String toString()

public int hashCode()

public boolean equals(java.lang.Object obj)

public void onPreParceling(boolean isStream)

Parameters:

isStream:

public void onPostParceling()

Called immediately after this object has been deserialized, can be used to handle any custom fields that cannot be easily annotated.