public abstract class TrackSelector extends Object
ExoPlayerresponsible for selecting tracks to be consumed by each of the player's
DefaultTrackSelectorimplementation should be suitable for most use cases.
selectTracks(RendererCapabilities, TrackGroupArray). This typically occurs at the start of playback, when the player starts to buffer a new period of the media being played, and when the track selector invalidates its previous selections.
TrackSelector.InvalidationListenerthat was passed to
init(InvalidationListener). A track selector may wish to do this if its configuration has changed, for example if it now wishes to prefer audio tracks in a particular language. This will trigger the player to make new track selections. Note that the player will have to re-buffer in the case that the new track selection for the currently playing period differs from the one that was invalidated.
selectTracks(RendererCapabilities, TrackGroupArray)contains not only
TrackSelections for each renderer, but also
RendererConfigurations defining configuration parameters that the renderers should apply when consuming the corresponding media. Whilst it may seem counter-intuitive for a track selector to also specify renderer configuration information, in practice the two are tightly bound together. It may only be possible to play a certain combination tracks if the renderers are configured in a particular way. Equally, it may only be possible to configure renderers in a particular way if certain tracks are selected. Hence it makes sense to determined the track selection and corresponding renderer configurations in a single step.
TrackSelector.InvalidationListener.onTrackSelectionsInvalidated()from any thread.
|Modifier and Type||Class and Description|
Notified when selections previously made by a
|Constructor and Description|
|Modifier and Type||Method and Description|
Called by the player to initialize the selector.
Called by the player when a
Called by the player to perform a track selection.
public final void init(TrackSelector.InvalidationListener listener)
listener- An invalidation listener that the selector can call to indicate that selections it has previously made are no longer valid.
public abstract TrackSelectorResult selectTracks(RendererCapabilities rendererCapabilities, TrackGroupArray trackGroups) throws ExoPlaybackException
public abstract void onSelectionActivated(Object info)
TrackSelectorResultpreviously generated by
selectTracks(RendererCapabilities, TrackGroupArray)is activated.
info- The value of
TrackSelectorResult.infoin the activated selection.
protected final void invalidate()
TrackSelector.InvalidationListener.onTrackSelectionsInvalidated()to invalidate all previously generated track selections.