Package com.google.android.exoplayer2

## Class Tracks.Group

- java.lang.Object
- - com.google.android.exoplayer2.Tracks.Group

- All Implemented Interfaces:
    `Bundleable`
  Enclosing class:
    Tracks

      public static final class Tracks.Group
      extends Object
      implements Bundleable

  Information about a single group of tracks, including the underlying `TrackGroup`, the level to which each track is supported by the player, and whether any of the tracks are selected.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.google.android.exoplayer2.Bundleable

      `Bundleable.Creator<T extends Bundleable>`

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static Bundleable.Creator<Tracks.Group>` | `CREATOR` | Object that can restore a group of tracks from a `Bundle`.
    `int` | `length` | The number of tracks in the group.

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Group​(TrackGroup mediaTrackGroup, boolean adaptiveSupported, @com.google.android.exoplayer2.C.FormatSupport int[] trackSupport, boolean[] trackSelected)` | Constructs an instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `boolean` | `equals​(Object other)` |
    `TrackGroup` | `getMediaTrackGroup()` | Returns the underlying `TrackGroup` defined by the media.
    `Format` | `getTrackFormat​(int trackIndex)` | Returns the `Format` for a specified track.
    `@com.google.android.exoplayer2.C.FormatSupport int` | `getTrackSupport​(int trackIndex)` | Returns the level of support for a specified track.
    `@com.google.android.exoplayer2.C.TrackType int` | `getType()` | Returns the `C.TrackType` of the group.
    `int` | `hashCode()` |
    `boolean` | `isAdaptiveSupported()` | Returns whether adaptive selections containing more than one track are supported.
    `boolean` | `isSelected()` | Returns whether at least one track in the group is selected for playback.
    `boolean` | `isSupported()` | Returns whether at least one track in the group is supported for playback, without exceeding the advertised capabilities of the device.
    `boolean` | `isSupported​(boolean allowExceedsCapabilities)` | Returns whether at least one track in the group is supported for playback.
    `boolean` | `isTrackSelected​(int trackIndex)` | Returns whether a specified track is selected for playback.
    `boolean` | `isTrackSupported​(int trackIndex)` | Returns whether a specified track is supported for playback, without exceeding the advertised capabilities of the device.
    `boolean` | `isTrackSupported​(int trackIndex, boolean allowExceedsCapabilities)` | Returns whether a specified track is supported for playback.
    `Bundle` | `toBundle()` | Returns a `Bundle` representing the information stored in this object.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### length

          public final int length

      The number of tracks in the group.

    - #### CREATOR

          public static final Bundleable.Creator<Tracks.Group> CREATOR

      Object that can restore a group of tracks from a `Bundle`.

  - ### Constructor Detail

    - #### Group

          public Group​(TrackGroup mediaTrackGroup,
                       boolean adaptiveSupported,
                       @FormatSupport
                       @com.google.android.exoplayer2.C.FormatSupport int[] trackSupport,
                       boolean[] trackSelected)

      Constructs an instance.
      Parameters:
        `mediaTrackGroup` - The underlying `TrackGroup` defined by the media.
        `adaptiveSupported` - Whether the player supports adaptive selections containing more than one track in the group.
        `trackSupport` - The `C.FormatSupport` of each track in the group.
        `trackSelected` - Whether each track in the `trackGroup` is selected.

  - ### Method Detail

    - #### getMediaTrackGroup

          public TrackGroup getMediaTrackGroup()

      Returns the underlying `TrackGroup` defined by the media.

      Unlike this class, `TrackGroup` only contains information defined by the media itself, and does not contain runtime information such as which tracks are supported and currently selected. This makes it suitable for use as a `key` in certain `(key, value)` data structures.

    - #### getTrackFormat

          public Format getTrackFormat​(int trackIndex)

      Returns the `Format` for a specified track.
      Parameters:
        `trackIndex` - The index of the track in the group.
      Returns:
        The `Format` of the track.

    - #### getTrackSupport

          @FormatSupport
          public @com.google.android.exoplayer2.C.FormatSupport int getTrackSupport​(int trackIndex)

      Returns the level of support for a specified track.
      Parameters:
        `trackIndex` - The index of the track in the group.
      Returns:
        The `C.FormatSupport` of the track.

    - #### isTrackSupported

          public boolean isTrackSupported​(int trackIndex)

      Returns whether a specified track is supported for playback, without exceeding the advertised capabilities of the device. Equivalent to `isTrackSupported(trackIndex, false)`.
      Parameters:
        `trackIndex` - The index of the track in the group.
      Returns:
        True if the track's format can be played, false otherwise.

    - #### isTrackSupported

          public boolean isTrackSupported​(int trackIndex,
                                          boolean allowExceedsCapabilities)

      Returns whether a specified track is supported for playback.
      Parameters:
        `trackIndex` - The index of the track in the group.
        `allowExceedsCapabilities` - Whether to consider the track as supported if it has a supported `MIME type`, but otherwise exceeds the advertised capabilities of the device. For example, a video track for which there's a corresponding decoder whose maximum advertised resolution is exceeded by the resolution of the track. Such tracks may be playable in some cases.
      Returns:
        True if the track's format can be played, false otherwise.

    - #### isSelected

          public boolean isSelected()

      Returns whether at least one track in the group is selected for playback.

    - #### isAdaptiveSupported

          public boolean isAdaptiveSupported()

      Returns whether adaptive selections containing more than one track are supported.

    - #### isSupported

          public boolean isSupported()

      Returns whether at least one track in the group is supported for playback, without exceeding the advertised capabilities of the device. Equivalent to `isSupported(false)`.

    - #### isSupported

          public boolean isSupported​(boolean allowExceedsCapabilities)

      Returns whether at least one track in the group is supported for playback.
      Parameters:
        `allowExceedsCapabilities` - Whether to consider a track as supported if it has a supported `MIME type`, but otherwise exceeds the advertised capabilities of the device. For example, a video track for which there's a corresponding decoder whose maximum advertised resolution is exceeded by the resolution of the track. Such tracks may be playable in some cases.

    - #### isTrackSelected

          public boolean isTrackSelected​(int trackIndex)

      Returns whether a specified track is selected for playback.

      Note that multiple tracks in the group may be selected. This is common in adaptive streaming, where tracks of different qualities are selected and the player switches between them during playback (e.g., based on the available network bandwidth).

      This class doesn't provide a way to determine which of the selected tracks is currently playing, however some player implementations have ways of getting such information. For example, ExoPlayer provides this information via `ExoTrackSelection.getSelectedFormat`.

      Parameters:
        `trackIndex` - The index of the track in the group.
      Returns:
        True if the track is selected, false otherwise.

    - #### getType

          public @com.google.android.exoplayer2.C.TrackType int getType()

      Returns the `C.TrackType` of the group.

    - #### equals

          public boolean equals​(@Nullable
                                Object other)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### toBundle

          public Bundle toBundle()

      Description copied from interface: `Bundleable`
      Returns a `Bundle` representing the information stored in this object.
      Specified by:
        `toBundle` in interface `Bundleable`