SessionPlayer.TrackInfo

Added in 1.1.0
Deprecated in 1.3.0

class SessionPlayer.TrackInfo : 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

Public constructors

TrackInfo(id: Int, type: Int, format: MediaFormat?)

Constructor to create a TrackInfo instance.

TrackInfo(id: Int, type: Int, format: MediaFormat?, isSelectable: Boolean)

Constructor to create a TrackInfo instance.

Public functions

Boolean
equals(obj: Any?)
MediaFormat?

Gets the MediaFormat of the track.

Int

Gets the id of the track.

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.

String

Constants

MEDIA_TRACK_TYPE_AUDIO

Added in 1.1.0
Deprecated in 1.3.0
const val MEDIA_TRACK_TYPE_AUDIO = 2: Int

MEDIA_TRACK_TYPE_METADATA

Added in 1.1.0
Deprecated in 1.3.0
const val MEDIA_TRACK_TYPE_METADATA = 5: Int

MEDIA_TRACK_TYPE_SUBTITLE

Added in 1.1.0
Deprecated in 1.3.0
const val MEDIA_TRACK_TYPE_SUBTITLE = 4: Int

MEDIA_TRACK_TYPE_UNKNOWN

Added in 1.1.0
Deprecated in 1.3.0
const val MEDIA_TRACK_TYPE_UNKNOWN = 0: Int

MEDIA_TRACK_TYPE_VIDEO

Added in 1.1.0
Deprecated in 1.3.0
const val MEDIA_TRACK_TYPE_VIDEO = 1: Int

Public constructors

TrackInfo

Added in 1.1.0
Deprecated in 1.3.0
TrackInfo(id: Int, type: Int, format: MediaFormat?)

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

Parameters
id: Int

id of track unique across MediaItems

type: Int

type of track. Can be video, audio or subtitle

format: MediaFormat?

format of track

TrackInfo

Added in 1.1.0
Deprecated in 1.3.0
TrackInfo(id: Int, type: Int, format: MediaFormat?, isSelectable: Boolean)

Constructor to create a TrackInfo instance.

Parameters
id: Int

id of track unique across MediaItems

type: Int

type of track. Can be video, audio or subtitle

format: MediaFormat?

format of track

isSelectable: Boolean

whether track can be selected via selectTrack.

Public functions

equals

fun equals(obj: Any?): Boolean

getFormat

Added in 1.1.0
Deprecated in 1.3.0
fun getFormat(): MediaFormat?

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
fun getId(): Int

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
fun getLanguage(): Locale

Gets the language code of the track.

Returns
Locale

Locale which includes the language information

getTrackType

Added in 1.1.0
Deprecated in 1.3.0
fun getTrackType(): Int

Gets the track type.

Returns
Int

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

hashCode

fun hashCode(): Int

isSelectable

Added in 1.1.0
Deprecated in 1.3.0
fun isSelectable(): Boolean

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

fun toString(): String