Class DefaultTrackSelector
- java.lang.Object
-
- com.google.android.exoplayer2.trackselection.TrackSelector
-
- com.google.android.exoplayer2.trackselection.MappingTrackSelector
-
- com.google.android.exoplayer2.trackselection.DefaultTrackSelector
-
- All Implemented Interfaces:
RendererCapabilities.Listener
- Direct Known Subclasses:
FakeTrackSelector
@Deprecated public class DefaultTrackSelector extends MappingTrackSelector implements RendererCapabilities.Listener
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.A defaultTrackSelector
suitable for most use cases.Modifying parameters
Track selection parameters should be modified by obtaining aTrackSelectionParameters.Builder
initialized with the currentTrackSelectionParameters
from the player. The desired modifications can be made on the builder, and the resultingTrackSelectionParameters
can then be built and set on the player:
Some specialized parameters are only available in the extendedplayer.setTrackSelectionParameters( player.getTrackSelectionParameters() .buildUpon() .setMaxVideoSizeSd() .setPreferredAudioLanguage("de") .build());
DefaultTrackSelector.Parameters
class, which can be retrieved and modified in a similar way by calling methods directly on this class:defaultTrackSelector.setParameters( defaultTrackSelector.getParameters() .buildUpon() .setTunnelingEnabled(true) .build());
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultTrackSelector.Parameters
Deprecated.ExtendsDefaultTrackSelector.Parameters
by adding fields that are specific toDefaultTrackSelector
.static class
DefaultTrackSelector.ParametersBuilder
Deprecated.UseDefaultTrackSelector.Parameters.Builder
instead.protected static interface
DefaultTrackSelector.SelectionEligibility
Deprecated.The extent to which tracks are eligible for selection.static class
DefaultTrackSelector.SelectionOverride
Deprecated.A track selection override.-
Nested classes/interfaces inherited from class com.google.android.exoplayer2.trackselection.MappingTrackSelector
MappingTrackSelector.MappedTrackInfo
-
Nested classes/interfaces inherited from class com.google.android.exoplayer2.trackselection.TrackSelector
TrackSelector.InvalidationListener
-
-
Field Summary
Fields Modifier and Type Field Description Context
context
Deprecated.protected static int
SELECTION_ELIGIBILITY_ADAPTIVE
Deprecated.Track is eligible for both a fixed selection and as part of an adaptive selection with multiple tracks.protected static int
SELECTION_ELIGIBILITY_FIXED
Deprecated.Track is eligible for a fixed selection with one track.protected static int
SELECTION_ELIGIBILITY_NO
Deprecated.Track is not eligible for selection.
-
Constructor Summary
Constructors Constructor Description DefaultTrackSelector(Context context)
Deprecated.DefaultTrackSelector(Context context, ExoTrackSelection.Factory trackSelectionFactory)
Deprecated.DefaultTrackSelector(Context context, TrackSelectionParameters parameters)
Deprecated.DefaultTrackSelector(Context context, TrackSelectionParameters parameters, ExoTrackSelection.Factory trackSelectionFactory)
Deprecated.DefaultTrackSelector(TrackSelectionParameters parameters, ExoTrackSelection.Factory trackSelectionFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DefaultTrackSelector.Parameters.Builder
buildUponParameters()
Deprecated.Returns a newDefaultTrackSelector.Parameters.Builder
initialized with the current selection parameters.protected static int
getFormatLanguageScore(Format format, String language, boolean allowUndeterminedFormatLanguage)
Deprecated.Returns a score for how well a language specified in aFormat
matches a given language.DefaultTrackSelector.Parameters
getParameters()
Deprecated.Returns the current parameters for track selection.RendererCapabilities.Listener
getRendererCapabilitiesListener()
Deprecated.Returns theRendererCapabilities.Listener
that the concrete instance uses to listen to the renderer capabilities changes.boolean
isSetParametersSupported()
Deprecated.Returns if thisTrackSelector
supportsTrackSelector.setParameters(TrackSelectionParameters)
.protected static boolean
isSupported(@com.google.android.exoplayer2.RendererCapabilities.Capabilities int formatSupport, boolean allowExceedsCapabilities)
Deprecated.Returns true if theC.FormatSupport
in the givenRendererCapabilities.Capabilities
isC.FORMAT_HANDLED
or ifallowExceedsCapabilities
is set and the format support isC.FORMAT_EXCEEDS_CAPABILITIES
.protected static String
normalizeUndeterminedLanguageToNull(String language)
Deprecated.Normalizes the input string to null if it does not define a language, or returns it otherwise.void
onRendererCapabilitiesChanged(Renderer renderer)
Deprecated.Called when the renderer capabilities are changed.void
release()
Deprecated.Called by the player to release the selector.protected @NullableType ExoTrackSelection.Definition[]
selectAllTracks(MappingTrackSelector.MappedTrackInfo mappedTrackInfo, @com.google.android.exoplayer2.RendererCapabilities.Capabilities int[][][] rendererFormatSupports, @com.google.android.exoplayer2.RendererCapabilities.AdaptiveSupport int[] rendererMixedMimeTypeAdaptationSupports, DefaultTrackSelector.Parameters params)
Deprecated.Called fromselectTracks(MappedTrackInfo, int[][][], int[], MediaPeriodId, Timeline)
to make a track selection for each renderer, prior to overrides and disabled flags being applied.protected Pair<ExoTrackSelection.Definition,Integer>
selectAudioTrack(MappingTrackSelector.MappedTrackInfo mappedTrackInfo, @com.google.android.exoplayer2.RendererCapabilities.Capabilities int[][][] rendererFormatSupports, @com.google.android.exoplayer2.RendererCapabilities.AdaptiveSupport int[] rendererMixedMimeTypeAdaptationSupports, DefaultTrackSelector.Parameters params)
Deprecated.Called byselectAllTracks(MappedTrackInfo, int[][][], int[], Parameters)
to create aExoTrackSelection.Definition
for an audio track selection.protected ExoTrackSelection.Definition
selectOtherTrack(int trackType, TrackGroupArray groups, @com.google.android.exoplayer2.RendererCapabilities.Capabilities int[][] formatSupport, DefaultTrackSelector.Parameters params)
Deprecated.Called byselectAllTracks(MappedTrackInfo, int[][][], int[], Parameters)
to create aExoTrackSelection
for a renderer whose type is neither video, audio or text.protected Pair<ExoTrackSelection.Definition,Integer>
selectTextTrack(MappingTrackSelector.MappedTrackInfo mappedTrackInfo, @com.google.android.exoplayer2.RendererCapabilities.Capabilities int[][][] rendererFormatSupports, DefaultTrackSelector.Parameters params, String selectedAudioLanguage)
Deprecated.Called byselectAllTracks(MappedTrackInfo, int[][][], int[], Parameters)
to create aExoTrackSelection.Definition
for a text track selection.protected Pair<@NullableType RendererConfiguration[],@NullableType ExoTrackSelection[]>
selectTracks(MappingTrackSelector.MappedTrackInfo mappedTrackInfo, @com.google.android.exoplayer2.RendererCapabilities.Capabilities int[][][] rendererFormatSupports, @com.google.android.exoplayer2.RendererCapabilities.AdaptiveSupport int[] rendererMixedMimeTypeAdaptationSupport, MediaSource.MediaPeriodId mediaPeriodId, Timeline timeline)
Deprecated.Given mapped track information, returns a track selection and configuration for each renderer.protected Pair<ExoTrackSelection.Definition,Integer>
selectVideoTrack(MappingTrackSelector.MappedTrackInfo mappedTrackInfo, @com.google.android.exoplayer2.RendererCapabilities.Capabilities int[][][] rendererFormatSupports, @com.google.android.exoplayer2.RendererCapabilities.AdaptiveSupport int[] mixedMimeTypeSupports, DefaultTrackSelector.Parameters params)
Deprecated.Called byselectAllTracks(MappedTrackInfo, int[][][], int[], Parameters)
to create aExoTrackSelection.Definition
for a video track selection.void
setAudioAttributes(AudioAttributes audioAttributes)
Deprecated.Called by the player to set theAudioAttributes
that will be used for playback.void
setParameters(DefaultTrackSelector.Parameters.Builder parametersBuilder)
Deprecated.Atomically sets the provided parameters for track selection.void
setParameters(DefaultTrackSelector.ParametersBuilder parametersBuilder)
Deprecated.UsesetParameters(Parameters.Builder)
instead.void
setParameters(TrackSelectionParameters parameters)
Deprecated.Called by the player to provide parameters for track selection.-
Methods inherited from class com.google.android.exoplayer2.trackselection.MappingTrackSelector
getCurrentMappedTrackInfo, onSelectionActivated, selectTracks
-
Methods inherited from class com.google.android.exoplayer2.trackselection.TrackSelector
getBandwidthMeter, init, invalidate, invalidateForRendererCapabilitiesChange
-
-
-
-
Field Detail
-
SELECTION_ELIGIBILITY_NO
protected static final int SELECTION_ELIGIBILITY_NO
Deprecated.Track is not eligible for selection.- See Also:
- Constant Field Values
-
SELECTION_ELIGIBILITY_FIXED
protected static final int SELECTION_ELIGIBILITY_FIXED
Deprecated.Track is eligible for a fixed selection with one track.- See Also:
- Constant Field Values
-
SELECTION_ELIGIBILITY_ADAPTIVE
protected static final int SELECTION_ELIGIBILITY_ADAPTIVE
Deprecated.Track is eligible for both a fixed selection and as part of an adaptive selection with multiple tracks.- See Also:
- Constant Field Values
-
context
@Nullable public final Context context
Deprecated.
-
-
Constructor Detail
-
DefaultTrackSelector
public DefaultTrackSelector(Context context)
Deprecated.- Parameters:
context
- AnyContext
.
-
DefaultTrackSelector
public DefaultTrackSelector(Context context, ExoTrackSelection.Factory trackSelectionFactory)
Deprecated.- Parameters:
context
- AnyContext
.trackSelectionFactory
- A factory forExoTrackSelection
s.
-
DefaultTrackSelector
public DefaultTrackSelector(Context context, TrackSelectionParameters parameters)
Deprecated.- Parameters:
context
- AnyContext
.parameters
- InitialTrackSelectionParameters
.
-
DefaultTrackSelector
@Deprecated public DefaultTrackSelector(TrackSelectionParameters parameters, ExoTrackSelection.Factory trackSelectionFactory)
-
DefaultTrackSelector
public DefaultTrackSelector(Context context, TrackSelectionParameters parameters, ExoTrackSelection.Factory trackSelectionFactory)
Deprecated.- Parameters:
context
- AnyContext
.parameters
- InitialTrackSelectionParameters
.trackSelectionFactory
- A factory forExoTrackSelection
s.
-
-
Method Detail
-
release
public void release()
Deprecated.Description copied from class:TrackSelector
Called by the player to release the selector. The selector cannot be used untilTrackSelector.init(InvalidationListener, BandwidthMeter)
is called again.- Overrides:
release
in classTrackSelector
-
getParameters
public DefaultTrackSelector.Parameters getParameters()
Deprecated.Description copied from class:TrackSelector
Returns the current parameters for track selection.- Overrides:
getParameters
in classTrackSelector
-
isSetParametersSupported
public boolean isSetParametersSupported()
Deprecated.Description copied from class:TrackSelector
Returns if thisTrackSelector
supportsTrackSelector.setParameters(TrackSelectionParameters)
.The same value is always returned for a given
TrackSelector
instance.- Overrides:
isSetParametersSupported
in classTrackSelector
-
setParameters
public void setParameters(TrackSelectionParameters parameters)
Deprecated.Description copied from class:TrackSelector
Called by the player to provide parameters for track selection.Only supported if
TrackSelector.isSetParametersSupported()
returns true.- Overrides:
setParameters
in classTrackSelector
- Parameters:
parameters
- The parameters for track selection.
-
setAudioAttributes
public void setAudioAttributes(AudioAttributes audioAttributes)
Deprecated.Description copied from class:TrackSelector
Called by the player to set theAudioAttributes
that will be used for playback.- Overrides:
setAudioAttributes
in classTrackSelector
-
setParameters
@Deprecated public void setParameters(DefaultTrackSelector.ParametersBuilder parametersBuilder)
Deprecated.UsesetParameters(Parameters.Builder)
instead.
-
setParameters
public void setParameters(DefaultTrackSelector.Parameters.Builder parametersBuilder)
Deprecated.Atomically sets the provided parameters for track selection.- Parameters:
parametersBuilder
- A builder from which to obtain the parameters for track selection.
-
buildUponParameters
public DefaultTrackSelector.Parameters.Builder buildUponParameters()
Deprecated.Returns a newDefaultTrackSelector.Parameters.Builder
initialized with the current selection parameters.
-
getRendererCapabilitiesListener
@Nullable public RendererCapabilities.Listener getRendererCapabilitiesListener()
Deprecated.Description copied from class:TrackSelector
Returns theRendererCapabilities.Listener
that the concrete instance uses to listen to the renderer capabilities changes. May benull
if the implementation does not listen to the renderer capabilities changes.- Overrides:
getRendererCapabilitiesListener
in classTrackSelector
-
onRendererCapabilitiesChanged
public void onRendererCapabilitiesChanged(Renderer renderer)
Deprecated.Description copied from interface:RendererCapabilities.Listener
Called when the renderer capabilities are changed.This method will be called on the playback thread.
- Specified by:
onRendererCapabilitiesChanged
in interfaceRendererCapabilities.Listener
- Parameters:
renderer
- The renderer that has its capabilities changed.
-
selectTracks
protected final Pair<@NullableType RendererConfiguration[],@NullableType ExoTrackSelection[]> selectTracks(MappingTrackSelector.MappedTrackInfo mappedTrackInfo, @com.google.android.exoplayer2.RendererCapabilities.Capabilities int[][][] rendererFormatSupports, @com.google.android.exoplayer2.RendererCapabilities.AdaptiveSupport int[] rendererMixedMimeTypeAdaptationSupport, MediaSource.MediaPeriodId mediaPeriodId, Timeline timeline) throws ExoPlaybackException
Deprecated.Description copied from class:MappingTrackSelector
Given mapped track information, returns a track selection and configuration for each renderer.- Specified by:
selectTracks
in classMappingTrackSelector
- Parameters:
mappedTrackInfo
- Mapped track information.rendererFormatSupports
- TheRendererCapabilities.Capabilities
for each mapped track, indexed by renderer, track group and track (in that order).rendererMixedMimeTypeAdaptationSupport
- TheRendererCapabilities.AdaptiveSupport
for mixed MIME type adaptation for the renderer.mediaPeriodId
- TheMediaSource.MediaPeriodId
of the period for which tracks are to be selected.timeline
- TheTimeline
holding the period for which tracks are to be selected.- Returns:
- A pair consisting of the track selections and configurations for each renderer. A null
configuration indicates the renderer should be disabled, in which case the track selection
will also be null. A track selection may also be null for a non-disabled renderer if
RendererCapabilities.getTrackType()
isC.TRACK_TYPE_NONE
. - Throws:
ExoPlaybackException
- If an error occurs while selecting the tracks.
-
selectAllTracks
protected @NullableType ExoTrackSelection.Definition[] selectAllTracks(MappingTrackSelector.MappedTrackInfo mappedTrackInfo, @com.google.android.exoplayer2.RendererCapabilities.Capabilities int[][][] rendererFormatSupports, @com.google.android.exoplayer2.RendererCapabilities.AdaptiveSupport int[] rendererMixedMimeTypeAdaptationSupports, DefaultTrackSelector.Parameters params) throws ExoPlaybackException
Deprecated.Called fromselectTracks(MappedTrackInfo, int[][][], int[], MediaPeriodId, Timeline)
to make a track selection for each renderer, prior to overrides and disabled flags being applied.The implementation should not account for overrides and disabled flags. Track selections generated by this method will be overridden to account for these properties.
- Parameters:
mappedTrackInfo
- Mapped track information.rendererFormatSupports
- TheRendererCapabilities.Capabilities
for each mapped track, indexed by renderer, track group and track (in that order).rendererMixedMimeTypeAdaptationSupports
- TheRendererCapabilities.AdaptiveSupport
for mixed MIME type adaptation for the renderer.params
- The parameters to use for the track selection.- Returns:
- The
ExoTrackSelection.Definition
s for the renderers. A null entry indicates no selection was made. - Throws:
ExoPlaybackException
- If an error occurs while selecting the tracks.
-
selectVideoTrack
@Nullable protected Pair<ExoTrackSelection.Definition,Integer> selectVideoTrack(MappingTrackSelector.MappedTrackInfo mappedTrackInfo, @com.google.android.exoplayer2.RendererCapabilities.Capabilities int[][][] rendererFormatSupports, @com.google.android.exoplayer2.RendererCapabilities.AdaptiveSupport int[] mixedMimeTypeSupports, DefaultTrackSelector.Parameters params) throws ExoPlaybackException
Deprecated.Called byselectAllTracks(MappedTrackInfo, int[][][], int[], Parameters)
to create aExoTrackSelection.Definition
for a video track selection.- Parameters:
mappedTrackInfo
- Mapped track information.rendererFormatSupports
- TheRendererCapabilities.Capabilities
for each mapped track, indexed by renderer, track group and track (in that order).mixedMimeTypeSupports
- TheRendererCapabilities.AdaptiveSupport
for mixed MIME type adaptation for the renderer.params
- The selector's current constraint parameters.- Returns:
- A pair of the selected
ExoTrackSelection.Definition
and the corresponding renderer index, or null if no selection was made. - Throws:
ExoPlaybackException
- If an error occurs while selecting the tracks.
-
selectAudioTrack
@Nullable protected Pair<ExoTrackSelection.Definition,Integer> selectAudioTrack(MappingTrackSelector.MappedTrackInfo mappedTrackInfo, @com.google.android.exoplayer2.RendererCapabilities.Capabilities int[][][] rendererFormatSupports, @com.google.android.exoplayer2.RendererCapabilities.AdaptiveSupport int[] rendererMixedMimeTypeAdaptationSupports, DefaultTrackSelector.Parameters params) throws ExoPlaybackException
Deprecated.Called byselectAllTracks(MappedTrackInfo, int[][][], int[], Parameters)
to create aExoTrackSelection.Definition
for an audio track selection.- Parameters:
mappedTrackInfo
- Mapped track information.rendererFormatSupports
- TheRendererCapabilities.Capabilities
for each mapped track, indexed by renderer, track group and track (in that order).rendererMixedMimeTypeAdaptationSupports
- TheRendererCapabilities.AdaptiveSupport
for mixed MIME type adaptation for the renderer.params
- The selector's current constraint parameters.- Returns:
- A pair of the selected
ExoTrackSelection.Definition
and the corresponding renderer index, or null if no selection was made. - Throws:
ExoPlaybackException
- If an error occurs while selecting the tracks.
-
selectTextTrack
@Nullable protected Pair<ExoTrackSelection.Definition,Integer> selectTextTrack(MappingTrackSelector.MappedTrackInfo mappedTrackInfo, @com.google.android.exoplayer2.RendererCapabilities.Capabilities int[][][] rendererFormatSupports, DefaultTrackSelector.Parameters params, @Nullable String selectedAudioLanguage) throws ExoPlaybackException
Deprecated.Called byselectAllTracks(MappedTrackInfo, int[][][], int[], Parameters)
to create aExoTrackSelection.Definition
for a text track selection.- Parameters:
mappedTrackInfo
- Mapped track information.rendererFormatSupports
- TheRendererCapabilities.Capabilities
for each mapped track, indexed by renderer, track group and track (in that order).params
- The selector's current constraint parameters.selectedAudioLanguage
- The language of the selected audio track. May be null if the selected audio track declares no language or no audio track was selected.- Returns:
- A pair of the selected
ExoTrackSelection.Definition
and the corresponding renderer index, or null if no selection was made. - Throws:
ExoPlaybackException
- If an error occurs while selecting the tracks.
-
selectOtherTrack
@Nullable protected ExoTrackSelection.Definition selectOtherTrack(int trackType, TrackGroupArray groups, @com.google.android.exoplayer2.RendererCapabilities.Capabilities int[][] formatSupport, DefaultTrackSelector.Parameters params) throws ExoPlaybackException
Deprecated.Called byselectAllTracks(MappedTrackInfo, int[][][], int[], Parameters)
to create aExoTrackSelection
for a renderer whose type is neither video, audio or text.- Parameters:
trackType
- The type of the renderer.groups
- TheTrackGroupArray
mapped to the renderer.formatSupport
- TheRendererCapabilities.Capabilities
for each mapped track, indexed by track group and track (in that order).params
- The selector's current constraint parameters.- Returns:
- The
ExoTrackSelection
for the renderer, or null if no selection was made. - Throws:
ExoPlaybackException
- If an error occurs while selecting the tracks.
-
isSupported
protected static boolean isSupported(@com.google.android.exoplayer2.RendererCapabilities.Capabilities int formatSupport, boolean allowExceedsCapabilities)
Deprecated.Returns true if theC.FormatSupport
in the givenRendererCapabilities.Capabilities
isC.FORMAT_HANDLED
or ifallowExceedsCapabilities
is set and the format support isC.FORMAT_EXCEEDS_CAPABILITIES
.- Parameters:
formatSupport
-RendererCapabilities.Capabilities
.allowExceedsCapabilities
- Whether to return true ifC.FormatSupport
isC.FORMAT_EXCEEDS_CAPABILITIES
.- Returns:
- True if
C.FormatSupport
isC.FORMAT_HANDLED
, or ifallowExceedsCapabilities
is set and the format support isC.FORMAT_EXCEEDS_CAPABILITIES
.
-
normalizeUndeterminedLanguageToNull
@Nullable protected static String normalizeUndeterminedLanguageToNull(@Nullable String language)
Deprecated.Normalizes the input string to null if it does not define a language, or returns it otherwise.- Parameters:
language
- The string.- Returns:
- The string, optionally normalized to null if it does not define a language.
-
getFormatLanguageScore
protected static int getFormatLanguageScore(Format format, @Nullable String language, boolean allowUndeterminedFormatLanguage)
Deprecated.Returns a score for how well a language specified in aFormat
matches a given language.- Parameters:
format
- TheFormat
.language
- The language, or null.allowUndeterminedFormatLanguage
- Whether matches with an empty or undetermined format language tag are allowed.- Returns:
- A score of 4 if the languages match fully, a score of 3 if the languages match partly, a score of 2 if the languages don't match but belong to the same main language, a score of 1 if the format language is undetermined and such a match is allowed, and a score of 0 if the languages don't match at all.
-
-