TrackInfo
open class TrackInfo : CustomVersionedParcelable
androidx.media2.common.SessionPlayer.TrackInfo |
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:
MediaFormat#KEY_LANGUAGE
MediaFormat#KEY_MIME
MediaFormat#KEY_IS_FORCED_SUBTITLE
MediaFormat#KEY_IS_AUTOSELECT
MediaFormat#KEY_IS_DEFAULT
Summary
Constants | |
---|---|
static Int | |
static Int | |
static Int | |
static Int | |
static Int |
Public constructors | |
---|---|
<init>(id: Int, type: Int, @Nullable format: MediaFormat?) Constructor to create a TrackInfo instance. |
|
<init>(id: Int, type: Int, @Nullable format: MediaFormat?, isSelectable: Boolean) Constructor to create a TrackInfo instance. |
Public methods | |
---|---|
open Boolean | |
open MediaFormat? |
Gets the |
open Int |
getId() Gets the id of the track. |
open Locale |
Gets the language code of the track. |
open Int |
Gets the track type. |
open Int |
hashCode() |
open Boolean |
Whether the current track can be selected via |
open String |
toString() |
Constants
Public constructors
<init>
TrackInfo(
id: Int,
type: Int,
@Nullable format: MediaFormat?)
Constructor to create a TrackInfo instance. Note: The default value for isSelectable()
is false.
Parameters | |
---|---|
id |
Int: id of track unique across MediaItem s |
type |
Int: type of track. Can be video, audio or subtitle |
format |
MediaFormat?: format of track |
<init>
TrackInfo(
id: Int,
type: Int,
@Nullable format: MediaFormat?,
isSelectable: Boolean)
Constructor to create a TrackInfo instance.
Parameters | |
---|---|
id |
Int: id of track unique across MediaItem s |
type |
Int: type of track. Can be video, audio or subtitle |
format |
MediaFormat?: format of track |
isSelectable |
Boolean: whether track can be selected via SessionPlayer#selectTrack(TrackInfo) . |
Public methods
getFormat
@Nullable open fun getFormat(): MediaFormat?
Gets the MediaFormat
of the track. If the format is unknown or could not be determined, null is returned.
getId
open fun getId(): Int
Gets the id of the track. The id is used by selectTrack(TrackInfo)
and deselectTrack(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 MediaItem
s to avoid potential mis-selection when a stale TrackInfo
is used.
Return | |
---|---|
Int |
id of the track |
getLanguage
@NonNull open fun getLanguage(): Locale
Gets the language code of the track.
Return | |
---|---|
Locale |
Locale which includes the language information |
getTrackType
open fun getTrackType(): Int
Gets the track type.
Return | |
---|---|
Int |
MediaTrackType which indicates if the track is video, audio or subtitle |
hashCode
open fun hashCode(): Int
isSelectable
open fun isSelectable(): Boolean
Whether the current track can be selected via selectTrack(TrackInfo)
or not.
Return | |
---|---|
Boolean |
true if the current track can be selected; false if otherwise. |
toString
@NonNull open fun toString(): String